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!
The first thing you usually do to customize your new techy blog is adding support for code blocks with syntax highlighting.
Now, I like to write my tumblr posts using markdown, the smart, portable markup choice. Markdown also gives you easy means to display code - Backticks ` surround inline…
attr_accessor_with_default
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 # => 26You 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?
Look at this code:
#let's define a variable not_five = 7 #and a method with the same name def not_five 3 endWhat do you think
not_fivewill produce? Will it output the variable value or execute a method?
>>not_five =>7Ruby 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
irb --noechowill do the trick.
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?
It is possible with supercool gem LESS www.lesscss.org/