Skip to content

Instantly share code, notes, and snippets.

View vicapow's full-sized avatar

Victor vicapow

View GitHub Profile
@vicapow
vicapow / 56GB.js
Last active November 5, 2015 04:50
Was I really just able to allocate 56GB of memory in Google chrome?
var x = [];
for (var i = 0; i < 56; i++) {
x.push(new Uint8Array(1024 * 1024 * 1024));
}
console.log(x.length);
This file has been truncated, but you can view the full file.
1c1
< (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
---
> (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.mapboxgl = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Canno
@vicapow
vicapow / json-to-js
Created May 31, 2015 03:18
json-to-js
#! /usr/local/bin/node
var util = require('util');
var vm = require('vm');
var Writable = require('stream').Writable;
var ws = Writable();
var chunks = [];
ws._write = function (chunk, enc, next) {
chunks.push(chunk);
next();
@vicapow
vicapow / js-to-json
Created May 31, 2015 03:17
js-to-json
#! /usr/local/bin/node
var vm = require('vm');
var Writable = require('stream').Writable;
var ws = Writable();
var chunks = [];
ws._write = function (chunk, enc, next) {
chunks.push(chunk);
next();
};
@vicapow
vicapow / index.html
Created May 30, 2015 23:13
circle packing with depth dependent padding
<!DOCTYPE html>
<html>
<style>
body {
margin: 0;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.js" charset="utf-8"></script>
<script>
@vicapow
vicapow / README.md
Last active August 29, 2015 14:19
Possible workshop schedule

Possible schedule for a D3.JS workshop.

@vicapow
vicapow / _.md
Last active August 29, 2015 14:19
test
@vicapow
vicapow / d3-masonic.js
Created March 15, 2015 19:14
masonic demo
// Checkout the project page at: https://github.com/shawnbot/masonic
(function(exports) {
var VERSION = "0.1.0";
d3.masonic = function() {
var columnCount = 0,
columnWidth = 200,
outerWidth = 0,
outerHeight = 0,
@vicapow
vicapow / index.js
Created March 1, 2015 10:59
non-recursive array flattening
var a = [1, 2, [2], [1, 2, [3, 4, [5]]], [[4, 5], 3, 2, 1], [1]];
function flatten(array) {
var stack = [];
var out = [];
var tail;
stack.push({array: array, idx: 0});
while(stack.length) {
tail = stack[stack.length - 1];
if (tail.idx >= tail.array.length) {
@vicapow
vicapow / react+d3-boilerplate.js
Created February 16, 2015 20:51
React + D3 boilerplate
var D3ReactTemplate = React.createClass({
sel: function() { return d3.select(this.getDOMNode()) },
getDefaultProps: function() {
return {
valueAccessor: function(d) { return d.value },
width: 400,
height: 400
}
},
getInitialState: function() {