Current status: incomplete draft.
- Computation: V8 very fast; significantly faster than most interpreted languages. The one very big exception is PyPy, which is in the same ballpark
""" | |
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 |
""" | |
Simple, asynchronous, nonblocking UDP emitter for Cube metrics. | |
""" | |
import json | |
import socket | |
from datetime import datetime | |
class Emitter(object): |
class MyClass(object): | |
def __init__(self): | |
self.foo = "I'm the correct variable!" | |
def do_something(self): | |
# Whoops, I forgot to write this as "self.foo". | |
print foo | |
if __name__ == "__main__": | |
foo = "Herp derp, I'm the wrong variable." |
-- Let's say you've got a Redis list that's composed of JSON values: | |
-- -- {"a": 5.2, "b": "something blah blah"} | |
-- -- {"a": 4.3, "b": "something blah blah"} | |
-- -- {"a": 125.2, "b": "something blah blah"} | |
-- And let's say that you want to increment all of the "a" fields by n. | |
-- Call the below script with: | |
-- -- KEYS = [key_of_list_to_update] | |
-- -- ARGV = [json_key_to_incr, value_to_add] | |
local num = redis.call('llen', KEYS[1]) |
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) |
// 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; |
// NSDate doesn't include overrides for standard comparison operators in Swift. | |
// This extension adds <, >, <=, >=, and ==, using NSDate's built-in `compare` method. | |
// MIT licensed. | |
func <=(lhs: NSDate, rhs: NSDate) -> Bool { | |
let res = lhs.compare(rhs) | |
return res == .OrderedAscending || res == .OrderedSame | |
} | |
func >=(lhs: NSDate, rhs: NSDate) -> Bool { | |
let res = lhs.compare(rhs) |
""" | |
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 |