Skip to content

Instantly share code, notes, and snippets.

@imajes
imajes / Gemfile
Created February 1, 2012 18:18
make ruby debug work in 1.9.3 with bundler
gem 'ruby-debug19', '0.11.6', :require => 'ruby-debug'
# FIXME: forcing rdebug to work on 1.9.3
gem 'linecache19', '0.5.13'
gem 'ruby-debug-base19', '0.11.26'
@j-manu
j-manu / gist:1559754
Created January 4, 2012 12:01 — forked from dx7/gist:1333785
Installing ruby-debug with ruby-1.9.3-p125
# Install with:
# bash < <(curl -L https://raw.github.com/gist/1559754)
#
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
echo "Installing ruby-debug with ruby-1.9.3-p125 ..."
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
def output name=((default=true); "caius")
puts "name: #{name.inspect}"
puts "default: #{default.inspect}"
end
output
# >> name: "caius"
# >> default: true
output "avdi"
@fxn
fxn / gist:1521270
Created December 26, 2011 14:31
Count number of divisors with a regexp
See https://github.com/fxn/math-with-regexps.
@diafygi
diafygi / slow_query_log_dump.py
Created December 16, 2011 04:38 — forked from memonic/cronjob.sh
Script to transform Amazon RDS slow log table into the MySQL slow query log format
"""
Queries the slowlog database table maintained by Amazon RDS and outputs it in
the normal MySQL slow log text format. Modified version of the script by
memonic (Thanks!) at https://gist.github.com/1481025
Things to change in this script for your own setup:
<root_user> to your mysql root user (e.g. "root")
<root_pass> to your mysql root password (e.g. "hunter2")
<host_domain> to your mysql root password (e.g. "prod-01.w3rfs2.us-east-1.rds.amazonaws.com")
@avdi
avdi / when.rb
Created December 5, 2011 22:17
Experimenting with Object#when in Ruby
def maybe_a_sandwich
nil
end
# Methods that might return nil are annoying. We want to write a nice
# confident chain:
result = nil
result = maybe_a_sandwich.add_horseradish.get_into_my_belly! rescue $!
result # => #<NoMethodError: undefined method `add_horseradish' for nil:NilClass>
@roidrage
roidrage / ebooks.md
Created December 2, 2011 15:15
Self-published and awesome
@cpatni
cpatni / app.rb
Created November 21, 2011 22:39
unique calculation using redis
require 'sinatra'
require 'redis'
require 'json'
require 'date'
class String
def &(str)
result = ''
result.force_encoding("BINARY")
require 'rubygems'
require 'sequel'
require 'fileutils'
require 'yaml'
# NOTE: This converter requires Sequel and the MySQL gems.
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
# installed, running the following commands should work:
# $ sudo gem install sequel
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
#!/usr/bin/env ruby
# Used to convert Rails CHANGELOGs to Markdown format.
# Usage: convert_changelog_to_markdown.rb CHANGELOG > CHANGELOG.md
text = File.read(ARGV[0])
processed = ''
def fixup_line(line)