Skip to content

Instantly share code, notes, and snippets.

View r2p2's full-sized avatar

Robert Peters r2p2

View GitHub Profile
// g++ main.cpp -std=gnu++0x
#include <vector>
#include <memory> // shared_ptr
template <class T>
class Base
{
public:
Base(T value)
:m_value(value)
// g++ main2.cpp -std=gnu++0x
#include <vector>
#include <memory> // shared_ptr
template <class T>
class Base
{
public:
Base(T value)
:m_value(value)
#include <vector>
template <class T>
class Foo
{
public:
void bar()
{
typename std::vector<T>::const_iterator it;
}
#include <stdint.h>
#include <stdio.h>
#include <cstring>
#include <fstream>
#include <map>
#include <arpa/inet.h>
uint32_t* load_code(char *file, uint32_t &filesize)
{
uint32_t *p_code = NULL;
@r2p2
r2p2 / WFE in Clojure
Created October 17, 2010 09:14
Mal wieder erste Gehversuche in Clojure.
(defn kill-process [process-channel]
(send process-channel (fn [a] "stop")))
(defn engine-loop [channel state process-list]
(loop [my-state state
my-process-list process-list]
(await channel)
(let [channel-value (deref channel)]
(do
(send channel (fn [a] "idle"))
@r2p2
r2p2 / gist:630825
Created October 17, 2010 12:57
Nur ein paar Gedanken, wie eine WFE in Clojure umgesetzt werden könnte, runter programmiert. Wenn Agents tatsächlich so eingesetzt werden sollen, könnte ich mich wohl nur schwer mit ihnen anfreunden.
(defn start-process-by-agent [process-agent]
(send-off process-agent (fn [process-data] "running")))
(defn stop-process-by-agent [process-agent]
(send-off process-agent (fn [process-data] "stopped")))
(defn init [wfe-id]
(println "initiating wfe")
(println "TODO: load unfinished processes")
(agent (hash-map
@r2p2
r2p2 / gist:639192
Created October 21, 2010 19:55
Brainfuck
module Main where
import Char
type Tape = [Char]
type Machine = (Tape, Tape)
type Operation = Machine → IO (Machine)
type Operations = [Operation]
raise =
@r2p2
r2p2 / gist:1095090
Created July 20, 2011 14:43
Xer Signalklasse
#include <iostream>
#include <vector>
struct CallbackNoArg
{
};
class CallbackBase
{
public:
#include <utils/event/signal.h>
#include <iostream>
class MySlot
{
public:
void slot()
{
std::cout << "foo" << std::endl;
@r2p2
r2p2 / main.cpp
Created September 24, 2011 08:01
class AbstractSocket
{
public:
AbstractSocket()
:m_i(0)
{
}
virtual void connect_to_host()
{