Skip to content

Instantly share code, notes, and snippets.

@tarcieri
tarcieri / gist:5483325
Last active December 16, 2015 19:10
The DHH Drinking Game

The @dhh Drinking Game

Take a drink whenever @dhh:

  1. Drops the f-bomb (or says "shit")
  2. Makes fun of Java (or Struts, Hibernate, etc)
  3. Mentions "frameworks should be extractions, not inventions"
  4. Mentions "constraints are liberating"
  5. Defends TurboLinks or the asset pipeline
  6. Mentions Basecamp
@clifff
clifff / C-large-1.in
Created April 21, 2013 16:33
Google Code Jam - Fair and Square Large Input 1
10001
1002001 1004006004002
14541 102030301
44944 1022325232202
1000001999901 1211124711121
2617287827163 4000008000005
1 101
1022325232201 1213326733121
44943 12345654321
42874 103045301
@paulsturgess
paulsturgess / reset_primary_key.md
Created February 27, 2013 19:49
Reset postgres primary key index using Rails
$ ActiveRecord::Base.connection.reset_pk_sequence!('table_name')

If you need the table names:

$ ActiveRecord::Base.connection.tables

=> ["accounts", "assets", ...]

@lpar
lpar / flac2mp3.rb
Created January 26, 2013 22:58
Ruby script I use to convert FLAC files to MP3, and then copy the metadata across.
#!/usr/bin/env ruby
# encoding: UTF-8
# Convert FLAC files to mp3 files, keeping metadata from the FLAC files.
#
# Requires that FLAC (including metaflac) and LAME tools be installed
# and on the path.
#
# Takes any number of .flac files on the command line.
@stas
stas / deploy.rb
Created January 15, 2013 15:34
Mina Deploy Task (Rails + Puma + Delay Job + rbenv)
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
# require 'mina/rvm' # for rvm support. (http://rvm.io)
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git)
@ctalkington
ctalkington / Gemfile
Last active May 16, 2023 20:19
Nginx, Sinatra, and Puma.
source :rubygems
gem "puma"
gem "sinatra"
@markbates
markbates / gist:4240848
Created December 8, 2012 16:06
Getting Started with Rack

If you're writing web applications with Ruby there comes a time when you might need something a lot simpler, or even faster, than Ruby on Rails or the Sinatra micro-framework. Enter Rack.

Rack describes itself as follows:

Rack provides a minimal interface between webservers supporting Ruby and Ruby frameworks.

Before Rack came along Ruby web frameworks all implemented their own interfaces, which made it incredibly difficult to write web servers for them, or to share code between two different frameworks. Now almost all Ruby web frameworks implement Rack, including Rails and Sinatra, meaning that these applications can now behave in a similar fashion to one another.

At it's core Rack provides a great set of tools to allow you to build the most simple web application or interface you can. Rack applications can be written in a single line of code. But we're getting ahead of ourselves a bit.

@jdeoliveira
jdeoliveira / gist:4080656
Created November 15, 2012 19:28
Dump/restore a postgres database in binary format for distribution
/Library/PostgreSQL/9.1/bin/pg_dump --host localhost --port 5432 --username <USERNAME> -b -c -E UTF-8 --no-owner --no-privileges --no-tablespaces --clean --schema public -F c -Z 9 -f <BACKUPFILENAME> <DATABASENAME>
/Library/PostgreSQL/9.1/bin/pg_restore --host localhost --port 5432 --username <USERNAME> --dbname <DATABASENAME> --no-owner --no-privileges --no-tablespaces --clean --schema public "<BACKUPFILENAME>"
@mysteriouspants
mysteriouspants / 000-README.md
Created November 7, 2012 17:08
HAML vs ERB vs SLIM on JRuby 1.7.0 Showdown!

Section of Introductions

This was all done on a rather nice iMac:

  • Intel Core i7 Sandy-Bridge 4-core chip
  • 12 GB of RAM
  • 1TB Spinning-disk hard drive
  • java version 1.6.0_37, build 1.6.0_37-b06-434-11M3909 "HotSpot" 64-bit VM "mixed mode" (whatever that's supposed to mean)
  • The excellent pre-chewed testing app at
@wlangstroth
wlangstroth / deploy.rb
Last active September 11, 2021 13:15
Capistrano + Nginx + Unicorn + Sinatra on Ubuntu
require 'bundler/capistrano'
set :application, "net"
set :repository, "git@githost.com:net.git"
set :scm, :git
set :default_environment, {
'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
}