Skip to content

Instantly share code, notes, and snippets.

@baweaver
baweaver / ruby_galaxy_poker_pattern_matching.rb
Created January 28, 2021 19:53
Variant of pattern matching example from RubyGalaxy talk
class Card
SUITS = %w(S H D C).freeze
RANKS = %w(2 3 4 5 6 7 8 9 10 J Q K A).freeze
RANKS_SCORES = RANKS.each_with_index.to_h
include Comparable
attr_reader :suit, :rank
def initialize(suit, rank)
@khernyo
khernyo / build.gradle
Created December 6, 2012 18:39
Gradle Android configuration with .so hack
// This hack works with com.android.tools.build:gradle:0.2, won't work in later version without modification
apply plugin: 'android'
targetCompatibility = 1.6
sourceCompatibility = 1.6
android {
target = 'android-14'
@drogus
drogus / Gemfile
Created April 23, 2012 18:34
Webmachine + ActionView pt2
source "http://rubygems.org"
gem "webmachine"
gem "actionpack"
gem "thin"
gem "datamapper"
gem "dm-migrations"
gem "dm-sqlite-adapter"
gem "debugger"
@asavartsov
asavartsov / Gemfile
Created February 17, 2012 16:49
Mongoid 3.0, Paperclip, embedded, accepts_nested_attributes_for and allow_destroy with optional description
gem 'rails', '3.2.1'
gem 'mongoid', :git => 'git://github.com/mongoid/mongoid.git'
gem 'mongoid-paperclip', :require => "mongoid_paperclip"
# if you're using rspec (should be temporary until mongoid-rspec will be updated to mongoid 3.0)
# group :test do
# gem "mongoid-rspec", :git => 'https://github.com/tanordheim/mongoid-rspec.git', :branch => 'mongoid_3_0'
# end
@v1nc3ntlaw
v1nc3ntlaw / rbenv-install-system-wide.sh
Last active July 26, 2022 01:08
rbenv install ruby 1.9.3-p448 on Debian 6 Squeeze
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential git-core curl libssl-dev \
libreadline5 libreadline5-dev \
zlib1g zlib1g-dev \
libmysqlclient-dev \
libcurl4-openssl-dev \
libxslt-dev libxml2-dev
@vpereira
vpereira / em_pipe_reader.rb
Created August 12, 2011 12:13
Eventmachine based named pipe reader
require 'fcntl'
require 'eventmachine'
#what is needed
#mkfifo mypipe
#that everything written thru the pipe have a "\n"
#ex: echo "foobar\n" > mypipe
#HPO = Handle Pipe Output
module HPO
@kaiwren
kaiwren / net_http_debug.rb
Created September 22, 2010 12:48
Enable debug for all Ruby HTTP requests
require 'net/http'
module Net
class HTTP
def self.enable_debug!
raise "You don't want to do this in anything but development mode!" unless Rails.env == 'development'
class << self
alias_method :__new__, :new
def new(*args, &blk)
instance = __new__(*args, &blk)
instance.set_debug_output($stderr)