Skip to content

Instantly share code, notes, and snippets.

View groovecoder's full-sized avatar
:shipit:

luke crouch groovecoder

:shipit:
View GitHub Profile
@groovecoder
groovecoder / gist:947150
Created April 28, 2011 19:40
vim command to remove the 3-byte unicode character under the cursor from the whole file
exec '%s/'.getline('.')[col('.')-1].getline('.')[col('.')].getline('.')[col('.')+1].'//g'
@groovecoder
groovecoder / gist:1701382
Created January 29, 2012 23:40
AttributeError: 'module' object has no attribute 'writer'
import csv
import os
STORING_TO_CSV = False
if 'STORE_TO_CSV' in os.environ:
facilities_csv = csv.writer(open('thd_facilities.csv', 'w'))
inspections_csv = csv.writer(open('thd_inspections.csv', 'w'))
STORING_TO_CSV = True
print "Storing to CSV"
@groovecoder
groovecoder / crest
Created March 13, 2012 04:08
a tiny crud/rest api in php
<?php
class db
{
protected static $dbh = false;
public function connect($dsn = null)
{
self::$dbh = new PDO($dsn);
self::$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
let mapleader = ","
filetype plugin indent on
set t_Co=256
colorscheme lucius
set nocompatible
set autoindent
set tabstop=4
set softtabstop=4
set shiftwidth=4
" Gist
let g:gist_clip_command='pbcopy'
let g:gist_detect_filetype=1
nnoremap <silent> <Leader>V :'<,'>Gist<CR>
" Gist
let g:gist_clip_command='pbcopy'
let g:gist_detect_filetype=1
nnoremap <silent> <Leader>V :'<,'>Gist<CR>
// ### EJSTemplate
//
// Template executed using EJS
var EJSTemplate = ks_utils.Class(BaseTemplate, {
initialize: function (options) {
BaseTemplate.prototype.initialize.apply(this, arguments);
var ejs = require('ejs');
util.debug("EJSTemplate.initialize, source: " + util.inspect(this.options.source));
this.compiled = ejs.compile(this.options.source);
util.debug("EJSTemplate.initialize, compiled: " + util.inspect(this.compiled));
@groovecoder
groovecoder / loaddata_without_fk_checks.py
Created March 20, 2012 18:51
monkey patch django loaddata to ignore foreign key checks
# monkey-patch django loaddata to ignore foreign key checks
from django.core.management.commands.loaddata import Command
from django.db import connections, DEFAULT_DB_ALIAS
def uses_mysql(connection):
return 'mysql' in connection.settings_dict['ENGINE']
_old_handle = Command.handle
def _foreign_key_ignoring_handle(self, *fixture_labels, **options):
"""Wrap the the stock loaddata to ignore foreign key checks so we can load
circular references from fixtures.
@groovecoder
groovecoder / gist:2388128
Created April 14, 2012 22:20
facility_json
{
"meta": {
"limit": 20,
"next": null,
"offset": 0,
"previous": null,
"total_count": 1
},
"objects": [
{
@groovecoder
groovecoder / gist:2389023
Created April 15, 2012 00:28
git log aliases
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
lol = log --graph --decorate --pretty=oneline --abbrev-commit
lola = log --graph --decorate --pretty=oneline --abbrev-commit --all