Skip to content

Instantly share code, notes, and snippets.

@ingeniarius
ingeniarius / nginx.conf
Created March 12, 2012 19:33
nginx upstart config
# nginx
description "nginx http daemon"
author "George Shammas <georgyo@gmail.com>"
start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]
env DAEMON=/usr/sbin/nginx
env PID=/var/run/nginx.pid
@ingeniarius
ingeniarius / gist:2924959
Created June 13, 2012 15:57
DCI yet another approach
class User < ActiveRecord::Base
end
class Book < ActiveRecord::Base
end
module CustomerRole
end
class AddToCartContext
@ingeniarius
ingeniarius / setup_ruby19.sh
Created July 10, 2012 09:28
Install Ruby 1.9.x on Ubuntu from sources
echo "Install Ruby..."
sudo apt-get update
sudo apt-get install build-essential libssl-dev zlib1g-dev libreadline-dev
export ruby_version=1.9.3-p194
cd /usr/src
sudo wget "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-$ruby_version.tar.bz2"
sudo tar xf "./ruby-$ruby_version.tar.bz2"
sudo rm "./ruby-$ruby_version.tar.bz2"
@ingeniarius
ingeniarius / 0. nginx_setup.sh
Created July 10, 2012 14:11 — forked from mikhailov/0. nginx_setup.sh
Nginx+Unicorn (production-ready setup)
# download and build nginx from sources
https://gist.github.com/3083579
#
# Paperclip convert id => id_partition
#
require 'fileutils'
class PaperclipExtend
def self.obtain_class
class_name = ENV['CLASS'] || ENV['class']
uploads_path = ENV['UPLOADS_PATH'] || ENV['uploads_path']
raise "Must specify CLASS" unless class_name
@ingeniarius
ingeniarius / raskell.rb
Created August 16, 2012 18:34 — forked from andkerosine/raskell.rb
Haskell-like list comprehensions in Ruby
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@
@ingeniarius
ingeniarius / dance.rb
Created September 24, 2012 13:38 — forked from ernie/dance.rb
Dependency Injection
#!/usr/bin/env ruby
require './dancer'
require './gangnam_style'
dancer = Dancer.new('PSY', GangnamStyle.new)
dancer.dance!
@ingeniarius
ingeniarius / Makefile
Created October 12, 2012 09:21
Makefile for SPIM S20 MIPS Simulator
#
# SPIM S20 MIPS Simulator.
# Makefile for SPIM.
#
# SPIM is covered by a BSD license.
#
# Copyright (c) 1990-2010, James R. Larus.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
@ingeniarius
ingeniarius / build_gemtags
Created November 27, 2012 13:02
Build the whole Ruby Gems ctags file for application
ruby -e "require 'bundler';paths = Bundler.load.specs.map(&:full_gem_path);system(%Q[ctags -R -f .gemtags #{paths.join(' ')}])"
@ingeniarius
ingeniarius / mysql_to_postgres.rb
Created February 22, 2013 15:13
Migrate data from MySQL to PostgreSQL using ActiveRecord Based on https://github.com/braintree/mysql_to_postgresql
#!/usr/bin/env ruby
require 'logger'
require 'active_record'
require 'active_record/base'
require 'active_support'
ActiveRecord::Base.logger = Logger.new("log/mysql_to_postgresql.log")
PROCESSES = 8