Skip to content

Instantly share code, notes, and snippets.

View kyriacos's full-sized avatar

Kyriacos Souroullas kyriacos

View GitHub Profile
@kyriacos
kyriacos / gist:1397872
Created November 27, 2011 17:40 — forked from chad/gist:76951
# How to find out where a method comes from.
# Learned this from Dave Thomas while teaching Advanced Ruby Studio
# Makes the case for separating method definitions into
# modules, especially when enhancing built-in classes.
module Perpetrator
def crime
end
end
class Fixnum
@kyriacos
kyriacos / gist:1173091
Created August 26, 2011 09:49
Patched Ruby 1.9.2 for faster load and GC
cd /tmp
# Faster require:
# https://gist.github.com/1008945
curl -O https://raw.github.com/gist/1008945/4edd1e1dcc1f0db52d4816843a9d1e6b60661122/ruby-1.9.2p290.patch
# GC-tuning:
# https://gist.github.com/856296
curl -O https://raw.github.com/gist/856296/a19ac26fe7412ef398bd9f57e61f06fef1f186fe/patch-1.9.2-gc.patch
#!/bin/sh
set -u
set -e
# Example init script, this can be used with nginx, too,
# since nginx and unicorn accept the same signals
# Feel free to change any of the following variables for your app:
APP_ROOT=/home/deploy/public_html/rm/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
ENV=production
@kyriacos
kyriacos / README.markdown
Created August 7, 2011 23:05 — forked from ariera/README.markdown
Nestable, sortable and dragable categories

Nestable, sortable and dragable categories:

In the project I'm working on we wanted to have a Category model which we wanted to be nestable. But we also liked the user to have a draggable interface to manage and rearrange the order of his categories. So we chose awesome_nested_set for the model and jQuery.nestedSortable for the UI.

It took me some time to arrange things to work properly so I wanted to share my work in case it helps anybody.

Before beginning

you might want to take a look at a demo app

  1. go to: http://awesomenestedsortable.heroku.com/groups/1
  2. click in manage categories
@kyriacos
kyriacos / Deploy
Created August 5, 2011 17:47 — forked from coop/Deploy
Deploy to S3 - Asset Pipeline, S3 and Heroku
namespace :deploy do
desc "Deploy to Heroku"
task :heroku do
Rake::Task["deploy:precompile_assets_and_upload_to_s3"].invoke
Rake::Task["deploy:push_heroku"].invoke
end
desc "Precompile assets and upload to s3"
task :precompile_assets_and_upload_to_s3 do
storage = Fog::Storage.new :provider => 'AWS', :aws_access_key_id => "123", :aws_secret_access_key => "123"
@kyriacos
kyriacos / migrator
Created February 20, 2011 11:14 — forked from maxim/migrator
#!/usr/bin/env ruby
# Simple migration navigator for terminal.
#
# Install
# 1) Throw this code into script/migrator
# 2) chmod +x script/migrator
#
# Use
# script/migrator => show 10 latest migrations, choose one
@kyriacos
kyriacos / Gemfile
Created February 5, 2011 12:54 — forked from darkhelmet/Gemfile
gem 'resque', '>= 1.10.0'
gem 'heroku' # You will need the heroku gem for this too.
Factory.define :application do |factory|
factory.attachment(:sample, "public/samples/sample.doc", "application/msword")
end
@kyriacos
kyriacos / dbdocs.rb
Created January 22, 2011 12:09 — forked from adelevie/dbdocs.rb
require 'sinatra'
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => 'mysql',
:encoding => 'utf8',
:database => 'foo',
:username => 'bar',
:password => 'baz',
:host => 'localhost'
@kyriacos
kyriacos / Gemfile
Created January 10, 2011 15:21 — forked from lstoll/Gemfile
gem 'compass', '0.10.2'
gem 'compass-960-plugin', :require => 'ninesixty'
gem 'haml', '3.0.10'