Technology
Connecting to a Crashplan instance in the Cloud
Submitted by steven on Sun, 07/04/2010 - 18:19Crashplan is a great "free" utility to automate the backing up of all your systems. I have been using it for almost a year to backup all my computers including my cloud instances.
I had to perform some maintenance on one of my cloud computers and forgot how to connect the admin tool to it. Below I'm outlining the steps so I won't forget again.
* Create a ssh tunnel to the machine
ssh -L 4200:localhost:4243 host
* Updated local CrashPlanDesktop to use port 4200
vi /usr/local/crashplan/conf/ui.properties (change port to 4200)
* Run CrashPlanDesktop
/usr/local/bin/CrashPlanDesktop
* Don't forget to revert the changes to the configuration file
vi /usr/local/crashplan/conf/ui.properties (change port back to 4243)
Empty Postfix Mail Queue
Submitted by steven on Sun, 07/04/2010 - 18:09Had an issue today where a bug sent over 20,000 messages into my postfix mail queue. Google then started "rate" limiting me as this issue was basically a DOS attack on my mail box. After some research, I found a couple ways to empty the postfix mail queue.
If you only want to purge the queue of email from use user, as root try:
mailq | tail +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" } { if ($8 == "user@example.com" && $9 == "") print $1 } ' | tr -d '*!' | postsuper -d -
To purge the entire queue:
postsuper -d ALL
Bulletproof Web Design
Submitted by steven on Sun, 02/21/2010 - 15:50Bulletproof Web Design -- Improving flexibility and protecting against worst-case scenarios with XHTML and CSS by Dan Cederholm
Let me start off by saying I'm a programmer, not a designer. Before reading Bulletproof Web Design, I had a basic understanding of just enough CSS structure and concepts to get by. This approach lead to very inefficient markup that was hard to read and maintain. What I was missing was a deeper understanding as to when to use the different constructs and why. I found this and much more in this book.
Dan Cederholm used a brilliant format in Bulletproof Web Design. Each chapter takes a single concept illustrated by an example site that employees a traditional "unbulletproof" approach and explains the pitfalls of the traditional methods. He then deconstructs the page and rebuilds it step-by-step using semantic XHTML and CSS. The books step-by-step approach of modifying only a couple lines of CSS and explaining the results make the book a quick, yet informative read.
The book starts by explaining why and how to design your site for flexible text sizes. He uses this as the driving point for the rest of the book. How to make your navigation, tables, tabs, lists, widget boxes, rounded corners, and layouts flexible. How to design your site to be valuable to users who either can not or choose not to use images and / or style sheets. The book ends with the step-by-step approach of creating a page that ties every concept together.
Reading the book has made me feel much more confident in my CSS usage. I have already seen the payoff as I have used the methodologies in the book to both design new widgets and to refactor existing code. I feel lucky to have stumbled upon it and am looking forward to reading his sequel book, Handcrafted CSS -- More Bulletproof Web Design.
ActiveRecord object caching in Ruby on Rails
Submitted by steven on Sat, 02/20/2010 - 17:03Yesterday I started playing with basic caching for PriceChirp and tried what I thought would be easy. Boy was I wrong. It turns out what I was attempting to do is not supported by :memory_store in the development environment. Before moving to :mem_cache_store, I was able to find a work around. The work around is outlined below for those who do not have the option of using memcached. However, if you can use memcached, it is by far the better route to take.
My goal was to cut down on the number of database hit by caching the resultant ActiveRecord object in :memory_store.
PriceChirp has improved wishlist support
Submitted by steven on Mon, 09/28/2009 - 03:41
![]()
This week I improved the Amazon wishlist support in PriceChirp. One of the cool features of PriceChirp from the beginning has been how easy it is to import an Amazon wishlist into PriceChirp. The only problem with this feature is it was an all or nothing proposition. Now, we have the ability to view our wishlists in PriceChirp and select which items we wish to import. The old feature of importing everything is still thee, but now we have options.
To see this feature in action, log into your PriceChirp account and do a wishlist search. This is done by searching for the email address associated to your Amazon wishlist. Once your wishlists are displayed, you can select "view wishlist" to get a listing of your items. From this page you can easily select which item to import into your personalized tracker.
Have fun!
PriceChirp tracks prices on Internationial Amazon sites
Submitted by steven on Fri, 09/25/2009 - 13:59
![]()
PriceChirp is growing. This week I added support to allow people to track prices and be alerted of changes for all the international Amazon sites. This includes Amazon US, Canada, France, Germany, Japan, and the UK. Just select the location of Amazon you are interested in searching, and use PriceChirp like normal. It was designed to make it easy to manage products from multiple sites at once. I'm hoping this design decision will pay off if in the future I add more vendors to PriceChirp.
Number to Currency Outside Rails
Submitted by steven on Fri, 09/18/2009 - 07:02I created a module I am also using both in rails and for some batch processing outside of rails. In order to ensure my data was formatted the same with both environments, I needed to figure out how to get access to the active_view helper number_to_currency outside of rails. Here is how I did it:
require 'rubygems' require 'action_view' def number_to_currency(number, options = {}) ActionView::Base.new.number_to_currency(number, options) end
Rescuing from open-uri timeouts
Submitted by steven on Sat, 09/12/2009 - 22:54Found an issue with open-uri because today Amazon's API is wonky. The same issue will occur when accessing any remote data via open-uri (like a RSS feed) if the data source is going to slow. The relevant part of my ruby code looks like:
begin doc = Nokogiri(open(api_url)) rescue print "Connection failed: #{$!}\n" next end
For some reason, the rescue does not catch a timeout error.
/usr/lib64/ruby/1.8/timeout.rb:54:in `rbuf_fill': execution expired (Timeout::Error)
Explicitly catching the timeout error fixes the code.
begin doc = Nokogiri(open(api_url)) rescue Timeout::Error print "Timeout::Error: #{$!}\n" next rescue print "Connection failed: #{$!}\n" next end
Good to know, as you never know when your remote data provider will be slow.
Gravatars on Rails
Submitted by steven on Sat, 08/29/2009 - 22:07![]()
Gravatar is the globally recognized avatar run by the folks who run Wordpress.com.
Your Gravatar is an image that follows you from site to site appearing beside your name when you do things like comment or post on a blog. This is done by associating an image to the users email address. Adding Gravatar to PriceChirp seemed like a fun thing to do.
The API is very simple, so adding it to a Ruby on Rails site is easy.
First, add a few lines to your application-helper.rb:
def gravatar_url_for(email, options = {}) url_for({ :gravatar_id => Digest::MD5.hexdigest(email), :host => 'www.gravatar.com', :protocol => 'http://', :only_path => false, :skip_relative_url_root => true, :controller => '/avatar' }.merge(options) ) end
You may also need to add:
Upgrading PriceChirp from Rails 2.2.2 to Rails 2.3.3
Submitted by steven on Thu, 08/27/2009 - 04:50Today I updated PriceChirp from rails 2.2.2 to rails 2.3.3. It was easier than expected, but I ran into several gotchas along the way. Here's an outline of the major issues I encountered and how I addressed them. Depending on your code, this may or may not be any any use. Note: Several of these steps had to be performed on both the development and production boxes.
1) Updating gems
To upgrade the base system gems, as root I ran:
gem update
This upgraded the system gems such as rails, mysql, passenger, etc. The gems built into PriceChirp in the /vendor/gems directory had to be updated separately. I'll get to those in a few minutes.
2) Updating passenger