Skip to content

Instantly share code, notes, and snippets.

macek /
Created Sep 24, 2010
Running Rake tasks in Engine Yard Crontab
cd /data/MyApp/current && /usr/bin/rake some:task
macek / 20101004063749_create_photos.rb
Created Oct 4, 2010
How to save uploaded files to your database in Rails
View 20101004063749_create_photos.rb
# db/migrate/20101004063749_create_photos.rb
class CreatePhotos < ActiveRecord::Migration
def self.up
create_table :photos do |t|
t.string :name, :null => false
t.binary :data, :null => false
t.string :filename
t.string :mime_type

After upgrading to OSX Lion, I discovered that both PEAR and PECL had gone missing. It turns out that you have to re-install them, but luckily it's quite simple. I found this quick guide from Ruggero De Pellegrini on Google+, and thought I would share the info to save you the confusion:

  1. Download the installer curl > go-pear.php
  2. Start the installation procedure with sudo sudo php -q go-pear.php
  3. Select a new installation base ($prefix) e.g. /usr/local
  4. Proceed with the install.
  5. If there is no /etc/php.ini file yet, copy the default sudo cp /etc/php.ini.default /etc/php.ini
  6. Edit /etc/php.ini and change the line ;include_path = ".:/php/includes" to include_path = ".:/usr/local/share/pear"
  7. Add /usr/local/bin/ to your path if you haven't already, e.g. in .profile
macek / advanced_output
Created Sep 24, 2010
Output Buffering with Ruby
View advanced_output
A contents <<<
send this to a
this goes to a
a, I forgot to add this
B contents <<<
this goes to b
b, please
View test_mail_purge.rb
require 'minitest/mock'
require 'minitest/unit'
require 'date'
class TestMailPurge < MiniTest::Unit::TestCase
class MailPurge
def initialize(imap)
@imap = imap
macek /
Created Jul 18, 2013
be careful :)

Be careful not to outdent content under a "|" character

    hello_html: |
      this is some text


This gist tests various aspects of syslog from Ruby. In order to do so you have to setup syslog first.

Setting up syslog is system-specific and quite variable because of variations like rsyslogd or syslogd-ng. OSX, for example, uses a custom system logger (the apple system logger) that supports the syslog API, but also adds additional stuff like the 'syslog' command line application.

macek /
Created Dec 5, 2012
Things I learned from rails src

1. see a selection of routes

$ rake routes CONTROLLER=foo

2. remove heredoc indenting

require 'active_support/core_ext/string'
BREW_POSTGRES_DIR=`brew info postgres | awk '{print $1"/bin"}' | grep "/postgresql/"`
LION_POSTGRES_DIR=`which postgres | xargs dirname`
LION_PSQL_DIR=`which psql | xargs dirname`
sudo mkdir -p $LION_POSTGRES_DIR/archive
sudo mkdir -p $LION_PSQL_DIR/archive
for i in `ls $BREW_POSTGRES_DIR`
if [ -f $LION_POSTGRES_DIR/$i ]
View gist:2156106
# Super Lasagna
**disclaimer:** the sauce is the hardest part to measure because all jars are different sizes and depending on the depth of your lasagna pan, you will only be able to make so many layers. this is sort of a trial and error thing. I would start with 3 jars of whatever sauce you pick out. you're looking for around 60 oz of sauce.
## Ingredients
1 pound italian sausage
2 tbsp olive oil
crushed red chili pepper (add as much as you want to achieve desired heat level)
You can’t perform that action at this time.