A command line script to retrieve json for all of your gists.
github.sh [username] [password] [total number of gists] [oath or user:password]| 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); } | |
| }); | |
| }); | |
| } |
Thanks to this article by Christoph Berg
Directories and files
~/| # 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) |
| %%%------------------------------------------------------------------- | |
| %%% @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). |
| (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> |
A state machine is defined as follows:
Input - a set of inputsOutput - a set of outputsState - a set of statesS0 ∈ S - an initial stateT : Input * State -> Output * State - a transition functionIf 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:
| // 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 |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| type Monoid<'a> = { | |
| unit : 'a | |
| op : 'a -> 'a -> 'a | |
| } | |
| let endo<'a> = | |
| { unit = id | |
| op = fun (f:'a -> 'a) (g:'a -> 'a) -> f << g } | |