Skip to content

Instantly share code, notes, and snippets.

View bjoerge's full-sized avatar

Bjørge Næss bjoerge

View GitHub Profile
@bjoerge
bjoerge / .gitignore
Last active March 14, 2017 12:07
gen-hotspot-styles
node_modules
[
{
"op": "replace",
"path": [
"nodes",
"0",
"nodes",
"0",
"characters",
"8",
@bjoerge
bjoerge / replayer.js
Created March 16, 2016 16:20
Emit values of an array over time
export default function replayer(array, opts = {}, emit) {
let idx = 0
let timer
return {
start: next,
stop: stop,
reset: reset
}
@bjoerge
bjoerge / syncUrl.js
Last active January 31, 2016 15:00
An require('url') replacement which keeps its properties in sync and supports a custom query parser/stringifier
import url from 'url'
export default Object.assign(configure(), configure)
function configure({qsImpl} = {}) {
return {
parse(urlToParse) {
return Object.assign(createUrlObject({qsImpl}), {
href: urlToParse
})
@bjoerge
bjoerge / README.md
Last active January 13, 2016 15:41
Minimalistic pubsub

Minimalistic pubsub

function pubsubber() {
  const subscribers = []
  return {
    subscribe,
    once,
    publish
 }
@bjoerge
bjoerge / .gitignore
Last active October 13, 2015 10:12
heidrun-logger
.DS_Store
npm-debug.log
node_modules
@bjoerge
bjoerge / skip-single-keys.js
Created April 29, 2015 14:11
Recursively skip keys with no siblings
const assert = require("assert");
function skipSingleKeys(obj) {
if (obj === null || typeof obj !== 'object') {
return obj;
}
const keys = Object.keys(obj);
if (keys.length == 1) {
return skipSingleKeys(obj[keys[0]]);
}
@bjoerge
bjoerge / parse.js
Created March 26, 2015 19:14
Parse CSV into objects with RxJS
const Rx = require('rx');
const csv = require('csv-parse');
const fs = require('fs');
Rx.Node.fromReadableStream(fs.createReadStream('file.csv').pipe(csv()))
.skip(1)
.withLatestFrom(rows.take(1), (row, header) => {
// Map header[i] => row[i]
return row.reduce((rowObj, cell, i) => {
rowObj[header[i]] = cell;
.playerContainer {
position: relative;
}
.playerContainer object {
height: 100%;
left: 0;
top: 0;
position: absolute;
width: 100%;
@bjoerge
bjoerge / index.js
Created January 27, 2015 18:59
requirebin sketch
var concat = require('concat-stream');
function parseCSV(file) {
var parser = csvParse({
delimiter: ',',
auto_parse: true,
columns: true
});
return new Promise(function(resolve, reject) {