Last active
September 5, 2016 16:08
-
-
Save haf/33d6c6dd94fc6259efdf05fb2fb1ff95 to your computer and use it in GitHub Desktop.
Make your OS X firewall mess with connections to js.stripe.com to test your async JavaScript
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
dig js.stripe.com |
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
<head> | |
<script type="text/javascript"> | |
//<![CDATA[ | |
function getScript(url, cb) { | |
var script = document.createElement('script'); | |
script.async = true; | |
script.src = url; | |
var head = document.getElementsByTagName('head')[0], | |
done = false; | |
script.onload = script.onreadystatechange = function() { | |
if (!done | |
&& (!this.readyState | |
|| this.readyState == 'loaded' | |
|| this.readyState == 'complete')) { | |
done = true; | |
cb(); | |
script.onload = script.onreadystatechange = null; | |
head.removeChild(script); | |
}; | |
}; | |
head.appendChild(script); | |
}; | |
getScript("https://js.stripe.com/v2/", function() { | |
Stripe.setPublishableKey('pk_test_Jxxxxxx'); | |
}); | |
//]]> | |
</script> | |
</head> |
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
#!/usr/bin/env bash | |
sudo su | |
dnctl pipe 1 config bw 6Kbit/s plr 0.2 delay 300 | |
echo "dummynet out proto tcp from any to 151.101.84.176 pipe 1" | pfctl -f - | |
# enable the rules | |
pfctl -e | |
# test things | |
time curl https://js.stripe.com/v2/ ... | |
# remove the rules | |
dnctl -q flush | |
# shutdown the application firewall | |
pfctl -d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment