Skip to content

Instantly share code, notes, and snippets.

View yefremov's full-sized avatar

Jeff yefremov

  • Riga, Latvia
View GitHub Profile
@yefremov
yefremov / LICENSE.txt
Created November 6, 2011 13:53 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@yefremov
yefremov / stateful.js
Created September 14, 2013 12:46 — forked from foca/stateful.js
// Stateful is a simple implementation of the state pattern for javascript.
//
// Read more on this design pattern here:
// -> http://sourcemaking.com/design_patterns/state
//
// Initialize Stateful by passing it an object, the name of the initial state
// (defaults to "default"), and an optional hash of interfaces that will be
// applied for each state. If these interfaces are not passed, they default to
// the object's constructor's States property. So, for example:
//
@yefremov
yefremov / introrx.md
Created February 29, 2016 13:51 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
var now =
typeof performance !== 'undefined' &&
typeof performance.now === 'function' ?
function () {
return performance.now();
} :
typeof Date.now === 'function' ?
function () {
return Date.now();
} :
@yefremov
yefremov / createClass.js
Created December 3, 2016 23:01
Implements class factory.
/**
* Creates a new class with the given field names as arguments and
* properties. Allows `instanceof` checks with returned constructor.
*/
var createClass = function () {
var length = arguments.length;
var args = new Array(length);
var i;
@yefremov
yefremov / index.html
Last active January 21, 2017 18:49
React and Redux
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Gist</title>
</head>
<body>
<div id="app"></div>
var waiting = [];
var waitingID;
var callWaiting = function () {
var funcs = waiting;
waiting = [];
waitingID = 0;
while(funcs.length) {
var noop = function () {};
var once = function (func) {
return function () {
if (func === null) {
return;
}
var callFunc = func;
var hasOwn = Object.prototype.hasOwnProperty;
var extend = function () {
var target = {};
var i;
for (i = 0; i < arguments.length; i++) {
var source = arguments[i];
var prop;
@yefremov
yefremov / codingame-thor-puzzle.js
Last active January 27, 2017 16:00
CodinGame Power of Thor
/**
* Solve this puzzle by writing the shortest code.
* Whitespaces (spaces, new lines, tabs...) are counted in the total amount of chars.
* These comments should be burnt after reading!
**/
var inputs = readline().split(' ');
var LX = parseInt(inputs[0]); // the X position of the light of power
var LY = parseInt(inputs[1]); // the Y position of the light of power