Skip to content

Instantly share code, notes, and snippets.

View michaeldv's full-sized avatar

Michael Dvorkin michaeldv

  • Cupertino, California
View GitHub Profile
class Controller
attr_reader :tag
def initialize
@tag = "Controller"
@window = Window.new(self)
@window.show
hello
hello_again
end
#!/usr/bin/env ruby
# Usage:
# $ ./script/railssh
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require APP_PATH
Rails.application.require_environment!
module Kernel
# 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
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
# @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?
# ...
@michaeldv
michaeldv / snippet.rb
Created February 17, 2010 07:44 — forked from auser/snippet.rb
def mode(arr=[])
hsh = arr.inject(Hash.new(1)) { |hash, item| hash[item] += 1; hash }
max = hsh.values.max
hsh.inject([]) { |arr, item| arr << item[0] if item[1] >= max; arr}
end
p mode %w(a b a a b c dd e e e) # ["e", "a"]
p mode %w(a b a a b c dd e e) # ["a"]
p mode %w(snowboarding is more than fun. super fun.) # ["fun."]
class GitProductive
attr_accessor :directory, :lines, :commits
def initialize(directory = Dir.pwd)
raise "#{directory} is not a git repository" unless Dir.entries(directory).include?(".git")
@directory = directory
@lines, @commits = 0, 0
end
def check!(duration = "1 days")
#! /usr/bin/env ruby
Main {
Home = File.expand_path(ENV["HOME"] || ENV["USERPROFILE"] || "~")
Basedir = File.join(Home, "mp3")
Threads = 8
description <<-txt
mp3scrape will scour any url for it's mp3 content - the script mirrors,
never downloading the same file twice. it does not, however, crawl a