Skip to content

Instantly share code, notes, and snippets.

@PetrSnobelt
PetrSnobelt / gol.js
Created November 13, 2015 15:11
Javascript ES5 GOL
function flat(arr){
return [].concat.apply([], arr);
}
//can be created by simple array
function nearNeighbours() {
var all = [-1, 0, 1].map(function (y) {
return [-1, 0, 1].map(function (x) {
return [(x), (y)];
});
@PetrSnobelt
PetrSnobelt / gol_es6.js
Last active November 14, 2015 15:51
Game of Life in pure ES6 in 40 loc
"use strict";
const near = [[-1,-1], [0,-1], [1,-1],
[-1, 0], [1, 0],
[-1, 1], [0, 1], [1, 1]];
const neighbours = (p) =>
near.map(i => [ (p[0] + i[0]), (p[1] + i[1]) ]);
var contain = (p, neig) =>
@PetrSnobelt
PetrSnobelt / fpr_resources.txt
Last active April 7, 2016 14:38
FPR sources
Rx Training Games learn and practice Reactive Extensions coding grid-based games
http://moumne.com/rx-training-games/
Learning FP the hard way: Experiences on the Elm language
https://gist.github.com/ohanhi/0d3d83cf3f0d7bbea9db
Reactive Programming at Cloud-Scale and Beyond [video]
http://www.infoq.com/presentations/reactive-cloud-scale
cyclejs
Resources
https://github.com/jaredly/rxvision - visualize rx
Pro získávání dat ze serveru
https://www.npmjs.com/package/observable-event-source
test sample
https://github.com/Reactive-Extensions/RxJS/blob/master/src/modular/test/buffercount.js
@PetrSnobelt
PetrSnobelt / gol_es6_2.js
Last active May 30, 2016 13:40
Game of Life in pure ES6 in 30 loc
const near = [[-1,-1], [0, -1], [1, -1],
[-1, 0], [1, 0],
[-1, 1], [0, 1], [1, 1]];
const neighbours = ([x, y]) =>
near.map(([nx,ny]) => [x + nx, y + ny])
//maybe using Symbol can help
Array.prototype.hash = function() {return this.join(',')}
const t = require("tcomb");
// imstruct is a tcomb type builder that internally builds an
// Immutable.Record object, but applies tcomb's type system to it
const imstruct = require("../util/imstruct");
const Person = imstruct({
name: t.String,
age: t.Number
});
@PetrSnobelt
PetrSnobelt / idle.js
Last active June 7, 2016 22:10
Get idle time from winapi
"use strict";
//based on https://github.com/electron/electron/issues/1528
const ref = require('ref');
const refStruct = require('ref-struct');
const refArray = require('ref-array');
//const ffi = require('ffi-atom-shell'); //failed to install
const ffi = require('ffi');
@PetrSnobelt
PetrSnobelt / rss.xml
Created March 11, 2017 17:11
Sample Media Rss File
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title>Some Bands I Like</title>
<link>http://www.andyvolk.com/webmonkey/bands/</link>
<description>A list of some bands I like
(or have been a member of).</description>
<item>
<title>Rocking Webmonkey Garage Band</title>
<link>http://www.webmonkey.com/ourband.html</link>
<description>The best ever garage band on the Internet.</description>
@PetrSnobelt
PetrSnobelt / react-components.txt
Last active November 7, 2018 20:43
Nice react components
State
=====
Redux
Redux-Observables
Mobx
https://github.com/infinum/mobx-jsonapi-store
functional setState
xState
https://github.com/davidkpiano/xstate