Skip to content

Instantly share code, notes, and snippets.

View yfyf's full-sized avatar

Ignas Vyšniauskas yfyf

View GitHub Profile
@yfyf
yfyf / measure_theory.tex
Created October 9, 2011 23:35
Measure Theory Notes
\documentclass[12pt]{article}
\usepackage{amsfonts, amsthm, amsmath}
\usepackage{verbatim}
\setlength{\textwidth}{6.5in}
\setlength{\oddsidemargin}{0in}
\setlength{\textheight}{9.5in}
\setlength{\topmargin}{0in}
\setlength{\headheight}{0in}
\setlength{\headsep}{0in}
\setlength{\parskip}{0pt}
@yfyf
yfyf / limit-infinity
Created February 4, 2012 15:08
motivation for the extended integers
Return = case NumberGrouping of
default ->
Nums = [Nr || {Nr, _} <- ctree:get_nr(ResultTree, [{count, Limit}])],
Sublist = case Limit of
infinity ->
Numbers;
L when is_integer(L) ->
lists:sublist(number_utils:expand_list(Nums), Limit)
end,
number_utils:reduce_list(Sublist).
@yfyf
yfyf / foobar_rebar_plugin.erl
Created November 23, 2012 11:25
execute rebar plugin when explicit only
-module(foobar_rebar_plugin).
-export([
pre_compile/2
]).
pre_compile(Config, AppFile) ->
case is_explicit_plugin(Config) of
true ->
%% Do Stuff.
@yfyf
yfyf / receiver.erl
Created January 25, 2013 13:55
Receiver snippet
Pid = spawn(fun() -> F = fun (Fun) -> receive A -> erlang:display(A), Fun(Fun) end end, F(F) end).
@yfyf
yfyf / Command-T-on-deb.md
Last active December 15, 2015 06:09
Note to not forget what is needed for Command-T on Debian
  • sudo apt-get install gcc vim-nox ruby ruby-dev
  • do the stuff from INSTALLATION
  • compile C extension manually
@yfyf
yfyf / unicode_repl_demo.erl
Last active December 18, 2015 14:19
Unicode handling
%% If your shell is setup correctly then inputing unicode chars should work like this:
1> A = "žžžūvis".
[382,382,382,363,118,105,115]
%% Contains integers > 255,
%% hence this is a list of codepoints, good!
%% None of these will work:
17> <<"žžžūvis">>.
** exception error: bad argument
18> <<"žžžūvis"/utf8>>.
@yfyf
yfyf / eunit_helper.hrl
Created June 20, 2013 10:43
Full Eunit assert output
-define(FULL_EUNIT_OUTPUT(Expr),
begin
try Expr
catch
_:Foo ->
?debugFmt("~n~100P~n", [Foo, 999999]),
erlang:error(eunit_assert_failed)
end
end).
@yfyf
yfyf / refl.erl
Created July 21, 2013 17:22
testing performance of reflection
-module(refl).
-compile(export_all).
normal(Foo) ->
lists:sort([Foo]).
bad(Mod, Fun, Foo) ->
Mod:Fun([Foo]).
@yfyf
yfyf / issue.idr.hs
Last active December 20, 2015 05:59
Type unification error
module Issue
data Env : (t: Type) -> (iR: t -> Type) -> (xs: Vect t n) -> Type where
Empty : {iR: t -> Type} -> (Env t iR Vect.Nil)
Extend : {r:t} -> {iR: t -> Type} -> {xs: Vect t n} ->
(res: (iR r)) -> (Env t iR xs) -> (Env t iR (r::xs))
data ElemAtIs : (i: Fin n) -> a -> Vect a n -> Type where
ElemAtIsHere : {x: a} -> {xs : Vect a n} -> ElemAtIs fO x (x::xs)
ElemAtIsThere : {i : Fin n} -> {x: a} -> {xs : Vect a n} ->
@yfyf
yfyf / idris-lol.log
Last active December 20, 2015 12:39
A simple Idris type checking failure
Skipping ./ConcEnv.idr
Type checking ./ConcState.idr
ConcState.idr:134:Can't unify EffM IO effs effs () with EffM IO [(MkEff
(ConcEnv ResState Resource rsin) eff)] xs' ()
Specifically:
Can't unify effs with [MkEff (ConcEnv ResState Resource rsin) eff]
ConcState.idr:176:Incomplete term Effects.>>= {m = IO} {xs = [MkEff
(ConcEnv {n = 1} ResState Resource [(RState Z Nat)]) (ConcState
IO),MkEff () StdIO]} {xs' = updateWith {a = EFFECT} {ys = [MkEff