The idea of using gists for blogging sounds interesting. They can be searched like this for a user's blog gists. #blog
should be appended to the title of the gist for it to show up in the search result.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func sample_usage() { | |
digits := "0123456789abcdefghijklmnopqrstuvwxyz" // base 36 | |
var num int64 = 9876543210 | |
fmt.Printf("input number is %d\n", num) | |
e := encode(num, digits) | |
fmt.Printf("encoded as %v\n", e) | |
d := decode(e, digits) | |
fmt.Printf("decoded as %v\n", d) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(server1). | |
-export([start/2, rpc/2]). | |
start(Name, Mod) -> | |
register(Name, spawn(fun() -> loop(Name, Mod, Mod:init()) end)). | |
rpc(Name, Request) -> | |
Name ! {self(), Request}, | |
receive | |
{Name, Response} -> Response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(name_server). | |
-export([init/0, add/2, find/1, handle/2]). | |
-import(server1, [rpc/2]). | |
%% client routines | |
add(Name, Place) -> rpc(name_server, {add, Name, Place}). | |
find(Name) -> rpc(name_server, {find, Name}). | |
%% callback routines | |
init() -> dict:new(). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(server2). | |
-export([start/2, rpc/2]). | |
start(Name, Mod) -> | |
register(Name, spawn(fun() -> loop(Name,Mod,Mod:init()) end)). | |
rpc(Name, Request) -> | |
Name ! {self(), Request}, | |
receive | |
{Name, crash} -> exit(rpc); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(server3). | |
-export([start/2, rpc/2, swap_code/2]). | |
start(Name, Mod) -> | |
register(Name, | |
spawn(fun() -> loop(Name,Mod,Mod:init()) end)). | |
swap_code(Name, Mod) -> rpc(Name, {swap_code, Mod}). | |
rpc(Name, Request) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(name_server1). | |
-export([init/0, add/2, find/1, handle/2]). | |
-import(server3, [rpc/2]). | |
%% client routines | |
add(Name, Place) -> rpc(name_server, {add, Name, Place}). | |
find(Name) -> rpc(name_server, {find, Name}). | |
%% callback routines | |
init() -> dict:new(). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(server4). | |
-export([start/2, rpc/2, swap_code/2]). | |
start(Name, Mod) -> | |
register(Name, spawn(fun() -> loop(Name,Mod,Mod:init()) end)). | |
swap_code(Name, Mod) -> rpc(Name, {swap_code, Mod}). | |
rpc(Name, Request) -> | |
Name ! {self(), Request}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule PersianCalendar do | |
@moduledoc """ | |
for converting persian calendar to/from gregorian calendar | |
""" | |
@breaks [ | |
-61, | |
9, | |
38, | |
199, |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer