Skip to content

Instantly share code, notes, and snippets.

🇨🇦
Hackety hack

Chris Cummer senorprogrammer

🇨🇦
Hackety hack
Block or report user

Report or block senorprogrammer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:97273
# ---------- Custom Git-based 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\]"
View CSS Transparency
.transparent_class {
filter:alpha(opacity=50);
-moz-opacity:0.5;
-khtml-opacity: 0.5;
opacity: 0.5;
}
View gist:437306
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),
View RFC822
#
# 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
View gist:498535
#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;
View gist:557761
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.
@senorprogrammer
senorprogrammer / str_2_hex.rb
Created Apr 3, 2011
Converts strings to hex codes in Ruby
View str_2_hex.rb
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
View range_intersection.rb
#!/usr/bin/env ruby
# From my blog post at http://www.postal-code.com/binarycode/2009/06/06/better-range-intersection-in-ruby/
class Range
def intersection(other)
raise ArgumentError, 'value must be a Range' unless other.kind_of?(Range)
my_min, my_max = first, exclude_end? ? max : last
other_min, other_max = other.first, other.exclude_end? ? other.max : other.last
@senorprogrammer
senorprogrammer / git-cmd-prompt
Created Aug 8, 2011
Git-based command prompt
View git-cmd-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 / rake_strip_whitespace
Created Aug 30, 2011
Rake task to strip whitespace
View rake_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' ]
You can’t perform that action at this time.