Skip to content

Instantly share code, notes, and snippets.

@zackdouglas
zackdouglas / Lazy or short switch.js
Created March 28, 2018 23:42
A silly switch transpilation target
(f={f () { return 'f' }, g () { return 'g' }}['f'],f&&f()||new Error)
@zackdouglas
zackdouglas / jsTemplatedQuine.js
Created June 7, 2017 20:21
So close to a quine…
var expose=(strings,...expressions)=>{return{strings,expressions}};
JSON.stringify((expose`var ${expose(`expose=${expose}`)};`),undefined,2);
@zackdouglas
zackdouglas / detectPrivateMode.js
Created May 19, 2017 16:33
Detect if a user is in Private Browsing mode
function detectPrivateMode(a){var b;if(window.webkitRequestFileSystem)window.webkitRequestFileSystem(window.TEMPORARY,1,function(){b=!1},function(a){b=!0});else if(window.indexedDB&&/Firefox/.test(window.navigator.userAgent)){var c;try{c=window.indexedDB.open("test")}catch(a){b=!0}void 0===b&&t(function(){return"done"===c.readyState},function(a){a||(b=!c.result)})}else if(o(window.navigator.userAgent)){b=!1;try{window.indexedDB||(b=!0)}catch(a){b=!0}}else if(window.localStorage&&/Safari/.test(window.navigator.userAgent)){if(window.safariIncognito)b=!0;else try{window.localStorage.setItem("test",1)}catch(a){b=!0}void 0===b&&(b=!1,window.localStorage.removeItem("test"))}t(function(){return void 0!==b},function(c){a(b)})}
@zackdouglas
zackdouglas / README.md
Last active April 3, 2023 07:44
Universal JS atou/utoa

Utoatou

A better btoa and atob that supports non-ASCII characters in a healthy manner.

Compatible with AMD, CommonJS, and ES2015 module loaders.

@zackdouglas
zackdouglas / css-content-attr-fails.html
Created February 9, 2017 00:25
Why does CSS attr() fail for input elements?
<html>
<head>
<style>
body *:before {
content: attr(value) ' '
}
</style>
</head>
<body>
<div value=works />
@zackdouglas
zackdouglas / README.md
Last active January 27, 2017 15:21
Make any page look like-ish Markdown
@zackdouglas
zackdouglas / launchWorker.js
Created January 17, 2017 18:42
Launch a function as a Worker
function launchWorker(f) {
if (! (f instanceof Function)) {
throw new Error(`Cannot launch ${typeof(f)} as Worker`);
}
const src = `(${f})();`;
const blob = new Blob([src], {type: 'application/javascript'});
const url = URL.createObjectURL(blob);
return new Worker(url);
}
@zackdouglas
zackdouglas / template.html
Created September 9, 2015 19:33
Click to peek password entry field
<input type=password placeholder=Password onmousedown="this.type=''" onmouseup="this.type='password'" style="padding:1px"/>
@zackdouglas
zackdouglas / README.md
Last active September 9, 2015 17:37
Stagefright_CVE-2015-1538-1_Exploit

The Latest on Stagefright: CVE-2015-1538 Exploit is Now Available for Testing Purposes

By zLabs Wednesday, Sep 9 2015 at 08:05

37 465

8  7  585

More than a month has passed since Zimperium first broke the news of zLabs’ VP of Platform Research and Exploitation Joshua J. Drake’s discovery of multiple critical vulnerabilities in Android’s media library – libstagefright. In that time frame, the number and importance of the events that have unfolded is nothing short of amazing. Back in April and May we reported two sets of vulnerabilities to Google, both including multiple with critical severity. In July, we announced our intentions to publish our exploit on August 5th during Black Hat USA. After discussions with ZHA Partners, including both carriers and device manufacturers, we agreed to postpone the release of the exploit until August 24th. Multiple researchers have publicly discussed their own working exploits targeting vulnerabilities within libstagefright. Before we dive into our exploit, let’s rec

@zackdouglas
zackdouglas / test
Created April 26, 2015 04:48
Newline Diff Example
This line will not be included in the diff in the next revision.
This line will be included in the diff in the next revision.
This line was added in the new revision.