Skip to content

Instantly share code, notes, and snippets.

View bmeck's full-sized avatar

Bradley Farias bmeck

View GitHub Profile
// https://github.com/bmeck/StaticAnalysis
var script = new Script("function f() {return x;}", "index.js");
// hint: 1 scope for basic script
function* getImpureAssignments(scope, ignore = new Set()) {
if (scope.type == Scope.TYPE.WITH) {
yield {
type: 'WithScope',
// will point to w/e was in with($ref)
reference: scope.arguments().next().reference()
var asn = require('asn1.js');
var rfc3280 = require('asn1.js/rfc/3280');
var CRLReason = rfc3280.CRLReason;
var Certificate = rfc3280.Certificate;
var fs = require('fs');
global.log = false;
var cert = Certificate.decode(fs.readFileSync('sandbox/valid-cert/cacert.der'), 'der')
var exts = cert.tbsCertificate.extensions;
global.log = false;
var asn = require('asn1.js');
var rfc3280 = require('asn1.js/rfc/3280');
var CRLReason = rfc3280.CRLReason;
var Certificate = rfc3280.Certificate;
var fs = require('fs');
global.log = false;
var cert = Certificate.decode(fs.readFileSync('sandbox/valid-cert/cacert.der'), 'der')
var exts = cert.tbsCertificate.extensions;
var CRLDistPoints = asn.define('CRL Distribution Points', function() {
function scrape(url) {
var page = ''; //or whatever
var fulfill,reject;
var ret = new Promise(function (f,r) {
fulfill = f;
reject = r;
});
function getPage(current) {
request(current, function (err, data) {
if (err) {
@bmeck
bmeck / gist:734bd0da9ce25cba0ee4
Created April 3, 2015 19:07
leaky `hasOwnProperty` and `get arguments`?
var binding = require('bindings')('eol.node');
var heapdump = require('heapdump');
var fs = require('fs');
function easy_to_find_names() {
var taco_tuesday = {
wacky_wednesday: function keep_closure_alive() {}
};
return taco_tuesday;
}
var things = [easy_to_find_names()]//, easy_to_find_names()];
@bmeck
bmeck / notes.md
Last active August 29, 2015 14:16
Notes on Async Call Bradley Meck and Alex Rauchmayer
@bmeck
bmeck / runner.js
Created January 30, 2015 18:01
Example of making a complex runner capable of limited concurrency, disjoint continuation, and mixed concurrency/parallelism
// an example of using async / await style scheduling using callbacks
// we can do things without promises and get some nicer (imho) results
// promises still work here, but are not shown for advanced cases
function* task(step) {
//
// simple callback style continuation
//
yield _ => setTimeout(_,0);
@bmeck
bmeck / scenarios
Last active August 29, 2015 14:12
example of a transaction
All read/write locks exist from start of tranaction until the transaction is commited.
This effectively lets you lock all rows relevant to your transaction, and if there is a conflict
replay the transaction.
1. concurrent write to `parent`
Newest transaction gets replayed.
2. reading a `parent` that is being written to
@bmeck
bmeck / minimal-modification.js
Created January 2, 2015 04:26
Jan- code redux
var WrappedBuffer = Buffer;
function RiffFile(file) {
this.readstream = require('fs').createReadStream(file);
this.readstream.on('readable',function(){
this.consume();
}.bind(this));
this.filesize = require('fs').statSync(file).size;
this.runOnce = true;
this.totalReads = 0;
}
@bmeck
bmeck / this-file.js
Last active August 29, 2015 14:12
attempt to find repro for Jan-'s problem
// usage: node this-file.js file-to-read
stream=require('fs').createReadStream(process.argv[2]);
var to_read = 315208358;
var max_chunk = Math.pow(2,17);
var largest_chunk = 0;
var total_read = 0;
stream.on('readable', function () {
console.log('readable')
var b=stream.read(Math.min(max_chunk, to_read - total_read))
while(b != null && to_read) {