Skip to content

Instantly share code, notes, and snippets.

View eiriklv's full-sized avatar

Eirik L. Vullum eiriklv

View GitHub Profile
@Avaq
Avaq / combinators.js
Last active May 1, 2024 09:38
Common combinators in JavaScript
const I = x => x
const K = x => y => x
const A = f => x => f (x)
const T = x => f => f (x)
const W = f => x => f (x) (x)
const C = f => y => x => f (x) (y)
const B = f => g => x => f (g (x))
const S = f => g => x => f (x) (g (x))
const S_ = f => g => x => f (g (x)) (x)
const S2 = f => g => h => x => f (g (x)) (h (x))
function* runTimer(getState) {
while(yield take('START')) {
while(true) {
const {stop, tick} = yield race({
stop : take('STOP'),
tick : call(wait, ONE_SECOND);
})
if ( !stop ) {
yield put(actions.tick());
// devDependencies in package.json:
"require-reload": "0.2.2",
"react-transform-hmr-no-accept": "1.0.1", // not published, get it here: https://github.com/brandonbloom/react-transform-hmr
// in babelrc:
"env": {
"development": {
"plugins": [
@marick
marick / about_those_lava_lamps.md
Last active June 22, 2022 21:08
About Those Lava Lamps

Around 2006-2007, it was a bit of a fashion to hook lava lamps up to the build server. Normally, the green lava lamp would be on, but if the build failed, it would turn off and the red lava lamp would turn on.

By coincidence, I've actually met, about that time, (probably) the first person to hook up a lava lamp to a build server. It was Alberto Savoia, who'd founded a testing tools company (that did some very interesting things around generative testing that have basically never been noticed). Alberto had noticed that people did not react with any urgency when the build broke. They'd check in broken code and go off to something else, only reacting to the breakage they'd caused when some other programmer pulled the change and had problems.

@brentvatne
brentvatne / contest.md
Last active February 18, 2024 21:08
React.js Conf Contest

React.js Conf tickets, everyone wants them but we only have space for 400 people, and that includes speakers, organizers and everyone’s proud parents and grandparents! If you are into speaking and have time before December 13th, you should submit a 30 minute talk or 5 minute lightning talk proposal. If you’re more into writing than speaking or coding, ReactJSNews is giving away 1 ticket for the best blog post submission. But you probably like programming, so React Native Newsletter & Exponent are giving away two tickets for the best React Native apps made with Exponent! Of course, if you like speaking, writing and programming you should do all of the above.

Details of the contest

  • You make an “app” and publish it to Exponent. You don’t have to open source it, but people
@scottwrobinson
scottwrobinson / brain-mnist.js
Created December 7, 2015 15:22
Brain.js example for training and testing on MNIST data
var brain = require('brain');
var fs = require('fs');
var getMnistData = function(content) {
var lines = content.toString().split('\n');
var data = [];
for (var i = 0; i < lines.length; i++) {
var input = lines[i].split(',').map(Number);
@alexanderGugel
alexanderGugel / ied-0.1.0
Created November 16, 2015 23:24
ied-0.1.0 vs npm-2.14.7 vs npm-3.4.0
.
├── node_modules
│   ├── 00963d697b2adf0c185c4e04e73174ba9b288eb2
│   │   ├── node_modules
│   │   │   └── xml-escape -> ../../00963d697b2adf0c185c4e04e73174ba9b288eb2/package
│   │   └── package
│   │   ├── LICENSE
│   │   ├── README.md
│   │   ├── index.js
│   │   ├── package.json

@kangax's ES6 quiz, explained

@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).

Here we go with the explanations:

Question 1:
(function(x, f = () =&gt; x) {
@davideast
davideast / SyncPath.js
Last active April 20, 2021 17:19
Firebase Social Network Client Fanout
export class SyncPath {
constructor(rootRef, path) {
this._rootRef = rootRef;
this.user = this._rootRef.getAuth();
this._userDataRef = this._rootRef.child(path).child(this.user.uid);
this.data = {};
this._userDataRef.on('value', (snap) => this.data = snap.val() || {});
}
keys() {
return Object.keys(this.data);
@gaearon
gaearon / slim-redux.js
Last active May 5, 2024 15:14
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {