Skip to content

Instantly share code, notes, and snippets.

View senorprogrammer's full-sized avatar
🇨🇦
Hackety hack

Chris Cummer senorprogrammer

🇨🇦
Hackety hack
View GitHub Profile
@senorprogrammer
senorprogrammer / hack.sh
Created March 31, 2012 16:54 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@senorprogrammer
senorprogrammer / reservation_states.txt
Created December 5, 2011 17:13
Reservation states
pending => cancelled
=> confirmed => completed => refunded
=> transaction_pending =>transaction_declined
=> denied
=> expired
=> customer_cancelled_pending
@senorprogrammer
senorprogrammer / rails_precommit.rb
Created November 22, 2011 21:45
Pre-commit hooks for Rails projects
#!/usr/bin/env ruby
# Pre-commit hooks to check the code for errant syntax issues, like logging messages, etc.
# Chris Cummer
# Check to see if I've left any debugging lines in the ruby files
def check_for_ruby_debug( flag )
run_cmd( flag, "grep -rls 'puts \">>' ../../app/**/*.rb", "Debug puts found in:" )
end
@senorprogrammer
senorprogrammer / rake_strip_whitespace
Created August 30, 2011 21:06
Rake task to strip whitespace
require 'extlib/pathname'
require 'zlib'
desc 'Strip whitespace from source files'
task :strip do
# files and extensions to process
FILES = %w[ capfile CHANGELOG LICENSE Manifest MIT-LICENSE README QUICKLINKS README_FOR_APP RUNNING_UNIT_TESTS Rakefile SPECS TODO USAGE .autotest .gitignore .htaccess ].freeze
EXTENSIONS = %w[ builder cgi conf css deploy erb example fcgi feature gemspec haml htc htm html js key markdown opts php rake ratom rb rcsv rdf rhtml rjs rpdf ru rxml sake sass sh sql thor txt vcf xml yml ].freeze
paths = Pathname.glob(Rails.root / '*') - [ Rails.root / 'vendor' ]
@senorprogrammer
senorprogrammer / git-cmd-prompt
Created August 8, 2011 18:50
Git-based command prompt
# Git-based command prompt
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"
@senorprogrammer
senorprogrammer / str_2_hex.rb
Created April 3, 2011 00:07
Converts strings to hex codes in Ruby
class String
def hexcode
hash = 0
self.each_byte do |chr|
hash = chr + (( hash << 5 ) - hash )
end
code = ((hash>>24)&0xFF).to_s(16) + ((hash>>16)&0xFF).to_s(16) + ((hash>>8)&0xFF).to_s(16) + (hash&0xFF).to_s(16)
return code[0..5]
end
end
A CEO does only three things. Sets the overall vision and strategy of the company and communicates it to all stakeholders. Recruits, hires, and retains the very best talent for the company. Makes sure there is always enough cash in the bank.
#import <mach/mach_time.h>
uint64_t start = mach_absolute_time();
// do stuff to be timed
uint64_t end = mach_absolute_time();
uint64_t elapsed = end - start;
mach_timebase_info_data_t info;
#
# RFC822 Email Address Regex
# --------------------------
#
# Originally written by Cal Henderson
# c.f. http://iamcal.com/publish/articles/php/parsing_email/
#
# Translated to Ruby by Tim Fletcher, with changes suggested by Dan Kubb.
#
# Licensed under a Creative Commons Attribution-ShareAlike 2.5 License
h1 {
@include linear-gradient(color-stops(#999, black));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
Or, if you prefer plain CSS:
h1 {
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%,
color-stop(0%, #999999),