Skip to content

Instantly share code, notes, and snippets.

View michaeldv's full-sized avatar

Michael Dvorkin michaeldv

  • Cupertino, California
View GitHub Profile
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
@michaeldv
michaeldv / gist:188101
Created September 16, 2009 15:24 — forked from pccl/gist:187933
# Tasks can fall through the gaps when matching on '='
# e.g. for a task where due_at = 2009-09-16 23:00:00, and where Time.now = 2009-09-16,
# it would not match due_today or due_tomorrow, hence would not appear in Fat Free.
named_scope :due_today, lambda { { :conditions => [ "due_at = ?", Time.zone.now.midnight.utc ], :order => "id DESC" } }
named_scope :due_tomorrow, lambda { { :conditions => [ "due_at = ?", Time.zone.now.midnight.tomorrow.utc ], :order => "id DESC" } }
# By specifying a range of dates, tasks would always match with one of the bucket dates.
named_scope :due_today, lambda {
{ :conditions => [ "due_at >= ? AND due_at < ?", Time.zone.now.midnight.utc, Time.zone.now.midnight.tomorrow.utc ], :order => "id DESC" }
}
1. Create a text backup of your data form the live server. This will ask for a password.
mysqldump -u your_user -p your_redmine_database > backup_sql_file.sql
2. Transfer the backup_sql_file.sql to your new server.
3. Once there, drop the existing database on the new server and import your database to the empty database on the new server.
!!!! Triple check this is on the new server and not your live one!!!!
@michaeldv
michaeldv / gist:180578
Created September 3, 2009 22:24 — forked from mtodd/gist:180398
Surround a heredoc with quotes and you can continue the code on the same line:
render :status => 404, :text => <<-'EOH' and return unless setup
article not found<br/>
I, as a server, have failed<br/>
https?
EOH
Quotes also give you more freedom/creativity with the terminal ID: