Skip to content

Instantly share code, notes, and snippets.


Keybase proof

I hereby claim:

  • I am bregenspan on github.
  • I am benregenspan ( on keybase.
  • I have a public key ASBLpQ0uaOXi-hamZxrh7-wK1nxOTmxl1tZ-seoYYtZ4Rwo

To claim this, I am signing this object:

bregenspan / diveTo.js
Last active Dec 17, 2020
Recursively dive() to deeply-wrapped components via Enzyme
View diveTo.js
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()
View Facebook SDK Splitting HOWTO
# Install NPM dependencies:
npm install babel-generator@6.26.0 babel-traverse@6.26.0 babylon@6.18.0
# Download Facebook's unminified SDK
# Run
node split-facebook-debug-js.js
View gist:33f7791a78f6e4115af5
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);
View AMDRequireDependency.js.patch
diff --git a/lib/dependencies/AMDRequireDependency.js b/lib/dependencies/AMDRequireDependency.js
index 1f183e1..526531b 100644
--- a/lib/dependencies/AMDRequireDependency.js
+++ b/lib/dependencies/AMDRequireDependency.js
@@ -47,14 +47,14 @@ AMDRequireDependency.Template.prototype.apply = function(dep, source, outputOpti
source.insert(depBlock.arrayRange[0] + 0.9, "var __WEBPACK_AMD_REQUIRE_ARRAY__ = ");
source.replace(depBlock.arrayRange[1], depBlock.functionRange[0] - 1, "; (");
source.insert(depBlock.functionRange[1], ".apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));");
- source.replace(depBlock.functionRange[1], depBlock.outerRange[1] - 1, "}" + wrapper[1]);
+ source.replace(depBlock.functionRange[1], depBlock.outerRange[1] - 1, "}.bind(this)" + wrapper[1]);
bregenspan / gist:e874f413bdcb62933a80
Created Nov 23, 2014
WD.js JS condition asserter that retries on-error.
View gist:e874f413bdcb62933a80
/* Version of wd.asserters.jsCondition that retries on-error.
This is useful for cases where you need to assert a condition at a time when the page might
be reloading -- in such a case, the assertion could reach the browser at a time when the document
is not yet ready, triggering an error. This catches the error and retries.
> browser.waitFor(jsConditionWithRetries('window.FOOBAR'), 5000, 500);
(Requires Selenium Server >= 2.44.0)
bregenspan / circle.yml
Created May 8, 2014
Testing a Circle CI build with Sauce Labs
View circle.yml
## Customize the test machine
- wget && tar -xvf sc-latest-linux.tar.gz
bregenspan / PanopticonSimulator.js
Last active Dec 20, 2015
Go to , open a Javascript console (Ctrl + Shift + J in Chrome), and run this, to simulate the terrifying surveillance panopticon that looms over us all.
View PanopticonSimulator.js
/* Panopticon Simulator v0.1
Scripts 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 = [
bregenspan / .gitconfig
Created May 25, 2013
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)
View .gitconfig
tool = mymeld
conflictstyle = diff3
[mergetool "mymeld"]
cmd = meld --diff $LOCAL $MERGED $REMOTE
bregenspan / gist:5637609
Created May 23, 2013
Android Studio Logcat Filter to exclude spammy messages
View gist:5637609