Skip to content

Instantly share code, notes, and snippets.

View jschoolcraft's full-sized avatar

Jeff Schoolcraft jschoolcraft

View GitHub Profile
@jschoolcraft
jschoolcraft / backup.rb
Created May 5, 2011 15:06
bit of my astrails-safe file, showing mysql command line batch execution
mysqldump do
options "-ceKq --single-transaction --create-options"
username = "some"
pass = "thing"
user username
password pass
socket "/var/run/mysqld/mysqld.sock"
@jschoolcraft
jschoolcraft / Guardfile
Created May 4, 2011 14:16 — forked from fnichol/Guardfile
One of my current Guardfiles
# More info at https://github.com/guard/guard#readme
guard 'ego' do
watch('Guardfile')
end
guard 'spork' do
watch('config/application.rb')
watch('config/environment.rb')
watch(%r{^config/environments/.*\.rb$})
@jschoolcraft
jschoolcraft / postgres.rake
Created April 7, 2011 23:59
Stole this from someone else, but updated to work with Rails 3
namespace :db do
desc "Reset all sequences. Run after data imports"
task :reset_sequences, :model_class, :needs => :environment do |t, args|
if args[:model_class]
classes = Array(eval args[:model_class])
else
puts "using all defined active_record models"
classes = []
Dir.glob(RAILS_ROOT + '/app/models/**/*.rb').each { |file| require file }
ActiveRecord::Base.subclasses.select { |c|c.base_class == c}.sort_by(&:name).each do |klass|
@jschoolcraft
jschoolcraft / delayed_job.bluepill
Created April 7, 2011 16:38 — forked from vertis/delayed_job.bluepill
bluepill monitoring multiple delayed_job workers
app_home = "/home/mi/production"
workers = 5
Bluepill.application("mi_delayed_job", :log_file => "#{app_home}/shared/log/bluepill.log") do |app|
(0...workers).each do |i|
app.process("delayed_job.#{i}") do |process|
process.working_dir = "#{app_home}/current"
process.start_grace_time = 10.seconds
process.stop_grace_time = 10.seconds
process.restart_grace_time = 10.seconds
## config/boot.rb
# Place this snippet right above the "Rails.boot!" command at the bottom of the file.
class Rails::Boot
def run
load_initializer
extend_environment
Rails::Initializer.run(:set_load_path)
end
def extend_environment
function log(object) {
Ti.API.debug(object);
if(logger) {
logger.log(object);
};
};
var indWin = null;
var actInd = null;
// RATER MODULE for Appcelerator Titanium
/*
WHAT IS IT:
Create a cycling reminder to go rate your app at the App Store. Tracks
the app launch count, and reminds the user every 20 launches (configurable) to
rate the app, with a click to launch the app page in the App Store.
Reminders stop if the user clicks the "Rate Now" or "Don't Remind Me" options.
USAGE:
@jschoolcraft
jschoolcraft / task.js
Created March 23, 2011 18:42 — forked from sr3d/task.js
(function() {
App.Models.Task = App.Models.Base.createModel('Task', 'tasks', {
name: 'TEXT',
note: 'TEXT',
due_at: 'DATE',
is_completed: 'TEXT',
completed_at: 'TEXT',
category_id: 'TEXT',
event_id: 'INTEGER',
has_reminders: 'TEXT',
Robot-C is supported. Just FYI
Has something called Task Control, up to 4 concurrent tasks, with priority...
could do something like:
StartTask(RaiseBasket, 10)
StartTask(MoveToWallGoal, 10)
To move to the goal and make sure the basket is Raised
RaiseBasket
# Prompt Setup
function minutes_since_last_commit {
now=`date +%s`
last_commit=`git log --pretty=format:'%at' -1`
seconds_since_last_commit=$((now-last_commit))
minutes_since_last_commit=$((seconds_since_last_commit/60))
echo $minutes_since_last_commit
}