Skip to content

Instantly share code, notes, and snippets.

joeybaker / clickable.js
Created Apr 9, 2012
jQuery for a clickable element
View clickable.js
/* Clickable elements
// when any .clickable elem is clicked, we'll grab the first link in the elem and redirect to it.
$('body').on('click', '.clickable', function(e){
var link = $('a:first', this)
, href = link.attr('href')
// _blank, command key, ctrl key, middle click
if (link.attr('target') == '_blank' || e.metaKey || e.ctrlKey || e.which == 2), '_blank')
alias tolf="find . -type f -not -iname '*.png' -not -iname '*.jpg' -not -iname '*.jpeg' -not -iname '*.gif' -not -iname '*.tif' -not -iname '*.tiff' -not -iname '.git' -exec perl -pi -e 's/\r\n?/\n/g' {} \;"
joeybaker / strtotitle
Created May 2, 2012
strtotitle – php to title case a string
View strtotitle
# converts a string to title case
# input: string
# output: string in title case
function strtotitle($title) {
$blacklist = array( 'of','a','the','and','an','or','nor','but','is','then','else', 'at','from','by','on','off','for','in','out','over','to','into','with' );
$words = explode(' ', $title);
foreach ($words as $key => $word) {
if ($key == 0 || !in_array($word, $blacklist))
$words[$key] = ucfirst($word);
joeybaker /
Created May 10, 2012
Turn a dir into a git repo
# add this to your .bash_profile
# usage: gitinstall
function gitinstall(){ git init; git remote add origin "$@"; git config branch.master.remote origin; git config branch.master.merge refs/heads/master; git pull;}
joeybaker /
Created May 10, 2012
setup a new django project using virtual environments
# To setup a new django project
virtualenv PROJECTNAME --no-site-packages
source PROJECTNAME/bin/activate
pip install django startproject PROJECTNAME
python PROJECTNAME/ runserver
joeybaker /
Created May 10, 2012
Batch Convert CLRF to LF
find . -type f -not -iname '*.png' -not -iname '*.jpg' -not -iname '*.jpeg' -not -iname '*.gif' -not -iname '*.tif' -not -iname '*.tiff' -not -iname '.git' -exec perl -pi -e 's/\r\n?/\n/g' {} \;
joeybaker /
Created May 10, 2012
Batch rename in bash example
ls mx50_* | awk '{print("mv "$1" "$1)}' | sed s/mx50_*/buckminster_/2 | /bin/sh
joeybaker / gist:2654948
Created May 10, 2012
Heatmap based on mouse movement
View gist:2654948
Copyright (c) 2010, Patrick Wied. All rights reserved.
Code licensed under the BSD License:
var heatmapApp = (function(){
// var definition
// canvas: the canvas element
// ctx: the canvas 2d context
// width: the heatmap width for border calculations
View gist:2654956
<!doctype html>
<title>Image-free spinner</title>
@-webkit-keyframes fadeOut {
0% { opacity:1; }
100% { opacity:.1; }}
p {
joeybaker / .htaccess
Created May 10, 2012
Security for WordPress
View .htaccess
<files wp-config.php>
order allow,deny
deny from all
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]