Skip to content

Instantly share code, notes, and snippets.

View kirbysayshi's full-sized avatar

Drew Petersen kirbysayshi

View GitHub Profile
@kirbysayshi
kirbysayshi / index.js
Created March 23, 2015 21:13
flatten an object into a single depth using string keys
require('tap-browser-color')();
var test = require('tape');
test('it flattens!', function(t) {
var input = {
users: [
{ name: 'name1', id: 1, image: { '64x64': 'http://1' } },
{ name: 'name2', id: 2, image: { '64x64': 'http://2' } }
],
errors: [ new Error('err1') ],
@kirbysayshi
kirbysayshi / flatten_and_test.js
Last active May 14, 2019 15:31
flatten an object into a single depth using string keys
require('tap-browser-color')();
var test = require('tape');
test('it flattens!', function(t) {
var input = {
users: [
{ name: 'name1', id: 1, image: { '64x64': 'http://1' } },
{ name: 'name2', id: 2, image: { '64x64': 'http://2' } }
],
errors: [ new Error('err1') ],
@kirbysayshi
kirbysayshi / index.js
Created March 21, 2015 20:11
requirebin sketch
var debug = require('debug')
var lg = debug('vash:TS');
var Parser = require('vash/lib/parser');
var Lexer = require('vash/lib/lexer');
var codegen = require('vash/lib/codegen');
var TypeScript = require('typescript');
console.log('type?', TypeScript)
function compileTS(markup, options) {
@kirbysayshi
kirbysayshi / index.js
Last active August 29, 2015 14:17
requirebin sketch
var cvs = document.querySelector('#cvs');
var ctx = cvs.getContext('2d');
window.addEventListener('resize', resize, false)
function resize(e) {
cvs.width = window.innerWidth;
cvs.height = window.innerHeight;
}
resize();
@kirbysayshi
kirbysayshi / index.js
Created February 17, 2015 10:01
requirebin sketch
var td = require('transducers-js');
var csp = require('csp-ksh');
var chan = csp.chan;
var put = csp.put;
var take = csp.take;
// Create a channel with a buffer of size 2 using a sliding window strategy,
// with a transducer that groups as tuples.
var ch = chan([csp.SLIDING, 2], td.partitionAll(2));
@kirbysayshi
kirbysayshi / index.js
Last active August 29, 2015 14:15
requirebin sketch
localStorage.debug = '';
var debug = require('debug')('csp-ksh');
function kick(ch) {
debug('ch:'+ch.id, 'kick');
if (
!ch.kicked
&& (ch.consumers.length|| ch.producers.length)
) {
debug('ch:'+ch.id, 'kick:run-queued',
@kirbysayshi
kirbysayshi / TaskQueue.js
Created February 15, 2015 04:30
A Task Queue, because sometimes I don't want to learn another API
function TaskQueue(concurrency) {
var _queue = [];
var _concurrents = 0;
var ctr = {
queue: function(fn) {
_queue.push(fn)
},
next: function() {
while (_concurrents < concurrency) {
_concurrents += 1;
@kirbysayshi
kirbysayshi / README.md
Last active August 29, 2015 14:13
Equalizer animation experiments. But why so much CPU and not GPU?

I'm experimenting with the most efficient way (in terms of CPU / battery usage) to make a small equalizer animation that will appear multiple times on a page.

I've tried CSS animations, CSS transitions, canvas drawing, and a plain GIF (and more not listed here!). I'd expect the CSS animations and transitions to be completely GPU powered, but Chrome 39.0.2171.99 on my Macbook Air 10.10 uses large amounts of CPU (shown in both the Chrome Task Manager as well as Activity Monitor). I've set layout boundaries via overflow: hidden, checked paint rects, etc.

Here are the different tests:

Keybase proof

I hereby claim:

  • I am kirbysayshi on github.
  • I am kirbysayshi (https://keybase.io/kirbysayshi) on keybase.
  • I have a public key whose fingerprint is 950B 3198 7DB5 59AE 881F 5A0D E5A1 98CF 0A3D 8B01

To claim this, I am signing this object:

@kirbysayshi
kirbysayshi / index.js
Created September 7, 2014 08:40
requirebin sketch
// just because requirebin needs something to require...?
var vash = require('vash');
var play = document.createElement('input');
play.type = "button";
play.value = "play/pause";
document.body.appendChild(play);
play.onclick = function(e) {
evolve(null, state)