Skip to content

Instantly share code, notes, and snippets.

# Install NPM dependencies:
npm install babel-generator@6.26.0 babel-traverse@6.26.0 babylon@6.18.0
# Download Facebook's unminified SDK
wget https://connect.facebook.net/en_US/sdk/debug.js
# Run
node split-facebook-debug-js.js
@bregenspan
bregenspan / diveTo.js
Last active December 17, 2020 02:17
Recursively dive() to deeply-wrapped components via Enzyme
import merge from 'lodash/merge';
/**
* Given an Enzyme ShallowWrapper and component identifier, dives() down until the
* specified component is the root component.
*
* @param { Enzyme.ShallowWrapper } shallowWrapper - wrapper to dive into
* @param { string } name of component to dive for (should match constructor name).
* @param { object= } options to pass to dive()
*/
@bregenspan
bregenspan / gist:5637609
Created May 23, 2013 16:59
Android Studio Logcat Filter to exclude spammy messages
^((?!wpa_supplicant|NetStatUtil).*)$

Keybase proof

I hereby claim:

  • I am bregenspan on github.
  • I am benregenspan (https://keybase.io/benregenspan) on keybase.
  • I have a public key ASBLpQ0uaOXi-hamZxrh7-wK1nxOTmxl1tZ-seoYYtZ4Rwo

To claim this, I am signing this object:

@bregenspan
bregenspan / gist:33f7791a78f6e4115af5
Created September 29, 2015 13:41
Sort Webpack analyze tool chunk list (e.g. http://webpack.github.io/analyse/#chunk/31) by size
var table = document.querySelectorAll('tbody')[1];
Array.prototype.slice.apply(table.querySelectorAll('tr')).forEach(function (el) {
var size = el.querySelector('td:nth-of-type(3)').innerHTML;
var num = parseInt(size,0);
if (size.indexOf('KiB') > -1) {
num = num * 1024;
}
el.setAttribute('data-size', num);
})
@bregenspan
bregenspan / gist:2161338
Created March 22, 2012 18:25
Mixin to supply Tastypie resource with support for X-HTTP-Method-Override headers, using jacobian's patch from https://github.com/toastdriven/django-tastypie/pull/351
class XHMOMixin(object):
"""
Use to supply a Tastypie resource with support for X-HTTP-Method-Override
headers, e.g.:
`class HomeResource(XHMOMixin, ModelResource):`
"""
def method_check(self, request, allowed=None):
"""
@bregenspan
bregenspan / PanopticonSimulator.js
Last active December 20, 2015 14:29
Go to http://360gigapixels.com/tokyo-tower-panorama-photo/ , open a Javascript console (Ctrl + Shift + J in Chrome), and run this, to simulate the terrifying surveillance panopticon that looms over us all.
/* Panopticon Simulator v0.1
Scripts http://360gigapixels.com/tokyo-tower-panorama-photo/ to convey a
deep, Enemy Of The State starring Will Smith-reminescent message regarding
the surveillance state and the voyeurism of gigapixel photos.
*/
var people = [
[-7.510113307350065,14.652493577797886,0.5],
[56.83548684296012,16.498978246091596,0.5],
@bregenspan
bregenspan / .gitconfig
Created May 25, 2013 00:53
Git merge config to use Meld as merge tool (with the middle pane representing the merge target, unlike the crappy default where middle pane is BASE)
[merge]
tool = mymeld
conflictstyle = diff3
[mergetool "mymeld"]
cmd = meld --diff $LOCAL $MERGED $REMOTE
@bregenspan
bregenspan / gist:5061480
Created March 1, 2013 00:39
Quick little script to test an XCode expression against an HTML file, using Scrapy's XPath selector. This is by no means the best or most direct way to test an XPath expression.
from scrapy.http import TextResponse
from scrapy.selector import HtmlXPathSelector
XPATH_TO_TEST = "//img/@src"
FILE_TO_TEST_AGAINST = "pathtest.html"
f = open(FILE_TO_TEST_AGAINST, 'r')
test_html = f.read()
response = TextResponse('http://www.example.com', status=200, headers=[], body=test_html)
@bregenspan
bregenspan / gist:2504141
Created April 26, 2012 23:28
Add support for combination of manual and automatic bindings to Backbone ModelBinder
diff --git a/static/js/lib/Backbone.ModelBinder.js b/static/js/lib/Backbone.ModelBinder.js
index b321c37..53881b1 100644
--- a/static/js/lib/Backbone.ModelBinder.js
+++ b/static/js/lib/Backbone.ModelBinder.js
@@ -25,6 +25,10 @@
this._model = model;
this._rootEl = rootEl;
+ this._attributeBindings = {};
+ this._options = { // TODO: set this properly