Skip to content

Instantly share code, notes, and snippets.

View test
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.
@joemaller
joemaller / wp-config-db-sample.php
Created Jul 6, 2012
Git-safe WordPress config
View wp-config-db-sample.php
<?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 Sep 13, 2012
shell one-liner to rename @2x files so they work with compass sprites
View gist:3715084
ruby -e 'Dir.glob("*@2x.*").each { |f| %x[ git mv #{f} #{f.gsub("@", "_")} ] }'
@joemaller
joemaller / gist:3940259
Created Oct 23, 2012
MediaElement.js: Enable smoothing in Flash fallback
View gist:3940259
// 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
View Evolution of a Python programmer.py
#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 Mar 9, 2018
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…
View PS1 Color Functions for Shell Prompts.sh
# 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 Dec 25, 2015
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
View Bash color Git branch.sh
# 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 Jan 14, 2013
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.
View rbenv_bootstrap.sh
#!/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 Jan 22, 2013
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…
View array_sortByKey.php
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;
}