Amazon Reduced Redundancy Storage Released
Rack::Bug setup
Code Readability vs Optimization
Exporting MySQL database
Exporting mySQL dumps can sometimes be tricky. Some sites suggest exporting dump like so:
mysqldump database_name > dump.sql
However, the problem with this method, is that the stream redirect might not be able to handle UTF-8 encoding correctly on certain OSes. I recently had a project that uses exotic characters and some characters...
Executing SQL commands in Rails
Most of the times, ActiveRecord's helpers to access database info is all you need; sometimes, you want to do some hacky stuff.
For example, I had to figure out a database's timezone and schema but I had no shell access to the server. So I ran this used Base.connection.execute and fetch_row to get the...
Copying files between S3 accounts
Recently, I had to transfer a all files from one S3 account to another one. Since I didn't like to bother Amazon with my petty problems. I decided to use a ruby script to do it. Here's the script and some steps I took to do it.
Setup
First thing we need to do is to...
Counting total number of objects in S3
Sometimes it comes in handy to get the total number of objects you have in S3 but it is not as straight forward. Here's a snippet I use to get total number of objects using right_aws gem.
require 'rubygems'
require 'right_aws'
AWS_ID='id
Lazy blogging with Twitter and Tumblr
Recently, I was bored with trying to follow links on Twitter Trends for videos and images. So I put this script together quickly to search for all new Twitter results then post the tweets with links on Tumblr, where it would show images and videos.
Setup
You'll need to have a few gems:
- hpricot
- ruby-tumblr
sudo gem install hpricot...
Scraping Images from Twitpics
Recently, I've been scraping Images and videos from Twitter and one site that has not been too easy to grab pics from is Twitpics. Here's a snippet of code that I've been using to grab the image from Twitpic with Hpricot:
require 'net/http'
require 'hpricot'
def...
Finding Memory Leaks with Bleak House
Sometimes a project can get large with many lines of code and some of those parts may have some leaks. These leaks might not be bad at first, but it will eventually can eat up all the memory on a server and cause it to act slow. Then, the thins/mongrels will have to be...
Copy S3 assets with right_aws
Lately, I've been using right_aws to interact with S3. One thing that I found helpful was copying assets between buckets and keeping the same permissions on them. However, it's not as simple as just copying the assets over. You need to get the Access Control Policy from the source and put it in the...

