Skip to content

Instantly share code, notes, and snippets.

View mattrobenolt's full-sized avatar
🀠
πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”

Matt Robenolt mattrobenolt

🀠
πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”
View GitHub Profile
json = raw_response.json
type_ = json['type']
cls = type(str(type_), (Response,), {})
response = cls()
func = functools.partial(setattr, response)
map(lambda t: func(*t), json.iteritems())
Index: src/array.js
===================================================================
--- src/array.js (revision 12923)
+++ src/array.js (working copy)
@@ -1239,8 +1239,8 @@
var accumulator = new InternalArray(length);
if (%DebugCallbackSupportsStepping(f)) {
for (var i = 0; i < length; i++) {
- if (i in array) {
- var element = array[i];
@mattrobenolt
mattrobenolt / gist:4299723
Created December 15, 2012 22:05
Python benchmark ways to cast an integer to a string: `a` vs str(a) vs format vs % vs repr(a)
# Python 2.7.3
$ python -m timeit -s 'a=5' 'str(a)'
10000000 loops, best of 3: 0.177 usec per loop
$ python -m timeit -s 'a=5' '`a`'
10000000 loops, best of 3: 0.0571 usec per loop # Fastest, but seems like it's not good practice
$ python -m timeit -s 'a=5' '"%s".format(a)'
1000000 loops, best of 3: 0.236 usec per loop # Slowest
$ python -m timeit -s 'a=5' '"%s" % a'
10000000 loops, best of 3: 0.159 usec per loop
$ python -m timeit -s 'a=5' 'repr(a)'
>>> f1 = lambda i: '%s' % i
>>> f2 = lambda i: '%s'.format(i)
>>> import dis
>>> dis.dis(f1)
1 0 LOAD_CONST 1 ('%s')
3 LOAD_FAST 0 (i)
6 BINARY_MODULO
7 RETURN_VALUE
>>> dis.dis(f2)
1 0 LOAD_CONST 1 ('%s')
@mattrobenolt
mattrobenolt / gist:4439597
Created January 3, 2013 00:07
Django middleware to capture X-Forwarded-Port header
class XForwardedPort(object):
def process_request(self, request):
try:
request.META['SERVER_PORT'] = request.META['HTTP_X_FORWARDED_PORT']
except KeyError:
pass
return None
from django.db import models
class DeviceA(object):
def do_something(self, string='Hello'):
print "Device A something '%s'" % string
def do_something_else(self):
print "Device A something else"
@mattrobenolt
mattrobenolt / gist:4473290
Last active December 10, 2015 18:18
Compiling Actionscript files to swf with the Flex SDK using a Makefile
MXMLC=/usr/local/Cellar/flex_sdk/4.6.0.23201/libexec/bin/mxmlc
all: HelloWorld.swf
.as.swf:
$(MXMLC) --static-link-runtime-shared-libraries=true -o $@ $<
.PHONY: all
.SUFFIXES: .as .swf
@mattrobenolt
mattrobenolt / gist:4490571
Created January 9, 2013 04:26
Comcast is awesome
$ ping -t30 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
64 bytes from 8.8.8.8: icmp_seq=0 ttl=46 time=4745.140 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=46 time=3744.064 ms
Request timeout for icmp_seq 6
Request timeout for icmp_seq 7
// parseUri 1.2.2
// (c) Steven Levithan <stevenlevithan.com>
// MIT License
function parseUri (str) {
var o = parseUri.options,
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
uri = {},
i = 14;
@mattrobenolt
mattrobenolt / README.md
Last active December 11, 2015 04:29
raven-js public beta

Raven.js (public beta)

Raven.js v1.0 and above requires Sentry v5.2 or later. If you're using getsentry.com, you're already up to date!

Migration Guide

First and foremost, "What is different when using Raven 1.0?" The new method is:

Raven.config(...).install()