Use node.js as javascript playground

In the past,I run my js test code in Firebug,it’s convenient to test my js function or code snippets.But this method has one disadvantage,that is I must write or paste my code on to the console of Firebug,the code can’t be stored in file.

Now,I find node.js,a awesome js playground.

You can install node.js easily.


./configure
make
make install

When node.js is available on your platform,you can start to play your js code. Just save your code to a file,and node your file in terminal.

Cool!

attr_accessor_with_default

rubyflare:

Here’s a method I hadn’t seen before: attr_accessor_with_default

This ActiveSupport method allows you to set a default value for an attribute accessor:

class Person
  attr_accessor_with_default :age, 25
end

some_person.age    # => 25

some_person.age = 26
some_person.age    # => 26

You can even pass in a block. Thanks to @modsognir for finding this one. I wonder why it doesn’t appear in the method list on the Rails API.

(via rubyloveinfo)

Variable or Method?

milandobrota:

Look at this code:

#let's define a variable
not_five = 7

#and a method with the same name
def not_five
  3
end

What do you think

not_five

will produce? Will it output the variable value or execute a method?

>>not_five
=>7

Ruby gives priority to the variables. If you want to force calling a method you can do it like this:

>>self.not_five
=>3

All Data In Cloud,Cool Thing.

Chrome is OS,Tab is application.

New Tab is Desktop.

Cloud,Cloud,Cloud!

Stop Printing Out Values After Each Statement in IRB

milandobrota:

irb --noecho

will do the trick.

solving jquery prototype conflict


(function($) { 
    //your code 
})(jQuery); 

git-undo a merge

With git log check which commit is one prior the merge. Then you can reset it using:

git reset --hard commit_sha

There’s also another way

git reset --hard HEAD~5

will get you back 5 commits.

Using ruby in CSS?

milandobrota:

It is possible with supercool gem LESS www.lesscss.org/