Skip to content

Instantly share code, notes, and snippets.

View Leonidas-from-XIV's full-sized avatar

Marek Kubica Leonidas-from-XIV

View GitHub Profile
Flat profile:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls ms/call ms/call name
33.33 0.01 0.01 615841 0.00 0.00 caml_alloc_shr
33.33 0.02 0.01 205211 0.00 0.00 camlEuler__fun_1131
33.33 0.03 0.01 mpq_val
0.00 0.03 0.00 615867 0.00 0.00 caml_fl_allocate
0.00 0.03 0.00 615841 0.00 0.00 allocate_block
@Leonidas-from-XIV
Leonidas-from-XIV / refactor.diff
Created September 30, 2014 17:02
Throwing out code can be so much fun. Pry `|>` and `@@` from my cold, dead hands.
diff --git a/src/slacko.ml b/src/slacko.ml
index 69695cd..7f18f4c 100644
--- a/src/slacko.ml
+++ b/src/slacko.ml
@@ -394,8 +394,8 @@ let presence_set token presence =
|> definitely_add "presence" presence
in query uri
-let search_all token ?sort ?sort_dir ?highlight ?count ?page query_ =
- let uri = endpoint "search.all"
@Leonidas-from-XIV
Leonidas-from-XIV / pactree.txt
Created September 27, 2014 00:17
Perl dependencies of caff
signing-party-svn
├─perl-libintl-perl
├─perl-text-iconv
├─recode
├─perl-mailtools
│ └─perl-timedate
├─perl-gd
│ └─gd
├─perl-gnupg-interface
│ ├─perl-moox-late
@Leonidas-from-XIV
Leonidas-from-XIV / lwt_rmtree.ml
Created September 14, 2014 20:20
Deleting recursively using Lwt
let rec rmtree path = lwt stat = Lwt_unix.lstat path in
match stat.Unix.st_kind with
| Unix.S_REG | Unix.S_LNK | Unix.S_BLK | Unix.S_CHR | Unix.S_SOCK | Unix.S_FIFO ->
Lwt_unix.unlink path
| Unix.S_DIR ->
Lwt_unix.files_of_directory path
|> Lwt_stream.filter (fun x -> x <> "." && x <> "..")
|> Lwt_stream.iter_s (fun p ->
let subdir = Filename.concat path p in
rmtree subdir)
@Leonidas-from-XIV
Leonidas-from-XIV / goal.py
Created July 27, 2014 11:28
Simple Python solution for g()('al') challenge
#!/usr/bin/env python3
class G(object):
def __init__(self, prefix='g'):
self.prefix = prefix
def __call__(self, args=None):
if args == 'al':
return self.prefix + 'al'
else:
#include <stdio.h>
int main(void) {
printf("%s\n",
"This is some other error "
"message from some C "
"code that got split.");
}
@Leonidas-from-XIV
Leonidas-from-XIV / vm.pl
Last active August 29, 2015 14:03
Virtual Machines demo program in Proll (load into SWI with ['vm.pl'].)
% SWI can do multiplication otherwise, but Proll does not, so define a mul predicate
mul(0, _, 0).
mul(_, 0, 0).
mul(1, Y, Y).
mul(X, 1, X).
mul(X, Y, Z) :- plus(Xpred, 1, X), mul(Xpred, Y, Zpred), plus(Zpred, Y, Z), !.
% our function, call f(8, 5, Z).
f(X, Y, Z) :- mul(X, Y, Zsucc), plus(Zsucc, 2, Z).
@Leonidas-from-XIV
Leonidas-from-XIV / structs.c
Created July 14, 2014 12:53
You can pass structs as values around in C, didn't know.
#include <stdio.h>
typedef struct foo {
int bar;
int baz;
} foo;
foo bar(foo baz) {
return baz;
}
@Leonidas-from-XIV
Leonidas-from-XIV / wiringpi.sh
Created July 12, 2014 20:50
WiringPi dependency install script for OPAM
#!/bin/sh -ex
# there are no releases of WiringPi, always uses git snapshots
git clone git://git.drogon.net/wiringPi
cd wiringPi
# the WiringPi build script calls make itself where necessary
./build
@Leonidas-from-XIV
Leonidas-from-XIV / gist:f838c9f208297ff78ac2
Created June 13, 2014 22:06
GHC 7.4.1 on Raspberry Pi compiling vector
[ 5 of 19] Compiling Data.Vector.Fusion.Stream.Monadic ( Data/Vector/Fusion/Stream/Monadic.hs, dist/dist-sandbox-3f9b858a/build/Data/Vector/Fusion/Stream/Monadic.o )
ghc: panic! (the 'impossible' happened)
(GHC version 7.4.1 for arm-unknown-linux):
Cant do annotations without GHCi
{Data/Vector/Fusion/Stream/Monadic.hs:104:19-33}
base:GHC.Exts.ForceSpecConstr{d ra42}