Skip to content

Instantly share code, notes, and snippets.

View kaosat-dev's full-sized avatar

Mark Moissette kaosat-dev

View GitHub Profile
@kaosat-dev
kaosat-dev / main.js
Created March 6, 2016 09:43 — forked from staltz/main.js
Cycle.js demo with MIDI and Web Audio
import {Observable, Disposable} from 'rx';
import {run} from '@cycle/core'
const jsondiffpatch = require('jsondiffpatch').create({
objectHash: function(obj) {
return obj.name;
}
});
function generateCurve(steps){
var curve = new Float32Array(steps)
@kaosat-dev
kaosat-dev / limitFlow.js
Created October 17, 2016 19:44 — forked from axefrog/limitFlow.js
Flow control limiter for most.js. Unlike `throttle`, which drops events indiscriminately, `limitFlow` retains the most recent event and ensures that it is emitted when the specified period elapses.
// Limit the rate of flow to an event every 250ms:
// const stream$ = other$.thru(limitFlow(250));
export function limitFlow(period) {
return function limitFlow(stream) {
const source = new RateLimitSource(stream.source, period);
return new stream.constructor(source);
};
}
@kaosat-dev
kaosat-dev / svg-to-png.js
Created October 29, 2016 09:25 — forked from caged/svg-to-png.js
Convert SVG's to PNGs. This works OK if the SVG's styles are inline. The SVG element must contain an xmlns attribute. Webkit also requires you specify a font size on `text` elements.
var svg = document.getElementById('graph'),
xml = new XMLSerializer().serializeToString(svg),
data = "data:image/svg+xml;base64," + btoa(xml),
img = new Image()
img.setAttribute('src', data)
document.body.appendChild(img)

update object

var state = {
    id: 1,
    points: 100,
    name: "Goran"
};

var newState = {
@kaosat-dev
kaosat-dev / cycle-state-ramda.md
Created February 18, 2017 13:48 — forked from wclr/cycle-state-ramda.md
A way to handle state in cycle.js

A way to handle state in cycle.js

Simple state management with xstream and ramda, in more transparent fashion than onionify

import * as R from 'ramda'

// first we create factory for making special state stream 
// that will hold our stream value and will be modified with supplied streams of reducers
type StateReducer<T> = (state: T) => T
@kaosat-dev
kaosat-dev / git-serve.md
Created February 24, 2017 07:13 — forked from datagrok/git-serve.md
How to easily launch a temporary one-off git server from any local repository, to enable a peer-to-peer git workflow.

Launch a one-off git server from any local repository.

I [tweeted this already][1] but I thought it could use some expansion:

Enable decentralized git workflow: git config alias.serve "daemon --verbose --export-all --base-path=.git --reuseaddr --strict-paths .git/"

Say you use a git workflow that involves working with a core "official" repository that you pull and push your changes from and into. I'm sure many companies do this, as do many users of git hosting services like Github.

Say that server, or Github, goes down for a bit.

@kaosat-dev
kaosat-dev / railway_oriented_programming.js
Created March 9, 2017 12:40 — forked from volodymyrprokopyuk/railway_oriented_programming.js
Railway Oriented Programming (JavaScript)
var _ = require('lodash');
var Success = function(success) { this.success = success; };
var Failure = function(failure) { this.failure = failure; };
var bindAll = function(fs) {
var bind = function(res, f) {
return res instanceof Success ? f(res.success) : res;
};
var bindF = function(f) { return _.partial(bind, _, f); };
@kaosat-dev
kaosat-dev / 0-Simple counter: different implementations...
Created March 14, 2017 14:33 — forked from srdjan/100+ different counter apps...
Simple counter: different implementations...
different implementations of the simple counter app... code verbosity vs expressiveness
@kaosat-dev
kaosat-dev / clone-all-twitter-github-repos.sh
Created March 29, 2017 10:09 — forked from caniszczyk/clone-all-twitter-github-repos.sh
Clone all repos from a GitHub organization
curl -s https://api.github.com/orgs/twitter/repos?per_page=200 | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}'
@kaosat-dev
kaosat-dev / commonjs-to-es6-modules.js
Created April 20, 2017 09:16 — forked from wegry/commonjs-to-es6-modules.js
purescript psc 0.9 output webpack loader that allows tree shaking
"use strict"
/*
* Webpack 2 loader that can take CommonJS output by psc 0.9.1 and convert
* it into tree shakable ES6 modules. No transpiling required.
*/
const fs = require('fs')
const commonJsRequire = /var ([$\w]+) = require\("(.*)"\)/g
const moduleExports = /module\.exports = \{(\n( ([$\w]+): ([$\w]+)(, )?\n)*)?\};/m