Skip to content

Instantly share code, notes, and snippets.

@jurStv
jurStv / composition_vs_chain.js
Last active April 17, 2017 05:46
From Functional Programming in Javascript book
/*
Here are five different implementations of the same floorSqrt()
functional composition.
They seem to be identical, but they deserve scrutiny.
But there are a few key differences we should go over:
Obviously the first method is verbose and inefficient.
The second method is a nice one-liner, but this approach becomes very unreadable
after only a few functions are applied.
The third approach is a chain of array functions, notably the map function. This works
fairly well, but it is not mathematically correct.
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
@jurStv
jurStv / adressForm.js
Created September 13, 2015 23:16
The event handler detached in adressForm.js Do not pay attention to Validator instances, it's just for filtering table-items and checking valid.
import {Rx} from "@cycle/core";
import {h} from '@cycle/dom';
import Validator from "../form-validator";
import cuid from "cuid";
let formValidator = new Validator({
name: /^\S+/,
lastname:/^\S+/,
email:/^\S+@\S+\.\S+/
});
@jurStv
jurStv / autopgsqlbackup
Created February 8, 2016 08:38 — forked from matthewlehner/autopgsqlbackup
Auto PostgreSQL backup script.
#!/bin/bash
#
# PostgreSQL Backup Script Ver 1.0
# http://autopgsqlbackup.frozenpc.net
# Copyright (c) 2005 Aaron Axelsen <[email protected]>
#
# This script is based of the AutoMySQLBackup Script Ver 2.2
# It can be found at http://sourceforge.net/projects/automysqlbackup/
#
# The PostgreSQL changes are based on a patch agaisnt AutoMySQLBackup 1.9

Folder Structure

Motivations

  • Clear feature ownership
  • Module usage predictibility (refactoring, maintainence, you know what's shared, what's not, prevents accidental regressions, avoids huge directories of not-actually-reusable modules, etc)
@jurStv
jurStv / README.md
Created June 11, 2016 08:09 — forked from rgrove/README.md
Cake's approach to React Router server rendering w/code splitting and Redux

Can't share the complete code because the app's closed source and still in stealth mode, but here's how I'm using React Router and Redux in a large app with server rendering and code splitting on routes.

Server

  1. Wildcard Express route configures a Redux store for each request and makes an addReducers() callback available to the getComponents() method of each React Router route. Each route is responsible for adding any Redux reducers it needs when it's loaded. (This isn't really necessary on the
@jurStv
jurStv / sonic-pi-tutorial.md
Last active March 16, 2022 21:44 — forked from jwinder/sonic-pi-tutorial.md
Sonic Pi tutorials concatenated

1 Welcome to Sonic Pi

Welcome friend :-)

Welcome to Sonic Pi. Hopefully you're as excited to get started making crazy sounds as I am to show you. It's going to be a really fun ride where you'll learn all about music, synthesis, programming, composition, performance and more.

But wait, how rude of me! Let me introduce myself - I'm

/*! jQuery.Flipster, v1.1.1 (built 2016-03-03) */
!function(a,b,c){"use strict";function d(a,b){var c=null;return function(){var d=this,e=arguments;null===c&&(c=setTimeout(function(){a.apply(d,e),c=null},b))}}var e=function(){var a={};return function(b){if(a[b]!==c)return a[b];var d=document.createElement("div"),e=d.style,f=b.charAt(0).toUpperCase()+b.slice(1),g=["webkit","moz","ms","o"],h=(b+" "+g.join(f+" ")+f).split(" ");for(var i in h)if(h[i]in e)return a[b]=h[i];return a[b]=!1}}(),f="http://www.w3.org/2000/svg",g=function(){var a;return function(){if(a!==c)return a;var b=document.createElement("div");return b.innerHTML="<svg/>",a=b.firstChild&&b.firstChild.namespaceURI===f}}(),h=a(b),i=e("transform"),j={itemContainer:"ul",itemSelector:"li",start:"center",fadeIn:400,loop:!1,autoplay:!1,pauseOnHover:!0,style:"coverflow",spacing:-.6,click:!0,keyboard:!0,scrollwheel:!0,touch:!0,nav:!1,buttons:!1,buttonPrev:"Previous",buttonNext:"Next",onItemSwitch:!1},k={main:"flipster",active:"flipster--active",container:"f
@jurStv
jurStv / pr.md
Created July 18, 2017 20:30 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@jurStv
jurStv / rxjs_operators_by_example.md
Created July 22, 2017 14:00 — forked from btroncone/rxjs_operators_by_example.md
RxJS 5 Operators By Example