This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Simple, asynchronous, nonblocking UDP emitter for Cube metrics. | |
""" | |
import json | |
import socket | |
from datetime import datetime | |
class Emitter(object): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Some really hacky code being used in my next blog redesign. | |
// by Peter Sobot (psobot.com) on December 16, 2012 | |
;(function ( $, window, document, undefined ) { | |
var pluginName = 'punchout', | |
defaults = { | |
}; | |
function Plugin( element, options ) { | |
this.element = element; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
1) Be someone crazy working with Apple's CoreAudio. | |
2) Put "CAShow(graph)" somewhere in your Objective-C code. | |
3) Copy the resulting output from your XCode Console window. | |
4) Do `pbpaste | python plot.py && open out.png` | |
5) See a very basic rendering of the crazy audio graph you've made. | |
""" | |
import re | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Queue | |
import multiprocessing | |
import threading | |
class BufferedReadQueue(Queue.Queue): | |
def __init__(self, lim=None): | |
self.raw = multiprocessing.Queue(lim) | |
self.__listener = threading.Thread(target=self.listen) | |
self.__listener.setDaemon(True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass[10pt]{article} | |
\usepackage[margin=1in]{geometry} | |
\usepackage[utf8]{inputenc} | |
\usepackage{amsmath} | |
\usepackage{amsfonts} | |
\usepackage{amssymb} | |
\setcounter{secnumdepth}{0} | |
\usepackage{fancyhdr, lastpage} | |
\pagestyle{fancy} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Read-only, network-free sandbox | |
;; Mac OS X 10.7+ | |
;; Restricts file writes and network access for any command run like: | |
;; sandbox-exec -f ronf.sb <command> | |
;; Useful for untrusted programs that should only do computation. | |
(version 1) | |
(allow default) | |
(deny file-write*) | |
(deny network*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
"The Beatbox Machine" by Peter Sobot and Borna Almasi | |
Designed and written in 4 hours on Sept. 25, 2011 at Music Hack Day Montréal | |
Dependencies: | |
EchoNest.Remix | |
Wubmachine.Remixer (https://github.com/psobot/wub-machine) | |
this file should end up in <wub-root>/remixers/beatbox.py | |
Honestly, this is just a code-dump to Github. (And the code only sorta-kinda-works, with hardcoded values.) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
liveyamlfile.py | |
Live Pythonic attribute access to properties in a yaml file. | |
by Peter Sobot (hi@psobot.com), August 8, 2012 | |
""" | |
import os | |
import time | |
import yaml | |
import logging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Detect exactly which bytes have changed in a file. | |
Useful for binary reverse engineering: | |
- Start script | |
- Save file from program, changing one attribute | |
- See which byte(s) have changed | |
""" | |
import os | |
import traceback |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RoundingDict(dict): | |
def __getitem__(self, key): | |
if key in self: | |
return dict.__getitem__(self, key) | |
try: | |
values = [abs(x - key) for x in self.keys()] | |
return self.values()[values.index(min(values))] | |
except (TypeError, ValueError): | |
raise KeyError(key) |