Skip to content

Instantly share code, notes, and snippets.

@hrwgc
hrwgc / README.md
Last active April 26, 2025 15:28
download all of your gists from gist.github.com

gist list

A command line script to retrieve json for all of your gists.

usage:

github.sh [username] [password] [total number of gists] [oath or user:password]
@katowulf
katowulf / firebase_copy.js
Last active July 29, 2022 15:58
Move or copy a Firebase path to a new location
function copyFbRecord(oldRef, newRef) {
oldRef.once('value', function(snap) {
newRef.set( snap.value(), function(error) {
if( error && typeof(console) !== 'undefined' && console.error ) { console.error(error); }
});
});
}
@miguelmota
miguelmota / README.md
Last active June 5, 2025 11:23
Multiple accounts with Mutt E-Mail Client (gmail example)

How to set up multiple accounts with Mutt E-mail Client

Thanks to this article by Christoph Berg

Instructions

Directories and files

~/
@asaaki
asaaki / currying.ex
Last active March 30, 2017 23:49
Partial Functions / Currying
# Another example for: http://onor.io/2014/03/31/partial-function-application-in-elixir/
defmodule PartFuncs do
defp addfun(x, y), do: x + y
# return a partially applied function
def add(a), do: &addfun(a, &1)
# could also easily be written as: addfun(a, b)
def add(a, b), do: (&addfun/2).(a, b)
@romulojales
romulojales / e2c4.erl
Last active August 29, 2015 14:00
Exercises from "Programming Erlang: Software for a Concurrent world."
%%%-------------------------------------------------------------------
%%% @author romulo.jales
%%% @copyright (C) 2014, <COMPANY>
%%% Exercise 2 chapter 4 "programming erlang: Software for a concurrent world"
%%% The BIF tuple_to_list( T) converts the elements of the tuple T to a list.
%%% Write a function called my_tuple_to_list( T) that does the same thing only not using the BIF that does this.
%%% @end
%%% Created : 23. Apr 2014 1:42 AM
%%%-------------------------------------------------------------------
-module(e2c4).
@dch
dch / sha.erl
Created May 18, 2014 23:33
erlang quick conversion of binary sha hash to printable hex/ascii
(akai@akai)27> Hex=fun(<<Hash:20/big-unsigned-integer-unit:8>>) ->
lists:flatten(io_lib:format("~40.16.0b", [Hash])) end.
#Fun<erl_eval.6.106461118>
(akai@akai)28> Hex(<<200,152,0,191,200,46,208,30,214,227,191,213,64,140,81,39,68,145,247,212>>).
"c89800bfc82ed01ed6e3bfd5408c51274491f7d4"
(akai@akai)29>
@eulerfx
eulerfx / EventMachines.md
Last active December 17, 2025 15:37
The relationship between state machines and event sourcing

A state machine is defined as follows:

  • Input - a set of inputs
  • Output - a set of outputs
  • State - a set of states
  • S0 ∈ S - an initial state
  • T : Input * State -> Output * State - a transition function

If you model your services (aggregates, projections, process managers, sagas, whatever) as state machines, one issue to address is management of State. There must be a mechanism to provide State to the state machine, and to persist resulting State for subsequent retrieval. One way to address this is by storing State is a key-value store. Another way is to use a SQL database. Yet another way is event sourcing. The benefit of even sourcing is that you never need to store State itself. Instead, you rely on the Output of a service to reconstitute state. In order to do that, the state machine transition function needs to be factored into two functions as follows:

@sritchie
sritchie / algebra.swift
Created June 9, 2014 02:57
Typeclasses in Swift
// Playground - noun: a place where people can play
import Cocoa
var str = "Hello, playground"
// Here's take 1. First, I defined the algebra like I would in
// Scala, as separate protocols:
protocol Semigroup {
typealias T
@staltz
staltz / introrx.md
Last active December 26, 2025 17:21
The introduction to Reactive Programming you've been missing
@eulerfx
eulerfx / EventSourcingMonoids.fs
Last active May 17, 2024 15:09
F# event-sourcing with monoids
type Monoid<'a> = {
unit : 'a
op : 'a -> 'a -> 'a
}
let endo<'a> =
{ unit = id
op = fun (f:'a -> 'a) (g:'a -> 'a) -> f << g }