-
Arel and Nested Queries
Arel is good at facilitating conditional clauses. This post mainly focuses on how to write nested queries with Arel. Let's look at a simple nested select example: SELECT * FROM ( SELECT * FROM users WHERE users.id < 100 ) as old_users One way to implement this is mixing ActiveRecord…
-
D3 for Beginners
I've longed for learning D3. It's partially because I love graphes. One graph triumphs thousands of words, I think. Now I got the opportunity to learn it while working on a gig. Sweet! The first couple of graphs I drew were just basic column charts, pie/…
-
Exclude Some Stylesheets in Rails 4
Rails 4 uses asset pipeline to concatenate and minify or compress JavaScript and CSS assets. It creates a default app/assets/stylesheets/application.css file which contains these lines: /* *= require_self *= require_tree . */ The require_tree directive tells Sprockets to recursively include all CSS files in the specified directory into…
-
Javascript Prototype and Inherance
We know that one way of Javascript supporting inherence is through prototype/__proto__. var accord = {make: 'Honda', model: 'accord'} var civic = {model: 'civic'} civic.__proto__ = accord Because civic inherits from accord, civic's make will be: civic.make =>'Honda' Javascript…
-
Fix Homebrew After Upgrade to Yosemite
I have been on Snow Leopard for years. My mac book air is almost 4 years old and I don't think I've ever upgraded my OS. Now I'm falling really behind, but I've been reluctant to upgrade because it's going…
-
Closure in Javascript, Ruby and Python
Closure is after an outer function returns, when inner function is called, it still has access to the outer function's defined variables. In order for the language to be able to support closures, it must support first-class functions. A first class function is a function that can be…