Skip to content

Instantly share code, notes, and snippets.

View michaeldv's full-sized avatar

Michael Dvorkin michaeldv

  • Cupertino, California
View GitHub Profile
@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:
#!/bin/sh
## install imagemagick on snow leopard: by kain, improved by mislav
## http://www.icoretech.org/2009/08/install-imagemagick-in-leopard-snow-leopard/
# working on 64bit kernel mode
set -e
PREFIX=/usr/local
wget http://sourceforge.net/projects/freetype/files/freetype2/2.3.9/freetype-2.3.9.tar.gz/download -O- | tar xz
# $ tweet Hi mom!
#
# Put this in ~/.bashrc or wherever.
# If it doesn't work, make sure your ~/.netrc is right
#
# (Thanks to @anildigital for curl-fu)
function tweet {
curl -n -d status="$*" http://twitter.com/statuses/update.xml &> /dev/null
echo "tweet'd"
@michaeldv
michaeldv / FIRST
Created May 27, 2009 04:10 — forked from nakajima/FIRST
Here's an example of a few different ways to call a method on a Ruby object.
If you're a beginner, try running the code above to watch it in action.
If you're not a beginner, go ahead and tear me a new one for whichever techniques I forgot ;)
- Pat
# force rails const_missing to preload these classes
#
ActionController
ActionController::Base
ActiveRecord
ActiveRecord::Base
ActionView
ActionView::Base
ActionView::Template
ActionView::Helpers