Skip to content

Instantly share code, notes, and snippets.

@joequery
joequery / gitfixup.py
Last active December 20, 2015 02:29
This script searches through the git log for the current directory you're in and starts an interactive rebase on a "base commit", which is simply a commit that doesn't start with "fixup! "
#!/usr/bin/env python
import subprocess
p = subprocess.Popen(["git", "log", "--format='%s'"], stdout=subprocess.PIPE)
out, err = p.communicate()
# Keep going until we don't find a "fixup! "
fixup_count = 0
max_list_size = 10
commits = out.split('\n')[:max_list_size]
@joequery
joequery / gist:6231493
Created August 14, 2013 14:19
Git some information about a repo if possible.
#!/usr/bin/env python
import subprocess
import os
F_DEVNULL = open(os.devnull, 'w')
p = subprocess.Popen(["git", "rev-parse", "--show-toplevel"],
stdout=subprocess.PIPE, stderr=F_DEVNULL)
repo_root, err = p.communicate()
repo_root = repo_root.strip()
@joequery
joequery / gist:6232026
Last active December 21, 2015 01:59 — forked from goatslacker/gist:6004481
Create a parseable time tracking log for vim. Requires https://gist.github.com/joequery/6231493 for the `git info` command.
" Lets me know how much time I've spent editing a file
" Keyboard shortcut -> \dt
augroup TimeSpentEditing
au!
au BufWinEnter * if !exists('b:tstart')|let b:tstart=reltime()|en
augroup END
function! TimeSpentEditing()
let secs = str2nr(reltimestr(reltime(b:tstart)))
let hours = secs / 3600
@joequery
joequery / gist:6232325
Created August 14, 2013 15:45
Quick jarnal notes
jarnal $(date +"notes_%b_%d_%Y.jaj" | tr '[:upper:]' '[:lower:]')
@joequery
joequery / gist:6271117
Last active December 21, 2015 07:28
Jarnal executables
# File: jaj2pdf
# Quickly convert jarnal files to pdf. Page dimensions don't seem to be
# preserved unfortunately
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
java -Xms64m -Xmx512m -jar $DIR/jarnalDir/jarnal.jar -pdf - $1
# File: jarnal
# Open up jarnal!
#!/bin/bash
(function () {
var t;
(function (t, e, i) {
function n(i, s) {
if (!e[i]) {
if (!t[i]) {
var r = "function" == typeof require && require;
if (!s && r) return r(i, !0);
if (o) return o(i, !0);
throw Error("Cannot find module '" + i + "'")
@joequery
joequery / gist:6528193
Created September 11, 2013 18:59
Altered Un-minified mapbox
(function () {
var t;
(function (t, e, i) {
function n(i, s) {
if (!e[i]) {
if (!t[i]) {
var r = "function" == typeof require && require;
if (!s && r) return r(i, !0);
if (o) return o(i, !0);
throw Error("Cannot find module '" + i + "'")
@joequery
joequery / enumeration_example.py
Created November 13, 2013 17:59
Python enumerate()
>>> # Suppose we have this list of tuples, each of length two.
... # Element 1 is a persons first name, element 2 is their last name
...
>>> names = [('Joseph', 'McCullough'), ('Luke', 'PolishLastName')]
>>> # Now, if we do a normal for loop, the item per each iteration is
... # a tuple
...
>>> for name in names:
... print("first: " + name[0])
... print("last: " + name[1])
@joequery
joequery / gist:7948727
Created December 13, 2013 18:19
Best spam email ever
If this email ends up in your spam folder move it to your inbox so links and
attachments would be active, you won't regret it!!!
Instead of $660* just $19.99(
look here!
[link removed]
), special Christmas offer, check the attachments!
@joequery
joequery / gist:7990173
Created December 16, 2013 16:48
testing django apps using django_discover_runner. Allows you to specify paths so you can use linux file autocompletion.
#!/usr/bin/env python
import sys
import subprocess
if len(sys.argv) != 2:
exit("Improper usage. Do pytest test/path/to/tests.someTestCase.some_test")
command_list = ["python", "manage.py", "test"]
test_path = sys.argv[1].replace("/", ".")
command_list.append(test_path)