Dynamic variable names in Bash

I’ve been looking for better way of doing it recently. Associative array sounded like overkill for me. Look what I found: suffix=bzz declare prefix_$suffix=mystr …and then… varname=prefix_$suffix echo ${!varname} From the docs: The ‘$’ character introduces parameter expansion, command substitution, or arithmetic expansion. … The basic form of parameter expansion is ${parameter}. The value of … Read more

How do you dynamically add elements to a ListView on Android?

Create an XML layout first in your project’s res/layout/main.xml folder: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:orientation=”vertical” android:layout_width=”fill_parent” android:layout_height=”fill_parent” > <Button android:id=”@+id/addBtn” android:text=”Add New Item” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:onClick=”addItems”/> <ListView android:id=”@android:id/list” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:drawSelectorOnTop=”false” /> </LinearLayout> This is a simple layout with a button on the top and a list view on the bottom. Note that the … Read more

What’s the difference between eval, exec, and compile?

The short answer, or TL;DR Basically, eval is used to evaluate a single dynamically generated Python expression, and exec is used to execute dynamically generated Python code only for its side effects. eval and exec have these two differences: eval accepts only a single expression, exec can take a code block that has Python statements: … Read more

What is the difference between call and apply?

The difference is that apply lets you invoke the function with arguments as an array; call requires the parameters be listed explicitly. A useful mnemonic is “A for array and C for comma.” See MDN’s documentation on apply and call. Pseudo syntax: theFunction.apply(valueForThis, arrayOfArgs) theFunction.call(valueForThis, arg1, arg2, …) There is also, as of ES6, the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)