Chrome Browser Just Made My Day Aug 17
Chrome added the ability to view :hover or :focus styles in the web inspector.

This is amazing.
If only they added :before and :after as well.
Chrome added the ability to view :hover or :focus styles in the web inspector.

This is amazing.
If only they added :before and :after as well.
I just came across Racc – a ruby implementation of Yacc. This is bringing back memories of my compiler course in college. I’m geeking out!
In college, I built a compiler for Pascal with Lex and Yacc. The project converted Pascal code to Lisp code and ran on Sun machines. It was pretty awesome. Sadly, I don’t have the code anymore, but I loved building it!
I started building a Mysql client in the web (think phpmyadmin but without the suck) and I have a need to parse SQL. Racc + SQL Parsing? Can there be anymore joy? Also, Racc’s runtime modules come with the Ruby standard library. How did I miss this?
Time to build a simple SQL parser in Ruby.
I found a great use for ActiveSupport’s Enumerable#sum while browsing through the Rails source code.
Ever write code where you need to gather a flattened array of child objects from the current array of ActiveRecord objects? For example:
class Post < ActiveRecord::Base has_many :categories end class Category < ActiveRecord::Base belongs_to :post end posts = Post.includes(:categories).all # Gather all the categories into one array using #collect all_categories = posts.collect { |post| post.categories } all_categroies.flatten! # Another way to do it with inject - no need for the #flatten call all_categories = posts.inject([]) { |sum, post| sum += post.categories }
The code is verbose. If you use Enumberable#sum you don’t have to write the inject or the flatten line:
post = Post.includes(:categories).all # Gathers all categories into one array all_categories = post.sum { |post| post.categories }
You could also use the shortcut form of that block:
all_categories = post.sum(&:categories)
My favorite part of the code is the use of the + operator and applying that to Arrays. Array + Array = Bigger Array.
Need to rsync modified files to a server? Try the following:
All you need to do is ensure that the base path set properly and modify the user@remote.server.com portion of the script and you’re all set!
Explanation after the break.
“But their eyes must converge at perhaps 10 feet away, then 60 feet, then 120 feet, and so on, depending on what the illusion is. So 3D films require us to focus at one distance and converge at another. And 600 million years of evolution has never presented this problem before. All living things with eyes have always focussed and converged at the same point.”
I strongly dislike 3D films but never knew why. Now I know.
Last I left off, I talked about bad fish and chips and Harry Potter. At the end of my London stay, I needed a break from traveling. I decided to head over to Dublin to visit a friend and hang out. After Dublin, I flew over to Edinburgh since it’s only an hour away. Both cities were very low key for me.