Ok, so thats a pretty trivial example, what I really wanted to say in this post is that Aloha on Rails is coming and it is going to be pretty awesome. Seth Ladd released a nice blog post about it today. You should really check it out.
Wednesday, May 06, 2009
Chad Fowler's 20 Rails Development No-No's
Chad Fowler, who will be keynoting at the Aloha on Rails RailsConf, recently released a list a 20 Rails Development No-No's on his blog. It is a decent list to review to help make yourself aware of various Rails "code smells." Throwing in my 2 cents, for number 10, Code in the Wrong Place, I would like to mention controllers that load the flash with HTML. If you are putting any HTML in your flash then you should use a proper view technology, such as a partial, to load it up:
Ok, so thats a pretty trivial example, what I really wanted to say in this post is that Aloha on Rails is coming and it is going to be pretty awesome. Seth Ladd released a nice blog post about it today. You should really check it out.
Ok, so thats a pretty trivial example, what I really wanted to say in this post is that Aloha on Rails is coming and it is going to be pretty awesome. Seth Ladd released a nice blog post about it today. You should really check it out.
VPN fix after Ubuntu Update - LCP terminated by peer
I use a VPN connection to my corporate email system to pull in emails and send them over to a gmail account with fetchmail. After upgrading to Ubuntu 9.04 (actually I think it was the upgrade to 8.10, but I went from 8.04 -> 8.10 -> 9.04 on the same day) the setup came crashing down - the VPN would no longer connect and thus and I was no longer able to get any emails. It turns out that the problem was related to a change in a configuration file after updating...before I get to that however, let me note my configuration.
First, my /etc/ppp/peers/cambervpn file:
next, my /etc/ppp/chap-secrets file:
next, my /etc/ppp/ip-up.d/cambervpn file:
and finally, my /etc/ppp/ip-down.d/cambervpn file:
To bring that up, you type "sudo pon cambervpn". After the upgrade, my syslog was telling me "Non-zero Async Control Character Maps are not supported!" and "LCP terminated by peer". Googling around led me believe this was a problem with MPPE. Sure enough, in looking at the file /etc/ppp/options.pptp I found that both MPPE options were commented out. Uncommenting the line "require-mppe-128" did the trick.
Hey, well if you read this far I guess you might be wondering what kind of command I issue to get fetchmail to forward mail over to my gmail account. The following command causes fetchmail to fetch the mail every 300 seconds:
An entry in my .netrc file provides the password for the POP server.
First, my /etc/ppp/peers/cambervpn file:
next, my /etc/ppp/chap-secrets file:
next, my /etc/ppp/ip-up.d/cambervpn file:
and finally, my /etc/ppp/ip-down.d/cambervpn file:
To bring that up, you type "sudo pon cambervpn". After the upgrade, my syslog was telling me "Non-zero Async Control Character Maps are not supported!" and "LCP terminated by peer". Googling around led me believe this was a problem with MPPE. Sure enough, in looking at the file /etc/ppp/options.pptp I found that both MPPE options were commented out. Uncommenting the line "require-mppe-128" did the trick.
Hey, well if you read this far I guess you might be wondering what kind of command I issue to get fetchmail to forward mail over to my gmail account. The following command causes fetchmail to fetch the mail every 300 seconds:
An entry in my .netrc file provides the password for the POP server.
Tuesday, May 05, 2009
Some Core Javascript Functions
I recently worked on two different projects that involved a fair amount of Javascript centering around using the Google Maps API. In doing so I began to factor out some of the components to be reusable in a general Google Maps project. While I usually use the excellent Prototype Javascript library I didn't want to leak Prototype code into these reusable components. This led me to using these functions, borrowed / evolved from various places, as the core functions to support the components:
I think these functions are a pretty good representation of the baseline support you will want in many Javascript projects.
I think these functions are a pretty good representation of the baseline support you will want in many Javascript projects.
Monday, April 13, 2009
Javascript Puzzler
Invoking an anonymous JavaScript function is a handy technique for avoiding namespace collisions in JavaScript code. The following two code snippets show the definition of a top level function followed by the invocation of an anonymous function. One of them, however, has a (easily fixed) problem (at least on Firefox 3.0.8). Can you spot what it is? Try figuring it out without running the code - don't cheat! Put your answer in the comments.
Snippet one:
Snippet two:
Surprising behavior. I'd be interested to find out if different browsers / JavaScript engines treat these code snippets in the same way.
Snippet one:
Snippet two:
Surprising behavior. I'd be interested to find out if different browsers / JavaScript engines treat these code snippets in the same way.
Friday, April 10, 2009
I Canz haz Ur Nullz at Bottom?
SQL Server when doing ORDER BY will put rows with null values in the sort column at the top - of course a simple adjustment to your ORDER BY can fix that:
Aloha on Rails is coming! I'll blog a bit more about this in the future but this should be a great conference with great sessions and Waikiki Beach just across the street!
Aloha on Rails is coming! I'll blog a bit more about this in the future but this should be a great conference with great sessions and Waikiki Beach just across the street!
Tuesday, April 07, 2009
Rails - Read More, Code Less, do Peer Reviews
For some previous projects I rolled some simple code for generating a random string - used to generate a password reset token for example:
Now I've found that this type of functionality has been in Rails for some time - now as ActiveSupport::SecureRandom and previously as Rails::SecretKeyGenerator.
Ok so that is simple code and probably isn't a problem but the lesson here is: read more, code less, do peer reviews...don't waste a lot of time re-inventing the wheel.
Now I've found that this type of functionality has been in Rails for some time - now as ActiveSupport::SecureRandom and previously as Rails::SecretKeyGenerator.
Ok so that is simple code and probably isn't a problem but the lesson here is: read more, code less, do peer reviews...don't waste a lot of time re-inventing the wheel.
Monday, April 06, 2009
Rails ActiveRecord Order by a Function
Of course you can pass functions in the order clause through ActiveRecord finders:
In the above case a Foo has fiscal_year and fiscal_month columns unfortunately stored as VARCHAR(255) containing, for example "2008" and "7". While the sorting will work that query will be able to leverage an index on these columns only if the database used can create indices that include functions. I'm not sure which databases can do this. From a quick look at the SQL Server and MySQL documentation it doesn't appear that either of these databases can do this.
In the above case a Foo has fiscal_year and fiscal_month columns unfortunately stored as VARCHAR(255) containing, for example "2008" and "7". While the sorting will work that query will be able to leverage an index on these columns only if the database used can create indices that include functions. I'm not sure which databases can do this. From a quick look at the SQL Server and MySQL documentation it doesn't appear that either of these databases can do this.
Subscribe to:
Posts (Atom)