Difference between >>> and >>

>> is arithmetic shift right, >>> is logical shift right. In an arithmetic shift, the sign bit is extended to preserve the signedness of the number. For example: -2 represented in 8 bits would be 11111110 (because the most significant bit has negative weight). Shifting it right one bit using arithmetic shift would give you … Read more

No Multiline Lambda in Python: Why not?

Guido van Rossum (the inventor of Python) answers this exact question himself in an old blog post. Basically, he admits that it’s theoretically possible, but that any proposed solution would be un-Pythonic: “But the complexity of any proposed solution for this puzzle is immense, to me: it requires the parser (or more precisely, the lexer) … Read more

JavaScript property access: dot notation vs. brackets?

(Sourced from here.) Square bracket notation allows the use of characters that can’t be used with dot notation: var foo = myForm.foo[]; // incorrect syntax var foo = myForm[“foo[]”]; // correct syntax including non-ASCII (UTF-8) characters, as in myForm[“ダ”] (more examples). Secondly, square bracket notation is useful when dealing with property names which vary in … Read more

What is Ruby’s double-colon `::`?

:: is basically a namespace resolution operator. It allows you to access items in modules, or class-level items in classes. For example, say you had this setup: module SomeModule module InnerModule class MyClass CONSTANT = 4 end end end You could access CONSTANT from outside the module as SomeModule::InnerModule::MyClass::CONSTANT. It doesn’t affect instance methods defined … Read more

How can I split a shell command over multiple lines when using an IF statement?

The line-continuation will fail if you have whitespace (spaces or tab characters¹) after the backslash and before the newline. With no such whitespace, your example works fine for me: $ cat test.sh if ! fab –fabfile=.deploy/fabfile.py \ –forward-agent \ –disable-known-hosts deploy:$target; then echo failed else echo succeeded fi $ alias fab=true; . ./test.sh succeeded $ … Read more

What is the meaning of prepended double colon “::”?

This ensures that resolution occurs from the global namespace, instead of starting at the namespace you’re currently in. For instance, if you had two different classes called Configuration as such: class Configuration; // class 1, in global namespace namespace MyApp { class Configuration; // class 2, different from class 1 function blah() { // resolves … Read more

What’s the meaning of “=>” (an arrow formed from equals & greater than) in JavaScript?

What It Is This is an arrow function. Arrow functions are a short syntax, introduced by ECMAscript 6, that can be used similarly to the way you would use function expressions. In other words, you can often use them in place of expressions like function (foo) {…}. But they have some important differences. For example, … Read more

Why are hexadecimal numbers prefixed with 0x?

Short story: The 0 tells the parser it’s dealing with a constant (and not an identifier/reserved word). Something is still needed to specify the number base: the x is an arbitrary choice. Long story: In the 60’s, the prevalent programming number systems were decimal and octal — mainframes had 12, 24 or 36 bits per … Read more

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