Skip to content

Instantly share code, notes, and snippets.

View joshbode's full-sized avatar
💽

Josh Bode joshbode

💽
  • Melbourne, Victoria, Australia
View GitHub Profile
@joshbode
joshbode / README.md
Last active August 29, 2015 14:02
Piratifying Proxy

Piratifying Proxy

  1. Install gunicorn and requests:

      $ pip install gunicorn requests
    
  2. Save pyrate.py to a directory and run the proxy from that directory:

$ gunicorn --workers 4 pyrate:app

@joshbode
joshbode / dijkstra.py
Last active August 29, 2015 14:02
Dijkstra's algorithm for finding shortest path (heapq version)
#!/usr/bin/env python
import heapq
def dijkstra(tree, start, end):
"""Dijkstra's algorithm for finding shortest path."""
queue = [(0, start, (start, ))]
seen = set()
@joshbode
joshbode / remark.html
Created June 25, 2014 05:39
Remark referencing a standalone Markdown doc (e.g. remark.html?doc=foo)
<!DOCTYPE html>
<html>
<head>
<title>Loading...</title>
<meta charset="utf-8" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" type="text/javascript"></script>
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" type="text/javascript"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
@joshbode
joshbode / combine.R
Last active August 29, 2015 14:03
Combine Nested Lists in R
#' Combine (nested) lists left-to-right
#'
#' @param ... lists to be combined.
combine = function(...) {
stack = rev(list(...))
names(stack) = rep('', length(stack))
result = list()
while (length(stack)) {
@joshbode
joshbode / active.bat
Last active August 29, 2015 14:06
Script to remind you to get up and take a break periodically
@echo off
start /B "" pythonw "%~dp0active.py" %*
"""
Encrypt data.
"""
import sys
import base64
import hashlib
from Crypto import Random
from Crypto.Cipher import AES
WITH
t AS (
-- determine compression flag
SELECT
'TABLE PARTITION' segment_type, t.table_name segment_name,
t.compression, t.compress_for,
t.partition_name
FROM
user_tab_partitions t
UNION ALL
# densify (fill) the missing levels of a data frame
densify = function(d, fill, dimensions, defaults=list()) {
# ensure columns to be filled are factors
dimensions = setdiff(dimensions, fill)
invalid = fill[!sapply(d[fill], is.factor)]
if (length(invalid)) {
stop("Cannot fill non-factors: ", paste0(fill, collapse=', '))
}
#include <TrinketKeyboard.h>
#define BUTTON 0
#define LED 1
const unsigned int WINDOW_DELAY = 500;
const unsigned int DEBOUNCE_DELAY = 50;
const unsigned short MAX_PRESS = 4;
unsigned long window_start = 0;
"""
Export song list from KBox
"""
import json
import requests
from xml.etree import cElementTree as ElementTree
import csv
# song data tags