Skip to content

Instantly share code, notes, and snippets.

View michaeldv's full-sized avatar

Michael Dvorkin michaeldv

  • Cupertino, California
View GitHub Profile
# @settings and anything in it could be nil or blank at any time
def get_backlog_issues(exclude_ids=[])
return [[]] unless @settings.present? &&
@settings['panes'].present? &&
@settings['panes']['backlog'].present? &&
@settings['panes']['backlog']['status'].present? &&
@settings['panes']['backlog']['limit'].present?
# ...
t = Thread.start do
l = '/ - \ |'.split
print "\e[?25l"
loop do
c = l.shift
print "\r#{c}"
STDOUT.flush
sleep 0.1
l.push c
end
# Everything you need to do to get started with Rails 2.3.8
#
# As of June 14th, 2010 @ 2:30 p.m. MST
#
# This gist now features instructions to get Rails 3 up and running with:
# - Ruby 1.8.7-p174
# - Bundler 0.9.26
# - Cucumber 0.8.0
# - Rspec 1.3.0 + Rspec-Rails 1.3.2
# - RVM
function git_deleted {
[[ $(git status 2> /dev/null | grep deleted:) != "" ]] && echo "-"
}
function git_added {
[[ $(git status 2> /dev/null | grep "Untracked files:") != "" ]] && echo '+'
}
function git_modified {
[[ $(git status 2> /dev/null | grep modified:) != "" ]] && echo "*"
function detect_rvm {
local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}')
[ "$gemset" != "" ] && gemset="@$gemset"
local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}')
[ "$version" != "" ] && version="$version"
local full="$version$gemset"
[ "$full" != "" ] && echo "$full"
}
function git_deleted {
require "rubygems"
require "ap"
unless IRB.version.include?('DietRB')
IRB::Irb.class_eval do
def output_value
ap @context.last_value
end
end
else # MacRuby
@michaeldv
michaeldv / regression
Created November 30, 2010 00:10
Regression between Rails 3.0.3 and 3.0.0
### 1) Added $stderr tracing in gems/activesupport-3.0.3/lib/active_support/xml_mini.rb
###
FORMATTING = {
"symbol" => Proc.new { |symbol| symbol.to_s },
"date" => Proc.new { |date| date.to_s(:db) },
"datetime" => Proc.new { |time| $stderr.puts "3.0.3: time.xmlschema for <#{time.class.inspect}>"; time.xmlschema },
"binary" => Proc.new { |binary| ActiveSupport::Base64.encode64(binary) },
"yaml" => Proc.new { |yaml| yaml.to_yaml }
} unless defined?(FORMATTING)
@michaeldv
michaeldv / xml.rb
Created December 1, 2010 03:36
activerecord/test/cases/xml_serialization_test.rb
module ActiveModel
# == Active Model XML Serializer
module Serializers
module Xml
extend ActiveSupport::Concern
include ActiveModel::Serialization
class Serializer #:nodoc:
class Attribute #:nodoc:
attr_reader :name, :value, :type