Skip to content

Instantly share code, notes, and snippets.

View christianparpart's full-sized avatar
🎃
Loading

Christian Parpart christianparpart

🎃
Loading
View GitHub Profile
@christianparpart
christianparpart / components-example.cpp
Last active August 29, 2015 13:56
clang -std=c++11 -o components-example components-example.cpp
#include <stdio.h>
#include <typeinfo>
#include <unordered_map>
class Foo {
public:
void dump() { printf("Hello, foo!\n"); }
};
class Bar {
@christianparpart
christianparpart / comps.cpp
Created February 24, 2014 15:37
clang++ -std=c++11 -o comps comps.cpp
#include <stdio.h>
#include <typeinfo>
#include <unordered_map>
class Foo {
public:
void dump() { printf("Hello, foo!\n"); }
};
class Bar {
@christianparpart
christianparpart / x0d-ialu.conf
Created April 3, 2014 09:54
sample x0d.conf
# vim:syntax=flow
import accesslog from 'x0d/plugins';
import director from 'x0d/plugins/director';
import access from 'x0d/plugins';
import status from 'x0d/plugins';
import auth from 'x0d/plugins';
handler setup {
# workers 4;
# /bin/bash
# depends: libgeoip-dev libpcre3-dev libpam-dev
version="1.7.1"
wget -O /tmp/nginx-${version}.tar.gz http://nginx.org/download/nginx-${version}.tar.gz &&
wget -O /tmp/nginx-auth-pam.tar.gz http://web.iti.upv.es/~sto/nginx/ngx_http_auth_pam_module-1.3.tar.gz && \
git clone git@github.com:giom/nginx_accept_language_module.git /var/tmp/nginx_accept_language_module &&
tar xzvpf /tmp/nginx-${version}.tar.gz -C /var/tmp/ &&
@christianparpart
christianparpart / echo-server.cpp
Created August 20, 2014 13:57
Xzero (local) Echo Server Demo
#include <xzero/Server.h>
#include <xzero/ConnectionFactory.h>
#include <xzero/Connection.h>
#include <xzero/LocalConnector.h>
#include <xzero/SequencedExecutor.h>
#include <base/Buffer.h>
using base::Buffer;
class EchoConnection : public xzero::Connection {
#include <functional>
#include <memory>
#include <stdio.h>
typedef std::function<void()> Task;
void onRead() { printf("onRead\n"); }
void onTimeout() { printf("onTimeout\n"); }
void wait(void* ep, Task&& onRead, Task&& onWrite, Task&& onTimeout) {
#pragma once
#include <xzero/Api.h>
namespace xzero {
class XZERO_API LogTarget {
public:
virtual ~LogTarget() {}
#pragma once
#include <xzero/Api.h>
/*
* <xzero/logging/...>
* LogSource the logging source, that initiates/triggers the log msgs
* LogLevel the log level (none, error, warn, info, debug)
* LogTarget the logging target, where to log to
* LogAggregator logging aggregator, that manages the sources and their target.
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netdb.h>
#include <getopt.h>
class Executor {
public:
typedef std::function<void()> Task;
virtual void execute(Task task) = 0;
protected:
void setExceptionHandler(std::function<void(const std::exception&)> eh);
void handleException(const std::exception& e);
void safeCall(Task task) noexcept; // auto-catch any possibly exception