Skip to content

Instantly share code, notes, and snippets.

View orian's full-sized avatar

Paweł Szczur orian

View GitHub Profile
/**
* Our data structure (e.g., a linked list)
*/
template <class ValueType>;
class MyDataStructure {
/**
* Inner class that describes a const_iterator and 'regular' iterator at the same time, depending
* on the bool template parameter (default: true - a const_iterator)
*/
template<bool is_const_iterator = true>
@orian
orian / boost_log_test.cc
Created December 20, 2013 23:55
Boost.Log simplest code + command line to compile it. Boost v1.54 Ubuntu 13.10,
#include <boost/log/trivial.hpp>
int main(int, char*[])
{
BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
BOOST_LOG_TRIVIAL(debug) << "A debug severity message";
BOOST_LOG_TRIVIAL(info) << "An informational severity message";
BOOST_LOG_TRIVIAL(warning) << "A warning severity message";
BOOST_LOG_TRIVIAL(error) << "An error severity message";
BOOST_LOG_TRIVIAL(fatal) << "A fatal severity message";
@orian
orian / gist:7858208
Last active December 30, 2015 16:59
Adding "swap workspace" to Xmonad

1. To imports add: import XMonad.Actions.SwapWorkspaces

2. Somewhere in file, where you have keyboard mapping add:

    -- Swap Workspaces
    , ((modm .|. controlMask,     xK_Right),  swapTo Next)
    , ((modm .|. controlMask,     xK_Left),   swapTo Prev)

3. Reload xmonad, now you can swap workspaces using combination Mod+Ctrl+Left and Mod+Ctrl+Right

@orian
orian / gist:7242125
Created October 30, 2013 23:33
gcc -Wl,--verbose,-v -O3 xor_train.c -o xor_train -lfann -lm
gcc -Wl,--verbose,-v -O3 xor_train.c -o xor_train -lfann -lm
collect2 version 4.8.1
/usr/bin/ld --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o xor_train /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. --verbose -v /tmp/ccVoFJmM.o -lfann -lm -l
@orian
orian / brnl_pbb_estimate.py
Created August 22, 2013 08:28
Let's say that you have an event which happen at each second with probability p, each second is independent on previous and next one. Instead of tossing a coin every second, one can try to toss a coin once and estimate when a next event is going to happen, and then call the function again at a moment of event to get next event time and so on.
#!/usr/bin/python
import random
class BernoulliPbb(object):
def __init__(self, p):
self.p = p
def Estimate(self):
r = random.random()
@orian
orian / loop_test_gen.py
Created June 27, 2013 11:42
simple script to generate 31 possible loops in Dart (http://dartlang.org)
#!/usr/bin/python
from string import Template
import itertools
def GenerateOne(name, initializer, test, update, use_break, use_continue):
if not test and not use_break:
return
tmpl = Template("""
$name() {
@orian
orian / robot.js
Created December 4, 2012 03:16 — forked from guilhermebruzzi/robot.js
Merry Go round
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot){
//robot.clone();
this.robotOptions = {
clone: {
canStartFight: false,
goBackOnCollision: false
@orian
orian / robot.js
Created December 4, 2012 02:30
Dzdzowniczka
var Robot = function(robot) {
};
Robot.prototype.lastHitAngle = -1;
Robot.prototype.radius = 20;
Robot.prototype.hit = 0;
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
this.hit = 0;
@orian
orian / robot.js
Created December 4, 2012 02:18 — forked from randompast/robot.js
QR-bot-002
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.turn(1);
robot.ahead(2);
@orian
orian / robot.js
Created December 4, 2012 01:22 — forked from robertomoulin/robot.js
Chewbaccax
var Robot = function(robot) {
robot.clone();
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(40);
robot.rotateCannon(360);};
Robot.prototype.onScannedRobot = function(ev) {