Joined July 2012
·

Santiago Rojo

Developer at Graion
·
Buenos Aires, Argentina
·
·
·

This was very useful for me.

Posted to AngularJS Toggle Class over 1 year ago

Nice, but just a detail. I'd change this line:

(element.hasClass(value)) ? element.removeClass(value) : element.addClass(value);

That structure is a conditional "assignment" not an if statement.

Posted to My Bash Prompt over 1 year ago

It will be great if you put some explanation of maybe a preview of the prompt

Posted to Use an alt image for img HTML tags over 1 year ago

@blainesch you're absolutely right. I didn't thought about that, the alternative image should exist, the idea is to set a default image that you know.

Posted to PHP operator precedence over 1 year ago

From the documentation http://php.net/manual/en/language.operators.logical.php, is pretty clear how or and and work.

Operators like || and && will make the logical comparison between two boolean values.

$a = false || true; // a => true

is equal to:

$a = (false || true); // a => true

But or and and will make a decision in the flow of the program. The or operator will run the second part of the expression only in the first one has failed. For instance:

connect_to_my_db() or die('Nope!');

That's the most common usage for the or operator. But, when we use it for something like this:

$a = false or true; // a => false

This is the wrong way to use this kind of operator. What happens here is that, PHP will try to identify two expressions and it will do it. The first expression is $a = false and the second one is true. Then will consider that the assignment was successful and will not use the second part of the or operation.

So, the equivalent for the previous line of PHP is:

($a = false) or true; // $a => false

The same thing for the and operator, but it'll examine the second part of the operation only in the first one was successful. For example, you can do something like this:

open_my_file() and read_my_file();

Only if the opening of the file has succeeded then it'll read the content of the file.

Is this confusing? Maybe yes. So, this is not a bug, but we're using the language in the wrong way.

Posted to PHP has standards, USE THEM! over 1 year ago

@creaktive that's a great link, every PHP developer must read. But is not related to this tip.

Posted to Bye Bye CSS Box Model... over 1 year ago

For me, one of the major achievements of "border-box method" is the safe use of mixed units; i.e. width of 50% and border of 1px.

Posted to var_dump vs. var_export over 1 year ago

Also, var_dump shows information about the type of the variable. I think that each of them is for a particular purpose.

Posted to The single most useful thing in bash over 1 year ago

I'll start to use it.

Posted to PHP the right way over 1 year ago

Hey, nice resource!

Thanks

Posted to git add -p over 1 year ago

Great tip. I think that I'm gonna use it a lot.

PS: The next time be more verbose please :P

Posted to Use an alt image for img HTML tags over 1 year ago

The bug is already fixed.

Achievements
103 Karma
16,644 Total ProTip Views