This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Dumps all databases to separate backup files named with today's date | |
BACKUP_TO="$HOME/backup/db" | |
MYSQLDUMP_OPTIONS="--compact --add-drop-table --skip-set-charset" | |
# --- | |
mkdir -p $BACKUP_TO | |
DATE=`date +'%Y-%m-%d'` | |
mysql -e 'show databases' | ruby -e " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Report how much memory is being used right now | |
# and call it from different places to debug: | |
def report_memory(note) | |
memory_usage = `ps -o rss= -p #{$$}`.to_i | |
mem_mb = sprintf('%.2f MB', memory_usage/1000.0) | |
puts "mem [#{note}]: #{mem_mb}" | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// script by Josh Fraser (http://www.onlineaspect.com) | |
// modded by Jeremy Seitz to only return offset as integer | |
function calculate_time_zone() { | |
var rightNow = new Date(); | |
var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0); // jan 1st | |
var june1 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0); // june 1st | |
var temp = jan1.toGMTString(); | |
var jan2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1)); | |
temp = june1.toGMTString(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Admin::BaseController < ApplicationController | |
before_filter :authenticate | |
# ... | |
private | |
def authenticate | |
return true if Rails.env.development? | |
authenticate_or_request_with_http_basic do |id, password| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<!-- example at http://somebox.com/canvas-fun.html --> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> | |
<script src="http://ajax.cdnjs.com/ajax/libs/ocanvas/1.0/ocanvas.min.js"></script> | |
<title>Canvas Experiment</title> | |
<script type="text/javascript"> | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Backbone.Rails.js | |
// | |
// Makes Backbone.js play nicely with the default Rails setup, i.e., | |
// no need to set | |
// ActiveRecord::Base.include_root_in_json = false | |
// and build all of your models directly from `params` rather than | |
// `params[:model]`. | |
// | |
// Load this file after backbone.js and before your application JS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The Democracy Now! music site will allow independent artists to submit original works for sharing with | |
other DN listeners, and potentially to be used as music on the show. | |
This is to be a standalone site, built in Rails 3. Users can fill out a form and upload a track. | |
After processing, they will receive and email containing a confirmation that the track was received, | |
and a link to the track on DN's site. By using this link, they can go to check for airplay, or | |
to request that a track be removed. | |
Home Page | |
Notices/Info/Events |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'builder' | |
require 'digest/md5' | |
class Content < ActiveRecord::Base | |
belongs_to :user | |
end | |
class Section < ActiveRecord::Base | |
has_many :assigned_sections | |
has_many :articles, :order => 'position', :through => :assigned_sections |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A More Awesome PS1 | |
# - only show username if its not the usual one | |
# - only show hostname if its not my local box (checks SSH_CONNECTION) | |
# - show root username in red | |
# - show current path, and smart truncate longer ones (>35 chars) | |
# - show git branch in brackets | |
# - show a red star for uncommitted git changes | |
# - show local hostname in green (192.*,10.*,::1) | |
# - show other hostnames in white |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
APP_ROOT = File.expand_path(File.dirname(File.dirname(__FILE__))) | |
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm') | |
begin | |
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME'])) | |
rvm_lib_path = File.join(rvm_path, 'lib') | |
$LOAD_PATH.unshift rvm_lib_path | |
require 'rvm' | |
RVM.use_from_path! APP_ROOT | |
rescue LoadError |