Skip to content

Instantly share code, notes, and snippets.

View junosuarez's full-sized avatar
💭
hi hello

juno suárez junosuarez

💭
hi hello
View GitHub Profile
rbenv install
gem install bundler
bundle install
# bootstrap all the things
<blink>im being held in san francisco working on legacy rails apps against my will</blink>
let a = []; for(let i = 0; i < .5e6; i++) a.push(i);
let lag = 0
let last = Date.now()
let int = setInterval(_=>{let now = Date.now();let diff=now-last;lag = Math.max(lag, diff);last = now; console.log('x'.repeat(40), now, lag, diff)}, 500)
(function safe(arr, fn, i) { i = i || 0; setImmediate(_=> { fn(i++); if (i < arr.length - 1) safe(arr, fn, i)}) })(a, console.log)

One could imagine a version of Node built on a hypothetical JavaScript-sans-Arrays. In such a world, packages would have to invent array types for themselves. The lingua franca array would be a number-keyed object, and packages would have to downcast their interpretation of arrays down to number-keyed objects at their thresholds. If a package missed doing this, their definition of an array would leak into calling packages. What if contemporary arrays were introduced into this ecosystem? At some level, they're still just sugar for objects-with-numeric-keys; but they'd have the potential to give packages a global interchange datatype for arrays. At the very least users would start passing them between packages. They'd expect native Arrays to work. Eventually there would be pressure on core to adopt the native Array. Would we do it?

The result of the above hypothetical is not that arrays replace objects, it's that native Arrays replace ad-hoc definitions of arrays. Native Arrays standardize the interchange form

@junosuarez
junosuarez / b.js
Last active February 1, 2016 00:21
Typescript error with --allowJavaScript - clone with git clone git@github.com:7cd1433497897e64af9f.git
function hi () {
return 'hi'
}
module.exports = hi
// compiles fine with:
// module.exports = function hi () {
// return 'hi'
// }
Prince of Networks, http://www.re-press.org/book-files/OA_Version_780980544060_Prince_of_Networks.pdf , page 89
For Latour all reality is political,
not because human power inexorably shapes the truth, but because truth
and reality are assembled through chains of actors in the same way that
bills go through Congress: slightly transformed and translated at each step,
and failing as often as they succeed. All reality is political, but not all poli-
tics is human.
referring to the ‘cosmopolitics’ of his friend Isabelle Stengers,
Latour speaks of a redefined political order that ‘brings together stars, pri-
@junosuarez
junosuarez / gist:7883441
Created December 10, 2013 00:06
example profiling from minq < 1.0.0
// rudimentary db query profiling
var profile
if (!config.profiledb) {
profile = function (x) { return x }
} else {
var totalQueries = 0
var profileLog = require('fs').createWriteStream('./dbprofile.log')
var path = require('path')
var base = path.resolve(path.join(__dirname, '..'))
// deferred example from https://github.com/cujojs/when/blob/master/docs/api.md#nodefncreatecallback
var when, nodefn;
when = require("when");
nodefn = require("when/node/function");
function nodeStyleAsyncFunction(callback) {
if(Math.random() * 2 > 1) {
callback("Oh no!");
} else {
@junosuarez
junosuarez / gist:7477639
Last active December 28, 2015 09:19
A census of SpiderMonkey ParserAPI JavaScript AST node types from 101,323 JavaScript files found on my computer in `~/dev`
Identifier 43806733
MemberExpression 14468088
Literal 14114779
CallExpression 7127477
ExpressionStatement 5921583
BlockStatement 4146079
Property 3926472
AssignmentExpression 3671689
BinaryExpression 3607263
VariableDeclarator 3017127
@junosuarez
junosuarez / gist:6875501
Created October 7, 2013 21:48
prototypal inheritance of getters / setters
a = Object.create({}, {
foo: {
get: function () { console.log('a.foo get') },
set: function (val) { console.log('a.foo set:', val) }
}
})
function B(){}
B.prototype = a
var b = new B