Skip to content

Instantly share code, notes, and snippets.

View jmazzi's full-sized avatar

Justin Mazzi jmazzi

View GitHub Profile
@jmazzi
jmazzi / .bashrc
Created January 30, 2009 14:02 — forked from henrik/.bashrc
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
@jmazzi
jmazzi / .bashrc
Created February 1, 2009 00:40 — forked from henrik/.bashrc
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
@jmazzi
jmazzi / codes.rb
Created February 4, 2009 16:45 — forked from jamis/codes.rb
# Generates a series of substitution cipher puzzles. The messages to
# "encrypt" are take from a text file passed on the command-line,
# where each message is on one line.
#
# The output is a PDF, "codes.pdf".
#
# This was written for my 7 year-old, who loves doing substitution
# ciphers.
require 'prawn'
# Original, did not work in production
map.connect 'referrals/logout', :controller => 'referrals/login', :action => 'logout'
map.connect 'referrals/:action/:id', :controller => 'referrals/home'
#
# rails template for skeleton app, haml, sass, shoulda, factory_girl, jquery
#
# TO-DO: Change the location of edge rails or equiv to match env.
#
# Link to local copy of edge rails
inside('vendor') { run 'ln -s ~/code/rails-edge rails' }
# Delete unnecessary files
run "rm README"
class Foo < ActiveRecord::Base
# attrs: bar (integer), baz (integer)
# want to make sure Foo.baz is > than Foo.bar
# this would only run validation when baz is numeric (because any int is > nil)
validates_each :bar do |record, attr, value|
if record.baz.is_a?(Numeric)
if value.is_a?(Numeric)
record.errors.add attr, 'must be less than baz.' unless value < record.baz
end
The form/controller works fine in development, and doesn't in production. It DID work fine in production earlier this week, but now it doesn't, and I didn't make any changes to the code. Any ideas, please send to [email protected].
Controller
class JobseekerprofilesController < ApplicationController
include ActsAsTinyURL
before_filter :login_required, :except => [:show]
caches_page :show
<?php
declare(ticks = 1);
class HRServerMon_Poller
{
var $hostname;
function HRServerMon_Poller($hostname)
{
#
# bash completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
@jmazzi
jmazzi / .bashrc
Created July 8, 2009 18:52 — forked from defunkt/.bashrc
# $ 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"