Skip to content

Instantly share code, notes, and snippets.

View jsmecham's full-sized avatar
💣
Breaking Things…

Justin Mecham jsmecham

💣
Breaking Things…
View GitHub Profile
@jsmecham
jsmecham / Prototype - Date#strftime
Created February 24, 2010 18:09
Date#strftime for Prototype
Date.monthNames = [
'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December'
];
Date.dayNames = [
'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday',
'Saturday'
];
@jsmecham
jsmecham / gist:611907
Created October 5, 2010 17:01
Dir.clone! for Ruby
class Dir
def self.clone!(source, destination, exclude)
exclude = ["^\\.{1,2}$"].concat(exclude).uniq
FileUtils.mkdir destination unless Dir.exists? destination
Dir.foreach(source) do |file|
next if exclude.detect { |pattern| file.match(/#{pattern}/i) }
@jsmecham
jsmecham / Date.js
Created April 14, 2011 01:32
JavaScript Date Formatter
/**
* Date#strftime(format) -> String
*
* - format (String): the format string
*
* Formats the *date* according to the directives given in the *format*
* string. Requires a String#interpolate() extension.
*
* ## Format Components
*
@jsmecham
jsmecham / jquery.points.js
Created September 8, 2011 20:15
A jQuery extension for determining the center point of an element as well as to calculate whether a given point is within an element's bounds
(function($) {
$.fn.centerPoint = function()
{
return {
x: this.position().left + (this.outerWidth(true) / 2),
y: this.position().top + (this.outerHeight(true) / 2)
}
};
@jsmecham
jsmecham / underscore.extensions.js
Created October 17, 2011 15:20
Useful Underscore.js Extensions
(function() {
//
// Iterates over an array of numbers and returns the sum. Example:
//
// _.sum([1, 2, 3]) => 6
//
_.sum = function(obj) {
if (!$.isArray(obj) || obj.length == 0) return 0;
return _.reduce(obj, function(sum, n) {

Useful Regular Expressions

Received Message Headers

/(^Received:.*?\n)(?=[a-zA-Z-]+:|\n)/im

@jsmecham
jsmecham / .zshrc
Last active October 28, 2017 17:11
#
# Justin's ZSH Configuration
#
# Oh My ZSH Configuration ====================================================
# Path to Oh My ZSH ----------------------------------------------------------
ZSH=$HOME/.oh-my-zsh
@jsmecham
jsmecham / .gemrc
Last active December 25, 2015 15:49
install: --user-install --no-document
update: --user-install --no-document
#
# Justin's IRB Configuration
#
# Support User Gems in Bundler-Managed Applications --------------------------
#
# if defined? ::Bundler
# user_gem_paths = Dir.glob("#{Gem.user_dir}/gems/*")
# user_gem_paths.each do |path|
# gem_path = "#{path}/lib"
#
# Justin's "Staple" ZSH Theme
#
# For use with Oh-My-Zsh. Place in ~/.oh-my-zsh/custom.
#
autoload -U add-zsh-hook
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}[%{$fg_no_bold[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX=""