Skip to content

Instantly share code, notes, and snippets.

@Idorobots
Idorobots / gist:5178102
Created March 16, 2013 20:12
fmincon example
function [c, ceq] = h(x)
ceq = [];
c = (x(1) - 1)^2 + (x(2) + 1)^2 - 1;
end
function [xp, yp] = circle(x,y,r)
ang=0:0.01:2*pi;
xp= x + r * cos(ang);
yp= y + r * sin(ang);
end
@Idorobots
Idorobots / gist:5236642
Created March 25, 2013 11:53
Seriously... Wat!?
class RandomSubclass < [Array, Hash, String, Fixnum, Float, TrueClass].sample
# Wat
end
@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)
@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: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: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: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: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: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: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.