Skip to content

Instantly share code, notes, and snippets.

@AndrewVos
AndrewVos / install-irssi-on-ec2.sh
Created September 3, 2011 22:58
Installing IRSSI on ec2
# dependencies
sudo yum install pkg-config
sudo yum install perl-ExtUtils-Embed
# Download and extract latest irssi
wget http://irssi.org/files/irssi-0.8.15.tar.gz
tar tar -xzvf irssi-0.8.15.tar.gz
#configure and make
cd irssi-0.8.15
@apeiros
apeiros / wav.rb
Created November 6, 2011 19:10
Fun with pure tones and WAV (see code after __END__)
class Numeric; def cap(min,max) return min if self < min; return max if self > max; self; end; end
class Wav
module Generators
end
def self.mnot(str)
tones = {
'C' => 264.0,
@taktran
taktran / mongomapper_cheatsheet.md
Created January 25, 2012 19:39
Mongomapper cheatsheet

Mongomapper cheatsheet

Mongomapper reference

Set up connection

require 'mongo_mapper'

def setup_mongo_connection(mongo_url)
@rodreegez
rodreegez / gist:1818506
Created February 13, 2012 17:36
Ruby 1.9.2 Load paths

via Gregory Brown (@seacreature) on Twitter:

Wrong way to deal with the 1.9.2 removal of . from the loadpath:

  1. require "./foo/bar" forces you to run code from your project root
  2. $LOAD_PATH.unshift(".") recreates security issue, and pollutes

Right way to deal with the 1.9.2 removal of . from the loadpath:

  1. require_relative "foo/bar" if you don't need Ruby 1.8 compatibility
@NZKoz
NZKoz / aa_instructions.md
Created May 2, 2012 03:07
Back Up All Your Gmail
  • Install getmail (aptitude install getmail4)
  • Set Up Your Imap Server (tl;dr)
  • getmail
  • ruby date_based_archive.rb ~/Maildir/.Archive
@sbishep
sbishep / gist:09509566cee1f5bb4115
Created February 27, 2015 17:31
Callbacks in pure ruby
module CallbackPureRuby
def self.included(klass)
klass.extend ClassMethods
klass.initialize_included_features
end
module ClassMethods
def initialize_included_features
@callbacks = Hash[:before, {}, :after, {}]
@rikukissa
rikukissa / .gitignore
Last active December 17, 2015 17:18
Darker theme for Shout. Has a bit more eye-friendly color scheme and hides some IMO unnecessary features such as "Leave" and "Submit" buttons.
.DS_Store
@nitschmann
nitschmann / easter_day.rb
Last active March 15, 2016 13:45
Ruby implementation to find out the easter day date for a specific year (based on Anonymous Gregorian algorithm)
require "date"
# anonymous gregorian algorithm (http://en.wikipedia.org/wiki/Computus#Anonymous_Gregorian_algorithm)
def easter_day(year)
if year.is_a?(Integer)
y = year
# calculation
a = y % 19
b = y / 100
c = y % 100
@rtomayko
rtomayko / Tests Is Wrong
Created January 28, 2009 20:50
Why "require 'rubygems'" In Your Library/App/Tests Is Wrong
In response to all the responses to:
http://twitter.com/rtomayko/status/1155906157
You should never do this in a source file included with your library,
app, or tests:
require 'rubygems'
The system I use to manage my $LOAD_PATH is not your library/app/tests
@canton7
canton7 / Sample DataMapper model.rb
Last active September 10, 2018 03:16
Sinatra Auth in a Box
# From bcrypt-ruby gem
require 'bcrypt'
class User
include DataMapper::Resource
attr_accessor :password, :password_confirmation
property :id, Serial
property :username, String, :required => true, :length => (2..32), :unique => true
property :password_hash, String, :length => 60