Skip to content

Instantly share code, notes, and snippets.

@Idorobots
Idorobots / gist:11387381
Created April 28, 2014 23:51
Half-assed ID3 attempt.
fun name (n, v) = n;
fun vals (n, v) = v;
fun get([], a) = 0
| get((b, v) :: tail, a) = if a = b then v else get(tail, a);
fun ig(a, S, C) =
(* TODO :( *)
C(S, name a);
@Idorobots
Idorobots / gist:8163848
Last active January 1, 2016 15:19
Why OOP when you can NOOP?
private auto typeDispatch(T, Cs...)(T value, Cs callbacks) {
/*static*/ foreach(i, C; Cs) {
if((cast(ParameterTypeTuple!C[0]) value) !is null) {
return callbacks[i](cast(ParameterTypeTuple!C[0]) value);
}
}
throw new SemanticError("Can't compile that!");
}
// ...
@Idorobots
Idorobots / gist:8125421
Created December 25, 2013 18:04
Final exam grades simulation.
samples = 100; % Ilość symulowanych egzaminów.
N = 128; % Ilość osób na egzaminie.
Q = 19; % Ilość pytań na egzaminie.
span = [2.0, 3.0, 3.5, 4.0, 4.5, 5.0]; % Oceny, jakie można było dostać.
R = zeros(1, N*samples); % Finalny wynik symulacji.
S = zeros(1, N); % Wynik symulacji jednego egzaminu.
mu = 0.1; % mu dla rozkładu normalnego.
@Idorobots
Idorobots / gist:7160066
Last active December 26, 2015 13:39
A handy replacement for plain `git merge`.
#! /bin/sh
# This little script will automatically test feature-branch code
# before it is actually merged into the master branch.
# Just alias it as so:
# git config --global alias.safe-merge '!exec $HOME/git_safe_merge.sh'
LAST_BRANCH=`git rev-parse --abbrev-ref HEAD`
TEMP_BRANCH=`date +"$LAST_BRANCH-%Y%m%d%H%M"`
@Idorobots
Idorobots / gist:6304636
Created August 22, 2013 08:37
Sample flood output.
{
"counters" : {
"all" : 110,
"ws_incomming" : 516,
"http_outgoing" : 458,
"ws_outgoing" : 434,
"http_incomming" : 430,
"alive" : 10,
"disconnected" : 0,
"connected" : 10,
@Idorobots
Idorobots / gist:6268501
Last active December 21, 2015 06:59
Proof of concept
{
"phases" : [],
"sessions" : [
{
"name" : "Session name",
"transport" : "xhr_polling",
"weight" : 0.2,
"metadata" : {
"foo" : "bar",
"baz" : "hurr"
@Idorobots
Idorobots / gist:6120670
Created July 31, 2013 09:24
Tsung Socket.IO config
<session probability="50" name="websocket" type="ts_websocket">
<transaction name="socketio_ws_handshake">
<request>
<dyn_variable name="sid" re="\r\n\r\n([^:]+):[^:]+:[^:]+:[^:]+"/>
<http url="/socket.io/1/" method="GET" version="1.1">
<http_header name="origin" value="null"/>
</http>
</request>
@Idorobots
Idorobots / gist:5422779
Last active December 16, 2015 10:49
C++, WAT
#include <stdio.h>
template <typename T>
T foo(T argc, char *argv<::>) <%
puts(argv<:0:>);
return argc;
%>
int(*main)(int, char*<::>) = &foo<int>;
@Idorobots
Idorobots / gist:5321135
Last active December 15, 2015 20:49
Programming the way it should be
((λ Z
((λ nil.
(((((λ null.
(λ cons.
(λ car.
(λ cdr.
(λ life
(the-universe
and-everything))))))
(λ l
@Idorobots
Idorobots / gist:5278294
Created March 30, 2013 20:54
Export your RSS feeds from Google Reader into Emacs News Ticker compatible format.
(require 'xml)
(defun assoc-or-error (what where &optional err-string)
(or (assoc what where)
(error (or err-string "Suddenly errors! Thousands of them!"))))
(defun google-reader-to-newsticker (filename)
"Parses google-reader subscription XML and returns newsticker compatible feed alist."
(with-temp-buffer
(insert-file-contents filename)