Ben Matasar
SQL for finding duplicate fields
I found this at Peter Freitag's blog.
SELECT email, COUNT(email) AS NumOccurrences FROM users GROUP BY email HAVING ( COUNT(email) > 1 );
tech | link | 2006/Jun | comments (0)
Emacs Snippets and Ruby
I've crossed a threshold past which it's actively painful to use any editor that is not emacs. I'm not thrilled by this, especially as I modify my emacs to make it even more different from all other tools I might use in the world. I registered TextMate before I broke myself, and I still use it for files with multiple source languages, like html/css/javascript. For almost everything else, I am now an emacs user. One feature I used to miss from TextMate is snippets, which are little shortcuts that autocomplete common phrases. Happily, an enterprising emacs-lisp hacker wrote snippet.el that builds on abbrev-mode. Combined with a chunk of the emacs-rails project, I have the following in my ~/.emacs:
(setq ruby-mode-abbrev-table (make-abbrev-table)) (require 'rails-lib) (def-snips (ruby-mode-abbrev-table) ("ea" "each { |$${elm}| $${body} }" "each") ("eacho" "each do |$${elm}|\n$>$.\nend" "each do") ("sorb" "sort_by { |$${elm}| $${body} }" "sort_by") ("coll" "collect { |$${elm}| $${body} }" "collect") ("collecto" "collect do |$${elm}|\n$>$.\nend" "collect do") ("sel" "select { |$${elm}| $${body} }" "select") )
Note that this will not work unless you are in abbrev-mode. Other than def-snips, I don't use emacs-rails at all, because I find that it's too heavyweight for me now that I know my way around. So when I type, for example, eacho followed by spacebar, emacs autocompletes with:
each do |elm| end
I can tab around the block to fill in the individual fields. The biggest win is that I don't have to type pipes or other hard to reach characters for common block idioms in ruby. It's sort of hard to explain, but worth trying and wonderful for TextMate users. I use snippets all the time, and add new snippets as I notice common things I type in Ruby or Python.
tech | link | 2006/Jun | comments (0)
Fenway Park
Last week I went to Boston to visit my best friend since high school. Naturally, I made sure the Red Sox were in town and got tickets. Descriptions of Fenway are neither new nor insightful, so I'm not going to go on at length about the walk up to the park, or the small chairs, or the Green Monster -- all of that is of course wonderful and well documented. One striking thing I did notice at Fenway is that everybody is into the game. They're completely focused on baseball: no dot races on the big TV, few beach balls, and just one attempted wave in two games. It's refreshing, especially compared to a place like Wrigley, where you get the impression everybody is more interested in getting drunk than watching baseball.
The first game, a nail-biter the Red Sox won on a sacrifice fly in the bottom of the eighth, is the most fun I've had at a regular season baseball game since the 1995 Mariners. I also can not say enough about the amazing Red Sox fans, and this is coming from one of their sharpest critics. They're annoying, whiny and intolerable over the internet. At the game, they're fantastic. Our second game was delayed by rain for five hours, and the stadium TV showed the Yankees/A's game. When it ended with a Yankees loss, the whole stadium erupted as it put the Sox one game ahead. I loved it, highly recommended.
baseball | link | 2006/Jun | comments (0)
Ben Matasar ben@matasar.org