Skip to content

Instantly share code, notes, and snippets.

View radekstepan's full-sized avatar

Radek Stepan radekstepan

View GitHub Profile
View find-rabbit.js
let t = 0; // try counter
const s = 10; // search space size
let r = Math.floor(Math.random() * s); // rabbit
// Take a guess.
const guess = g => {
t += 1;
console.log('Try', t, 'in', g, 'rabbit in', r);
export SYSTEM_SECRET=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
radekstepan / .gitignore
Last active March 29, 2016 02:29
Implement a function `pipe()` that takes several functions as arguments and returns a new function that will pass its argument to the first function, then pass the result to the second, then pass the result of the second to the third, and so on, finally returning the output of the last function. In other words, calling `pipe(foo, bar, baz)(1, 2,…
View .gitignore
radekstepan / app.jsx
Created March 29, 2016 01:55
View app.jsx
// Don't forget the imports.
import React from 'react';
import ReactDOM from 'react-dom';
const JSON_URL = "";
class Store {
constructor(data) { = data;
radekstepan / .gitignore
Last active March 26, 2016 23:52
View .gitignore
radekstepan / .gitignore
Last active March 4, 2016 09:25
Merge two sorted arrays into a sorted array of unique values from both
View .gitignore
radekstepan /
Last active August 29, 2015 14:08
Issues with Ractive

#Issues with Ractive

  • multiple transitions of the same component would not clear listeners leading to zombies in memory and ultimate browser crash; fixed in 0.6.0
  • events like tap do not work together with adapters like ractive-ractive because one uses dependencies and one uses peerDependencies
  • deeply nested POJO saved as a map with set triggers a change even if nothing has changed
  • ractive-ractive does not update parent model if we have passed in its subset like instead of parent; the data gets changed but no update event gets fired
  • setting a key to [] (resetting an array) has won't clear the array items from memory if they were linked to components, a while loop on all the items in the array and their subsequent pop works
  • an error in a component fails silently killing with it some part of the template logic
  • does not handle tags in templates that seem unclosed because they are closed in an if condition
  • have to do this `listing="{{ { 'ID': ID
radekstepan / events.js
Created October 20, 2014 16:01
Listening to events in Ractive
View events.js
var test = require('tape');
var Ractive = require('ractive');
var _ = require('lodash');
var mediator = require('../src/js/app/modules/mediator.js');
test('mediator subscriptions get cancelled', function(t) {
var called = 0;
radekstepan / gist:b3b4dad29e97f589928e
Created October 14, 2014 16:33
Edmonton communities and their locations
View gist:b3b4dad29e97f589928e
"data": [
"name": "Abbottsfield, Edmonton",
"type": "community",
"number": 2010,
"socrata_id": "q9gm-x3wv",
"lat": 53.5737301566926,
"lon": -113.38966126012794,
"zoom": 13
View duoskipper.js
// ==UserScript==
// @name DuoSkipper
// @description Skip test questions on Duolingo by pressing Enter.
// @include
// @version 1.0
// ==/UserScript==
window.addEventListener('load', function() {
$(document).keypress(function(evt) {
if (evt.keyCode == 13) {