Skip to content

Instantly share code, notes, and snippets.

// WARNING: WORK IN PROGRESS & UNTESTED
//
// @AUTHORS: Gustav Simonsson <gustav@ethdev.com>
// @DATE: 2015-10-30
// @VERSION: 0.1
// @LICENSE: GNUBL 2.0 (https://github.com/Gustav-Simonsson/GNUBL/blob/master/LICENSE)
//
// contract tracking versions added by designated signers.
// designed to track versions of geth (go-ethereum) recommended by the
// go-ethereum team. geth client interfaces with contract through ABI by simply
> eth.getCode(versions.address).length
5956
> eth.getStorageAt(versions.address,0)
"0x0000000000000000000000000000000000000000000000000000000000000002"
> eth.getStorageAt(versions.address,1)
"0x0000000000000000000000000000000000000000000000000000000000000000"
> eth.getStorageAt(versions.address,2)
"0x0000000000000000000000000000000000000000000000000000000000000002"
> eth.getStorageAt(versions.address,3)
"0x0000000000000000000000000000000000000000000000000000000000000000"
> debug.getBlockRlp(443947)
"f90683f90216a03182597a55e06f309d37ffac524d4398d59570a3c02f1e986955745d58b1b72ca0c0ab732e2356ffea1687a6da1e1ed4c359d7b8cadd26246e9ba3e04c349b06f794cefa54c1a83a0ecc31dd4e329e0d4b42869b1eb9a0952b1629b02c743931ac802922ae18c7b24d28eb62b270e635ba12f43cfedca9a0279fff32c31c99103904db217b5b3c1126d04446c7a6928e561ade8ce682b026a0bcd8074b5c072938965a609d806bb30b3d12f5afd8318cf901d418f2cc32a4d8b90100000008000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000100000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000008606074abb65248306c62b832fefd8831b3ddc84562e715896d583010203844765746885676f312e35856c696e75
> eth.getBlock(443947)
{
difficulty: 6628388332836,
extraData: "0xd583010203844765746885676f312e35856c696e7578",
gasLimit: 3141592,
gasUsed: 1827755,
hash: "0x47155617d178ae63d3d7d7ae9e9f1357d5dadd5d4a8e76e523764825c6f4294c",
logsBloom: "0x00000800000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000010000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
miner: "0x4e2f2f1d8e0870cd073a0286cbc99c911053446b",
nonce: "0xa10198831a7e1893",
func BenchmarkSignRandomInput(b *testing.B) {
for i := 0; i < b.N; i++ {
b.StopTimer()
_, seckey := GenerateKeyPair()
msg := randentropy.GetEntropyCSPRNG(32)
b.StartTimer()
if _, err := Sign(msg, seckey); err != nil {
b.Fatal(err)
}
}
to_proplist_meta(Meta,Rs) ->
lists:map(
fun(Res) ->
Elems = fun(Ele, Cnt) ->
V = if element(Cnt,Res) == null -> undefined;
true -> element(Cnt,Res) end,
{{Ele,V},Cnt+1}
end,
{Base,BaseCnt} = lists:mapfoldl(Elems, 1, hd(Meta)),
{Other,_} = lists:mapfoldl(
-module(foo).
-compile(export_all).
printer(Text, Num_times, Time_between) ->
[begin io:format(Text), timer:sleep(Time_between) end
|| _ <- lists:seq(1, Num_times)].
main() ->
spawn(?MODULE, printer, ["Hello~n", 30, 10]),
spawn(?MODULE, printer, ["World~n", 40, 15]),
subs(String, Ints) ->
{Intervals, _} = lists:mapfoldl(fun(E, A) -> L = A + E, {{A, L - 1}, L} end, 1, Ints),
[string:sub_string(String, Start, Stop) || {Start, Stop} <- Intervals].
@Gustav-Simonsson
Gustav-Simonsson / gist:1501514
Created December 20, 2011 13:06
proplist_to_record
-define(proplist_to_record(Record),
fun(PropList) ->
[_Tag | Defaults] = tuple_to_list(#Record{}),
Fields = record_info(fields, Record),
list_to_tuple([Record | [proplists:get_value(F, PropList, D)
|| {F, D} <- lists:zip(Fields, Defaults)]])
end).
all_msg(Acc) ->
receive
X ->
all_msg([X|Acc])
after
1 ->
Acc
end.