Skip to content

Instantly share code, notes, and snippets.

@there4
there4 / Grunt Coffee Task
Created June 15, 2012 22:42 — forked from davidpfahler/Grunt Coffee Task
A grunt task that compiles coffee-script to js
/*
* Grunt Task File
* ---------------
*
* Task: coffee
* Description: Compile coffee files to js
* Dependencies: coffee-script
*
*/
@there4
there4 / exercise.sh
Created June 22, 2012 13:47
hg commit hook for exercise
#!/bin/bash
# Seed random generator
RANDOM=$$$(date +%s)
# Random from 5..15
COUNT=$((RANDOM % 15 + 5))
# Random activity
EXERCISES=(
@there4
there4 / gist:3220241
Created July 31, 2012 20:34 — forked from munhitsu/gist:1034876
python 2.7 install on OSX (10.6.7) using brew (pip, easy_install, virtualenv, virtualenvwrapper)
#NOTE: .pydistutils.cfg seems to be not compatible with brew install python
#areas I needed to clean before installation
#clean up ~/Library/Python
#clean up .local
brew install python --framework
easy_install pip
pip install virtualenv
pip install virtualenvwrapper
mkdir $HOME/.virtualenvs
@there4
there4 / mysql_database_privileges.sql
Created August 5, 2012 17:35
MySQL list of privileges for a database
SELECT
md.host `Host`,
md.user `User`,
md.db `Database`,
REPLACE(RTRIM(CONCAT(
IF(md.Select_priv = 'Y', 'Select ', ''),
IF(md.Insert_priv = 'Y', 'Insert ', ''),
IF(md.Update_priv = 'Y', 'Update ', ''),
IF(md.Delete_priv = 'Y', 'Delete ', ''),
IF(md.Create_priv = 'Y', 'Create ', ''),
@there4
there4 / backbone_sync.js
Created August 16, 2012 04:16 — forked from jonpaul/backbone_sync.js
Rewriting backbone.sync for rails CSRF
(function($) {
var methodMap = {
'create': 'POST',
'update': 'PUT',
'delete': 'DELETE',
'read' : 'GET'
};
var getUrl = function(object) {
if (!(object && object.url)) return null;
@there4
there4 / package_dev_tools.pp
Created September 4, 2012 21:35
Puppet dotfiles install
class package_dev_tools
{
package
{
'git-core':
ensure => present
}
@there4
there4 / handlebars_pluralization.js
Created September 6, 2012 01:41
Handlebars pluralization helper
// usage: {{pluralize collection.length 'quiz' 'quizzes'}}
Handlebars.registerHelper('pluralize', function(number, single, plural) {
return (number === 1) ? single : plural;
});
@there4
there4 / handlebars_fromnow.js
Created September 6, 2012 01:43
Handlebars time format helper
// usage: {{fromNow date}}
Handlebars.registerHelper('fromNow', function(date) {
moment = new Moment(date);
return moment.fromNow();
});
@there4
there4 / parse_url.js
Created September 12, 2012 13:12
AMD Javascript Parse URL
// # Simple Url Parsing via DOM.
// -----------------------------------------------------------------------------
//
// * Author: Craig Davis <[email protected]>
//
define([], function(undefined) {
var a = document.createElement('a');
return function (url) {
@there4
there4 / 404js.php
Created September 13, 2012 02:14
404 Handler for JS Files
<?php
// # 404 Handler for JS in Dev Environment
//
// I kept stubbing my toe. Backbone can make it hard to notice that a file
// has returned a 404 unless you have the console open. This makes it much
// more noticeable.
//
// This is coupled with the .htaccess file entry:
//
// RewriteCond %{REQUEST_FILENAME} !-f