-
Use a version control system that allows you to deploy exactly what you want to, not "everything up to and including a particular checkin", e.g., use Git, not Perforce.
-
Have a centralized admin user account on servers, but also have individual user accounts and make people log in using their individual and then sudo. This strategy provides a better audit trail than logging in directly to the cetnral admin account.
-
Don't build a job queue system from scratch using cron. There are so many better-behaved job queue systems in various languages.
- Cron can't schedule more than some maximum number of jobs in a single minute, so it may miss running some jobs.
- Cron can't re-run missed jobs, so you have to come up with a way yourself of identifying any missed jobs (either because of the above issue or because cron or the system was down) and running them.
-
Databases sometimes need to be versioned in ways besides ActiveRecord-type migrations. For example, if two code branches differ in the columns th
This file contains hidden or 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
import java.lang.reflect.Method ; | |
String className = "java.lang.Class" ; // or whatever class you're interested in | |
Class c = Class.forName( className ) ; | |
Method[] methods = c.getDeclaredMethods() ; | |
for ( Method m : methods ) | |
{ |
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'rexml/document' | |
def set_up_Growl | |
if `ps -ax | grep GrowlHelperApp\.app | grep -v grep` == '' then | |
system( 'open /Library/PreferencePanes/Growl.prefPane/Contents/Resources/GrowlHelperApp.app' ) | |
end | |
end |
This file contains hidden or 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
now = Time.now.to_a | |
if ( now[2] * 60 + now[1] ) * 60 + now[0] > START_TIME_IN_SECONDS then | |
# start whatever you wanted to start at this time | |
end |
This file contains hidden or 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
# Based on http://stackoverflow.com/questions/2339021/how-can-i-load-some-activerecord-models-from-a-yaml-file-and-save-them-to-the-db/ | |
seed_filepath = File.join( RAILS_ROOT, 'db', 'seeds.yaml' ) | |
config = YAML::load_file( seed_filepath ) | |
config.each { |pluralized_model_name, fixtures| | |
model_class = pluralized_model_name.singularize.constantize | |
# If you like leaping without looking: | |
# model_class.create( fixtures ) |
This file contains hidden or 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
module PerfectBitsMath | |
def number_of_squares_in_interval( m, n ) | |
1 | |
end | |
end | |
module Math | |
extend PerfectBitsMath | |
end |
This file contains hidden or 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
#!/usr/bin/env ruby | |
arguments = [] | |
ARGV.each { |arg| | |
arguments << File.expand_path( arg ) | |
} | |
system( "java -cp /Applications/jEdit.app/Contents/Resources/Java/jedit.jar:/System/Library/Java -Dapple.awt.textantialiasing=true -Dapple.laf.useScreenMenuBar=true -Dapple.awt.antialiasing=true org.gjt.sp.jedit.jEdit -background #{arguments.join( ' ' )} &" ) |
This file contains hidden or 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
# Tested under: | |
# $ ruby -v | |
# ruby 1.8.7 (2010-04-19 patchlevel 253) [i686-darwin10.4.0], MBARI 0x6770, Ruby Enterprise Edition 2010.02 | |
class C | |
def f | |
raise NotImplementedError | |
end | |
end |
This file contains hidden or 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 | |
~/bin/toggle_Require_password_on_wake.app/Contents/MacOS/applet |
This file contains hidden or 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
tell application "System Preferences" | |
activate | |
set current pane to pane id "com.apple.preference.security" | |
tell application "System Events" | |
tell process "System Preferences" | |
-- UNLOCK CHECKS | |
if (exists checkbox "Click the lock to make changes." of window 1) is true then | |
click checkbox "Click the lock to make changes." of window 1 |