Skip to content

Instantly share code, notes, and snippets.

View Bueddl's full-sized avatar

Sebastian Büttner Bueddl

View GitHub Profile
SELECT
r.`id` AS `rule_id`,
SUM(qu.`value`) AS `window_usage`,
TIMESTAMPDIFF(SECOND, NOW(), MIN(qu.`created_at`)) AS `eslapsed_window_first_usage`
FROM
quota_rules` qr
LEFT JOIN `rules` r
ON (r.`id` = qr.`rule_id`)
LEFT JOIN `actions` a
ON (a.`id` = r.`action_id`)
@Bueddl
Bueddl / my_string.cpp
Created January 25, 2017 17:57
Implementation of small string optimization
#include <cstring>
#include <cstdio>
class my_string
{
private:
union
{
char inline_buf[16]; // sso
char *bufptr;
@Bueddl
Bueddl / GbxRemote2.php
Last active January 23, 2017 20:34
Engeneering at its finest - today: PHP & TrackMania
<?php
// 8 Bytes lesen
$contents = fread($this->socket, 8);
// Fehlerbehandlung - schon schlimm genug
if (strlen($contents) == 0) {
$this->error = new IXR_Error(-32300, 'transport error - cannot read size/handle');
return false;
}
template<class T, class... Ts>
struct _sizeof
{
static constexpr std::size_t value = 1 + _sizeof<Ts...>();
};
template<class T>
struct _sizeof<T>
{
@Bueddl
Bueddl / static_assert.cpp
Created January 19, 2017 14:52
Static assert for C++98
template<bool expr>
struct static_assert;
template<>
struct static_assert<true>
{
static const char test;
};
struct false_type
@Bueddl
Bueddl / funcfuncarray.c
Created January 18, 2017 01:29
An array of functions that return functions that return void :>
/* (C) 2017 Sebastian Büttner <sebastian.buettner@iem.thm.de> */
#include <stdio.h>
/* This is about functions returning functions that return void and take no arguments (see below). */
void func()
{
printf("func()\n");
}
@Bueddl
Bueddl / rtti.cpp
Last active January 14, 2017 23:43
Runtime Type Information
#include <exception>
#include <iostream>
#include <unordered_map>
class object_base;
struct rt_type_info
{
const char *name;
const rt_type_info *base;
document ::= prolog element Misc*
Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
S ::= (#x20 | #x9 | #xD | #xA)+
NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D]
| [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF]
| [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
@Bueddl
Bueddl / plugin.sync_servers.php
Created January 9, 2017 20:41
XAseco Plugin to Sync Blacklist files across multiple gameservers
<?php
/* vim: set noexpandtab tabstop=2 softtabstop=2 shiftwidth=2: */
/**
* Sync servers plugin.
* Synchronizes black lists accross servers upon each round.
* Created by Bueddl
*
* Dependencies: none
*/
void node_param_value(std::shared_ptr<tag_node> &node, const std::string &value)
{
auto string = std::make_shared<xmlrpc::tag_node>("string");
string->append_child(std::make_shared<xmlrpc::text_node>(value));
node->append_child(string);
}
void node_param_value(std::shared_ptr<tag_node> &node, int value)