Skip to content

Instantly share code, notes, and snippets.

import Rx from 'rxjs';
export const once = (fn, context) => {
let result;
return function() {
if (fn) {
result = fn.apply(context || this, arguments);
fn = null;
}
@fricze
fricze / compose.js
Created March 21, 2014 11:52
Neat JS compose
var reverseCall = function (argument, func) {
return func(argument);
};
var compose = function (funcs) {
return function (argument) {
return funcs.reduce(reverseCall, argument);
};
};
@fricze
fricze / Pierwsza własna funkcja
Created December 4, 2013 16:48
Clojure: tworzymy pierwszą funkcję
; write function which counts creature names
#_(...)
; store result in vector
#_(...)
; rewrite function to return quantity of names and age of creature
#_(...)
@fricze
fricze / gist:7790908
Last active December 30, 2015 06:39
Clojure: wykonujemy operacje na jamniczku, jamniczek poznaje Jadzię. Tworzymy pierwszą funkcję, poprawiamy konstrukcję funkcji, poznajemy destructuring
; and now, we gonna write first function
(defn is-dragon? ; name ?
"Function which takes a creature,
and check if this creature is dragon" ; doc
[creature] ; args
(if (= "dragon" (:species creature)) ; body
true
false))
@fricze
fricze / Jamniczek i struktury danych
Last active December 30, 2015 06:39
Clojure: tworzymy Jamniczka, poznajemy struktury danych
(def zenek
{:names ["Zenek" "Miażdżyciel gnatów" "Długouchy leń"]
:species "dachshund"
:age 109
:health :good})
; let's decompose this shit!
(def zenek-names
["Zenek" "Miażdżyciel gnatów" "Długouchy leń"]) ; wektory — zbiory o określonej kolejności
@fricze
fricze / Start with Clojure
Last active December 30, 2015 06:29
Clojure: [formy wyrażenia] notacja polska, komentarze
(+ 100 45) ; składnia jest banalnie, cudownie prosta:
; najpierw funkcja, potem argumenty, wszystko ujęte w nawiasy.
(vector 1 3 4 65 7) ; Wszystko co jest ujęte w nawiasy nazywamy formą (lub wyrażeniem)
(+ 1 2 3 4 5) ; dodawanie jest funkcją mogącą przyjąć nieskończoną liczbę argumentów
(/ 10 5)
(/ 5 6) ; Clojure ma specjalny typ liczbowy dla ułamków, po co?
(def x (/ 5 6)) ; definiowanie wartości
(float x)
(* 5 (+ 4 3)) ; zagnieżdżanie form
(defn dragon? [creature]
(if (= "dragon" (:species creature))
true
false))
@fricze
fricze / base.css
Last active December 29, 2015 08:49
html {
font-size:100%;
}
body {
color:#333;
line-height:1.56;
}
h1, h2, h3, h4 {
font-size:1rem;
font-weight:400;
@fricze
fricze / index.htm
Created November 25, 2013 17:03
„Na procesorach rozpierdol”—typografia vol.1, materiały początkowe HTML
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<itle>Podstawka do HTML</itle>
<link rel="stylesheet" type="text/css" href="base.css">
</head>
<body>
<section class="content">
@fricze
fricze / base.css
Created November 25, 2013 16:53
„Na procesorach rozpierdol”—typografia vol.1, materiały początkowe
// ustalamy rozmiar tekstu bazowego
html {
font-size:100%;
}
body {
color:#333; // ustalamy kolor tekstu, dlaczego nie «black», dlaczego nie «#000»
line-height:1.56; // interlinia, odległość od jednego wiersza tekstu do drugiego
}
// zerujemy tytuły
h1, h2, h3, h4 {