People frequently use lines of code as a metric. How many times have you heard someone say, “it’s only 10 lines?” or “This class is almost 200 lines?” Have you ever heard somebody boast that they could write something in fewer lines of code? Do you talk about your test to code ratio?
How many…
The cats out of the bag, Ruby isn’t immune to legacy code problems. Just because your app is written in a hip, fun, and dynamic language doesn’t mean that your codebase can’t stagnate, bloat, and quickly turn into an unmaintainable ball of mud. Before Gowalla was purchased by Facebook, the Rails…
__label__(:loop)
puts “The Ruby core team is playing a joke on us!”
__goto__(:loop)
puts “This line of code is never reached.”
This code works only if you compile ruby 1.9 to support goto statement.
p/s: Got this from the comments - http://kerneltrap.org/node/553/2131
A great article explaining a bit in depth of how Ruby code is translated to native machine code via JVM.
Great article with source code examples.
Convert Ruby 1.8 to 1.9 hash syntax
In vim, for an entire file:
:%s/:\([^ ]*\)\(\s*\)=>/\1:/gIn the shell, for an entire project:
perl -pi -e 's/:([\w\d_]+)(\s*)=>/\1:/g' **/*.rbNow, instead of those old-school hashes like this:
get '/', :agent => MOBILE_BROWSERS doYou’ll have new-school hashes like this:
get '/', agent: MOBILE_BROWSERS do
Tech newsletters
Just to share some newsletters I subscribe to. We all live in a world filled with noise and interruption. Sounds old school, but this is how I manage all the constant updates in tech world.
This way I don’t have to lurk HN, Reddit or other places while keeping focus on other important stuffs for the week.
Check these out.
- Ruby Weekly - curated by Peter Cooper - Ruby, Rails, Sinatra etc
- HTML5 Weekly - curated by Peter Cooper - HTML5, CSS3, Webdesign
- Javascript Weekly - curated by Peter Cooper - Javascript, Node.js, Jquery
- Hacker Newsletter - curated by Kale Davis - Stuffs from Hacker News
- Web Design Weekly - Awesome stuffs on HTML5 etc.
- StatusCode - curated by Peter Cooper - Software development stuffs.
Apart from above I do subscribe to some weekly newsletter over at StackExchange (StackOverflow, ServerFault, Programmers) just to get a glance at good questions/tips on related stuffs.
Practical Ruby for everybody (journalists, researchers, scientists etc.)
His articles are good explaining Rails core codes. Check it out if you want to dig in deeper into Rails core.
He writes about commit messages, the reason behind them and some insights or opinions regarding these code commits.
The concept of code gardening makes Rails organically grow. There are similarities between our codes and our gardens. Maybe by looking at this similarity we will better ourselves as coders.
Learning from the Masters is definitely a series of articles worth following. Check it out.
The simplest explanation on Threads in Ruby.