Skip to content

Instantly share code, notes, and snippets.

@inian
inian / unregister.js
Last active June 2, 2018 08:20
Unregister Dexecure Service Worker registrations
try {
navigator.serviceWorker.getRegistrations().then(function(registrations) {
registrations.forEach(function(registration) {
if (registration.active && registration.active.scriptURL.includes("dexecure")) {
console.log('removing registration', registration);
registration.unregister();
}
})
})
} catch (e) {
@inian
inian / cookieinject.py
Created June 9, 2015 03:41
Mitmproxy cookie Inject Script
cookieFile = ""
def start(context, argv):
global cookieFile
cookieFile = argv[1]
def request(context, flow):
f = open(cookieFile)
cookie =f.read().strip()
f.close()
if cookie != "":
@inian
inian / http2-compatibility-api.js
Last active November 4, 2017 12:55
Creating a zero-dependency Node.js static file server
const http2 = require('http2');
const fs = require('fs');
const options = {
key: fs.readFileSync('./selfsigned.key'),
cert: fs.readFileSync('./selfsigned.crt'),
allowHTTP1: true
}
const server = http2.createSecureServer(options, (req, res) => {
@inian
inian / swapon.sh
Created January 7, 2016 06:08
enable swap on ubuntu 14.04
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
@inian
inian / firstpaint.js
Created July 20, 2015 10:03
First Paint
timing = !!(typeof window.performance !== "undefined" && typeof window.performance.timing !== "undefined");
if (timing && timing.msFirstPaint && window.t_pagestart) {
t_firstpaint = timing.msFirstPaint - window.t_pagestart;
} else if (window.chrome && typeof window.chrome.loadTimes === 'function') {
t_firstpaint = window.chrome.loadTimes().firstPaintTime - window.chrome.loadTimes().startLoadTime;
}
@inian
inian / gist:4305b04f991529c67b5a
Created April 15, 2015 06:03
Set up a virtual display
export DISPLAY=:10
killall -9 Xvfb
Xvfb :10 -screen 0 1024x768x24 -extension RANDR > /dev/null 2>&1 &