Skip to content

Instantly share code, notes, and snippets.

testing, can these be downloaded? deleted? Edited, yes. Does anyone else see the download link?
OK, I see the delete link at the bottom. So yes, they can be deleted.
*.pbxproj -crlf -diff -merge
@joemaller
joemaller / wp-config-db-sample.php
Created July 6, 2012 15:40
Git-safe WordPress config
<?php
/**
* Make a copy of this file named wp-config-db.php
* wp-config-db SHOULD NOT be version controled, add it to gitignore
* Use this to store database access information so the main
* wp-config.php file can be modified and version controlled.
*/
/**
* Debug block, set WP_DEBUG to false to disable this on the live site
@joemaller
joemaller / gist:3715084
Created September 13, 2012 15:27
shell one-liner to rename @2x files so they work with compass sprites
ruby -e 'Dir.glob("*@2x.*").each { |f| %x[ git mv #{f} #{f.gsub("@", "_")} ] }'
@joemaller
joemaller / gist:3940259
Created October 23, 2012 17:37
MediaElement.js: Enable smoothing in Flash fallback
// Add to the options object when initializing MediaElement.js players for high-quality scaling
// found in source file mediaelement-and-player.js:1192, adds "smoothing=true" to flashvars
enablePluginSmoothing: true
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@joemaller
joemaller / PS1 Color Functions for Shell Prompts.sh
Last active March 9, 2018 21:33
A set of simple color functions to help customize the shell's $PS1 prompt. These wrap the nasty color and background escape codes into more humane functions. Due to shell string escaping oddness, these must be used with `PROMPT_COMMAND` instead of directly in PS1. A complete git-aware .bashrc prompt is here: https://gist.github.com/joemaller/f7d…
# https://gist.github.com/joemaller/4503986
#
# A set of color functions to help with fancy $PS1 prompts
#
# This:
# PROMPT_COMMAND='PS1="\e[32;1m\]\u@\[\e[35;1m\]\H \[\e[0m\]\w]\$ "''
#
# Can be more clearly written as:
# PROMPT_COMMAND='PS1="$(DARK_GREEN \\u@)$(PURPLE \\H) \w]\$ "''
#
@joemaller
joemaller / Bash color Git branch.sh
Last active December 25, 2015 16:12
A bash function for coloring the current git branch. Red for dirty, yellow if all files are staged and clean is green. This uses the color functions from https://gist.github.com/4503986
# https://gist.github.com/joemaller/4527475
#
# A simple bash function for coloring the current git branch.
# - Red: Tree is dirty
# - Yellow: All modified files are staged
# - Green: Tree is clean
#
# This uses the color functions from https://gist.github.com/4503986
function git_branch() {
@joemaller
joemaller / rbenv_bootstrap.sh
Created January 14, 2013 05:01
A little script for boostrapping a basic ruby rbenv environment. The script installs rbenv and ruby-build from Homebrew, activates a new rbenv and then installs the rbenv-rhash and compass gems.
#!/usr/bin/env bash
# This script bootstraps a basic ruby rbenv environment using Homebrew
#
# Should be executed in the current shell by calling from source (or dot):
# $ source ./.rbenv
# $ . ./.rbenv
RUBY_VERSION='1.9.3-p362'
@joemaller
joemaller / array_sortByKey.php
Created January 22, 2013 03:06
This works, but not well enough. Needs better handling of undefined values and arranging things in fixed lengths. For example, if there three items and only one has a sort key, but it's sort key asks to be in the second place, then the item specifying spot two should get spot two and all the undefined items should maintain order around it. Funda…
public function array_sortByKey($arr, $key)
{
$sort_on_key = function ($a, $b) use ($key) {
$a[$key] = (isset($a[$key])) ?: null;
$b[$key] = (isset($b[$key])) ?: null;
return strnatcmp($a[$key], $b[$key]);
};
usort($arr, $sort_on_key);
return $arr;
}