Skip to content

Instantly share code, notes, and snippets.

View jjmalina's full-sized avatar

Jeremiah Malina jjmalina

View GitHub Profile
@jjmalina
jjmalina / pre-commit
Last active October 1, 2015 11:17
Git pre-commit hook stolen from Yipit's blog
#!/usr/bin/env python
import os
import re
import subprocess
import sys
modified = re.compile('^(?:M|A)(\s+)(?P<name>.*)')
CHECKS = [
@jjmalina
jjmalina / storage.py
Created March 5, 2012 22:57
storage.py
from django.core.files.storage import get_storage_class
from storages.backends.s3boto import S3BotoStorage
class CachedS3BotoStorage(S3BotoStorage):
"""
S3 storage backend that saves the files locally, too.
"""
def __init__(self, *args, **kwargs):
super(CachedS3BotoStorage, self).__init__(*args, **kwargs)
self.local_storage = get_storage_class(
@jjmalina
jjmalina / columns.py
Created November 20, 2012 04:35
Columns
def columns(size, columns=30):
"""
Return the number of items in each of X columns given a number.
Basically the idea is to find exact or next largest rectangle of a given
number and given amount of columns. Then fill each column evenly.
"""
nearest_rect = 0
column_items = [0 for i in xrange(columns)]
for index in xrange(columns):
@jjmalina
jjmalina / shouts.js
Created November 30, 2012 23:17
Pin Shout
$(document).ready(function() {
var API_URL = "http://3n7g.localtunnel.com";
function newMap(lat, lng) {
var prevMap = $("#map img");
prevMap.css("z-index", 2);
@jjmalina
jjmalina / strings.py
Created December 21, 2012 16:38
Strings in Python. Credit to @lsemel
"""
.dMMMb dMMMMMMP dMMMMb dMP dMMMMb .aMMMMP .dMMMb
dMP" VP dMP dMP.dMP amr dMP dMP dMP" dMP" VP
VMMMb dMP dMMMMK" dMP dMP dMP dMP MMP" VMMMb
dP .dMP dMP dMP"AMF dMP dMP dMP dMP.dMP dP .dMP
VMMMP" dMP dMP dMP dMP dMP dMP VMMMP" VMMMP"
.aMMMb dMMMMb dMMMMMP dMMMMb dMP dMP dMMMMMMP dMMMMMP .dMMMb
dMP"dMP dMP.dMP dMP dMP"dMP dMP.dMP dMP dMP dMP" VP
dMMMMMP dMMMMK" dMMMP dMMMMK" VMMMMP dMP dMMMP VMMMb

$ brew update

$ brew install rbenv

$ brew install ruby-build

append eval "$(rbenv init -)" to your bash profile

$ rbenv install 1.9.3-p327

@jjmalina
jjmalina / example.js
Created March 12, 2013 23:23 — forked from jhs/example.js
// Short module explanation // Something to gather my thoughts
// // I think this looks cool.
//
module.exports = the_exported_function // Modules are a function. Always.
//
module.exports.extra = extra // Additional API entry points if
module.exports.other = other // desired.
//
var util = require('util') // Other packages from npm or core
var assert = require('assert') // No comma-first due to lots of
@jjmalina
jjmalina / Gruntfile.coffee
Created August 27, 2013 16:43
Using grunt-contrib-watch and grunt-contrib-coffee to only compile files as needed
# It's pretty annoying to get single CoffeeScript file compilation with grunt-contrib-coffee
# and grunt-contrib-watch because it doesn't work out of the box.
#
# This is an open issue and it depends on how your project is structured and how your tasks are configured.
# See: https://github.com/gruntjs/grunt-contrib-watch/issues/149
#
# Below is my simple solution which in a sort of hacky way alters the grunt config object at runtime.
module.exports = (grunt) ->
//
// insertion of logs into riak
// usage:
// cat logs | log-processing --host=127.0.0.1 --port=10017 mybucket
package main
import (
"bufio"
"encoding/json"
@jjmalina
jjmalina / gist:7606956
Created November 22, 2013 21:12
riakpbc crash
2013/11/22 13:33:59 ADDED 1VjPs9KAvFG52GuZJQsRvzgBN99 from line 2867651
2013/11/22 13:34:09 ADDED error from line 2867652
2013/11/22 13:34:09 ADDED error from line 2867653
2013/11/22 13:34:09 ADDED error from line 2867654
panic: interface conversion: interface is *riakpbc.RpbPutResp, not []uint8
goroutine 4 [running]:
github.com/mrb/riakpbc.(*Node).Ping(0xc200082190, 0xc20008b4b0)
/home/jeremiah/code/go/src/github.com/mrb/riakpbc/node.go:141 +0xda
github.com/mrb/riakpbc.(*Pool).Ping(0xc20008b4d0)