Skip to content

Instantly share code, notes, and snippets.

Avatar

Radek Stepan radekstepan

View GitHub Profile
View find-rabbit.js
// https://youtu.be/XEt09iK8IXs?t=1258
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);
View secret.sh
export SYSTEM_SECRET=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
echo "SYSTEM_SECRET is $SYSTEM_SECRET"
@radekstepan
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
/node_modules
*.log
.DS_Store
@radekstepan
radekstepan / app.jsx
Created March 29, 2016 01:55
rangle-react
View app.jsx
// Don't forget the imports.
import React from 'react';
import ReactDOM from 'react-dom';
const JSON_URL = "https://api.example.io/comments.json";
class Store {
constructor(data) {
this.data = data;
@radekstepan
radekstepan / .gitignore
Last active March 26, 2016 23:52
array-flatten
View .gitignore
/node_modules
*.log
.DS_Store
@radekstepan
radekstepan / .gitignore
Last active March 4, 2016 09:25
Merge two sorted arrays into a sorted array of unique values from both
View .gitignore
/node_modules
*.log
.DS_Store
@radekstepan
radekstepan / issues.md
Last active August 29, 2015 14:08
Issues with Ractive
View issues.md

#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 parent.name 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
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
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 https://www.duolingo.com/practice
// @version 1.0
// ==/UserScript==
window.addEventListener('load', function() {
$(document).keypress(function(evt) {
if (evt.keyCode == 13) {