Skip to content

Instantly share code, notes, and snippets.

View turboMaCk's full-sized avatar
🏠
Working from home

Marek Fajkus turboMaCk

🏠
Working from home
View GitHub Profile
@turboMaCk
turboMaCk / rounded-rect.html
Last active August 15, 2016 15:51
d3 rounded rect function
<!doctype html>
<html>
<body>
<svg></svg>
</body>
</html>
@turboMaCk
turboMaCk / hints.elm
Last active September 13, 2016 08:59
Hits for wojcek
import Html exposing (..)
import List exposing (..)
multiSnd : number -> (List (a, number) -> List (a, number))
multiSnd k =
map (\(a, b) -> (a, b*k))
multiSnd3 = multiSnd 3
multiSnd4 = multiSnd 4
@turboMaCk
turboMaCk / func.erl
Created October 13, 2016 11:29
Erlang recursion examples
-module(func).
-export([fac/1, ft/1, len/1, lt/1, fib/1, tail_fib/1]).
%% basic recursive implementation of factorial
fac(N) when N == 0 -> 1;
fac(N) when N > 0 ->
N*fac(N-1).
%% Tal recursion implementation
@turboMaCk
turboMaCk / func.erl
Last active October 13, 2016 11:36
Erlang recursion examples
-module(func).
-export([fac/1, ft/1, len/1, lt/1, fib/1, tail_fib/1]).
%% basic recursive implementation of factorial
fac(N) when N == 0 -> 1;
fac(N) when N > 0 ->
N*fac(N-1).
%% Tail recursion implementation of factorial
@turboMaCk
turboMaCk / currying.js
Last active November 16, 2016 00:22
Currying vs partial application vs factory
/**
Example is using Heron's formula for calculating area of triangle
more info: https://en.wikipedia.org/wiki/Heron%27s_formula
*/
// Given a function of type f: (X x Y x Z) -> N,
// currying produces f: X -> (Y -> (Z -> N))
// Num -> (Num -> (Num -> Num))
@turboMaCk
turboMaCk / brew_reinstall_all.sh
Last active February 14, 2017 17:44
Reinstall all home brew packages
#!/bin/bash
# Reinstall all brew packages and dependencies in the correct order
# - list all installed packages
# - print the package followed by its dependencies
# - print the package and a single depenency on each line
# - perform a topographical sort
# - print out each package in the correct order on a single line
# - pass to brew reinstall
brew list \
Verifying that "turbo_mack.id" is my Blockstack ID. https://onename.com/turbo_mack
@turboMaCk
turboMaCk / main.rs
Last active November 30, 2017 11:58
Simple rust program which deals with file reads in 3 different ways
// This program will read test.txt file and print it line by line
// implemented in 3 different ways
use std::io::BufReader;
use std::io::BufRead;
use std::fs::File;
fn main() {
// Procedural
@turboMaCk
turboMaCk / Main.elm
Last active April 15, 2020 10:20
Elm tail call optimization
module Main exposing (main)
import Html
sumFromZero : Int -> Int
sumFromZero n =
sumFromZeroTail 0 n
sumFromZeroTail : Int -> Int -> Int
sumFromZeroTail acc n =
module ContextView exposing (ContextItem, container, item)
import Html exposing (Html, Attribute)
import Html.Attributes as Attrs
type ContextItem = ContextItem
container : List (Attribute msg) -> (ContextItem -> List (Html msg)) -> Html msg
container attrs inner =
Html.div (Attrs.class "some-required-context-thing" :: attrs) <|