How to trim whitespace from a Bash variable?

A simple answer is: Xargs will do the trimming for you. It’s one command/program, no parameters, returns the trimmed string, easy as that! Note: this doesn’t remove all internal spaces so “foo bar” stays the same; it does NOT become “foobar”. However, multiple spaces will be condensed to single spaces, so “foo bar” will become “foo bar”. In addition it doesn’t remove … Read more

Error: “Cannot modify the return value” c#

This is because Point is a value type (struct). Because of this, when you access the Origin property you’re accessing a copy of the value held by the class, not the value itself as you would with a reference type (class), so if you set the X property on it then you’re setting the property on the copy and then discarding it, leaving … Read more

How to check if a variable is set in Bash?

(Usually) The right way where ${var+x} is a parameter expansion which evaluates to nothing if var is unset, and substitutes the string x otherwise. Quotes Digression Quotes can be omitted (so we can say ${var+x} instead of “${var+x}”) because this syntax & usage guarantees this will only expand to something that does not require quotes (since it either expands to x (which contains no word breaks so it … Read more

Append integer to beginning of list in Python

How it works: array.insert(index, value) Insert an item at a given position. The first argument is the index of the element before which to insert, so array.insert(0, x) inserts at the front of the list, and array.insert(len(array), x) is equivalent to array.append(x).Negative values are treated as being relative to the end of the array.

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