Skip to content

Instantly share code, notes, and snippets.

View RGafiyatullin's full-sized avatar

Raman Hafiyatulin RGafiyatullin

View GitHub Profile
@RGafiyatullin
RGafiyatullin / What Is That.md
Last active May 18, 2023 20:03
I can't understand why certain $latex$ blocks are not rendered in the Markdown? (In the Github preview)

$(P_0, \dots, P_n)$

The $n$ parties — $(P_0, \dots, P_n)$ , $\ell$

The $n$ parties $(P_0, \dots, P_n)$ , $\ell$

The parties $(P_0, \dots, P_n)$ , $\ell$

$P_0$

use std::collections::{HashMap, HashSet};
pub struct DiGraph {
adjacency: HashMap<usize, HashSet<usize>>,
}
impl From<HashMap<usize, HashSet<usize>>> for DiGraph {
fn from(edges: HashMap<usize, HashSet<usize>>) -> Self {
Self { adjacency: edges }
}
[2019-03-15T00:38:24Z INFO avro_rs_variants] ==== UnitStructure ===
[2019-03-15T00:38:24Z INFO avro_rs_variants] schema: Null
[2019-03-15T00:38:24Z INFO avro_rs_variants] input: UnitStructure
[2019-03-15T00:38:24Z INFO avro_rs_variants] avro: Null
[2019-03-15T00:38:24Z INFO avro_rs_variants] output: UnitStructure
[2019-03-15T00:38:24Z INFO avro_rs_variants] ==== NewtypeStruct ===
[2019-03-15T00:38:24Z INFO avro_rs_variants] schema: Array(Union(UnionSchema { schemas: [Boolean, Int, String] }))
[2019-03-15T00:38:24Z INFO avro_rs_variants] input: NewtypeStruct(true, 42, "hello")
[2019-03-15T00:38:24Z INFO avro_rs_variants] avro: Array([Boolean(true), Int(42), String("hello")])
[2019-03-15T00:38:24Z INFO avro_rs_variants] output: NewtypeStruct(true, 42, "hello")
extern crate avro_rs;
#[macro_use]
extern crate log;
extern crate serde;
use serde::{Deserialize, Serialize};
use avro_rs::Schema;
type Res = Result<(), Box<dyn std::error::Error>>;
case class State(successCount: Int, failureCount: Int) {
def incSuccessCount: State = copy(successCount = successCount + 1)
def incFailureCount: State = copy(failureCount = failureCount + 1)
}
object State {
def apply(): State = State(successCount = 0, failureCount = 0)
}
case class Request(...)
-record(s, {
success_cnt = 0 :: non_neg_integer(),
failure_cnt = 0 :: non_neg_integer()
}).
-type state() :: #s{}.
-type request() :: term().
-type response() :: term().
-type stats() :: {SuccessCount :: non_neg_integer(), FailureCount :: non_neg_integer()}.
-type result(T) :: {ok, {T, stats()}} | {error, {Reason :: term(), stats()}}.
@RGafiyatullin
RGafiyatullin / gist:4b895d6282b43d78dc42
Created September 14, 2014 23:21
EXML_no_destructor. REPL [03ef2b9]
(jd@127.0.0.1)16> FMem().
59206145
(jd@127.0.0.1)17> P = spawn(F6).
<0.3960.0>
(jd@127.0.0.1)18> FMem().
117761857
(jd@127.0.0.1)19> P ! go, process_info(P) /= undefined.
true
(jd@127.0.0.1)20> FMem().
168042448
@RGafiyatullin
RGafiyatullin / gist:675b97dc76c69d8a7c00
Created September 14, 2014 23:20
EXML_no_destructor: funs
FAlloc = fun() -> [ begin {ok, P} = exml_event:new_parser(), P end || _ <- lists:seq(1,10000) ] end.
FFree = fun( Ps ) -> [ exml_event:free_parser(P) || P <- Ps ] end.
FFeed = fun( Ps, Data ) -> [ exml_event:parse( P, Data ) || P <- Ps ] end.
FMem = fun() -> erlang:memory(system) end.
FWait = fun(Ret) -> receive _ -> Ret end end.
XmlOpen = <<"<t1><t2><t3><t4><t5><t1><t2><t3><t4><t5>">>.
XmlClose = <<"</t5></t4></t3></t2></t1></t5></t4></t3></t2></t1>">>.
F0 = fun() -> Ps = FAlloc(), FWait(ok) end.
@RGafiyatullin
RGafiyatullin / gist:9cefce33bb22f3350cf0
Last active August 29, 2015 14:06
EXML_no_destructor. REPL [5d5ed6a]
(jd@127.0.0.1)16> FMem().
59564416
(jd@127.0.0.1)17> P = spawn(F6).
<0.4611.0>
(jd@127.0.0.1)18> FMem().
118046664
(jd@127.0.0.1)19> P ! go, process_info(P) /= undefined.
true
(jd@127.0.0.1)20> FMem().
168332523
@RGafiyatullin
RGafiyatullin / emysql-connection-management.txt.erl
Last active December 26, 2015 20:39
Emysql tests. Case #1: emysql:execute/3. Case #2: emysql_query_queue:execute/3 (no pipelining). Case #3: emysql_query_queue:execute/3 (with pipelining).
[
{case_1,
[{min,557},
{max,8536},
{arithmetic_mean,4572.429290323886},
{geometric_mean,4560.35620553275},
{harmonic_mean,4548.125352799831},
{median,4519},
{variance,114096.88640374373},
{standard_deviation,337.782306232496},