Skip to content

Instantly share code, notes, and snippets.

View yannick's full-sized avatar
🏗️

Yannick Koechlin yannick

🏗️
View GitHub Profile
#!/usr/bin/env python3
from __future__ import print_function
import ujson as json
#import demjson
import sys
from hashlib import md5
import datetime
from collections import defaultdict
{
"ads": {
"20min.de.desktop.text": {
"type": "ad",
"url": "http://adserver.adtech.de/adiframe/3.0/1625/6060773/0/16/ADTECH;target=_blank;grp=[group]\r\n",
"ratio": "150x165"
},
"20min.de.desktop.video": {
"type": "ad",
"url": "http://adserver.adtech.de/adiframe/3.0/1625/6060777/0/16/ADTECH;target=_blank;grp=[group]\r\n",
@yannick
yannick / lp_counters.py
Created February 23, 2016 17:52 — forked from devdazed/lp_counters.py
Simple Linear Probabilistic Counters
"""
Simple Linear Probabilistic Counters
Credit for idea goes to:
http://highscalability.com/blog/2012/4/5/big-data-counting-how-to-count-a-billion-distinct-objects-us.html
http://highlyscalable.wordpress.com/2012/05/01/probabilistic-structures-web-analytics-data-mining/
Installation:
pip install smhasher
pip install bitarray
class MySingleton
{
private this()
{
}
private static bool instantiated_;
private __gshared MySingleton instance_;
#!/bin/bash
dmd -c -of.dub/build/application-debug-posix.osx-x86_64-dmd_2069-D7E2A6A44D76A380F3BB67889034B071/foo.o -debug -g -w -version=VibeDefaultMain -version=VibeUseNativeDriverType -version=VibeLibasyncDriver -version=CryptoSafe -version=Have_foo -version=Have_openssl -version=Have_vibe_d_utils -version=Have_vibe_d_data -version=Have_vibe_d_core -version=Have_vibe_d_http -version=Have_vibe_d_diet -version=Have_vibe_d_mail -version=Have_vibe_d_mongodb -version=Have_vibe_d_redis -version=Have_vibe_d_web -version=Have_vibe_d -version=Have_libasync -version=Have_memutils -Isource/ -I../vibe.d/source/ -I../../../.dub/packages/libasync-0.7.8/libasync/source/ -I../../../.dub/packages/memutils-0.4.4/memutils/source/ -I../../../.dub/packages/openssl-1.1.4_1.0.1g/openssl -Jviews source/app.d ../vibe.d/source/vibe/d.d ../vibe.d/source/vibe/vibe.d ../vibe.d/source/vibe/core/args.d ../vibe.d/source/vibe/core/concurrency.d ../vibe.d/source/vibe/core/connectionpool.d ../vibe.d/source/vibe/core/core.d ../vibe.d/source/
module influxdb.client;
import vibe.core.net;
import vibe.core.log;
string DEFAULT_ADDRESS = "127.0.0.1";
ushort DEFAULT_UDP_PORT = 4455;
private final class InfluxConnection
{
module devicedetect;
extern (C):
alias e_fiftyoneDegrees_MatchMethod fiftyoneDegreesMatchMethod;
alias e_fiftyoneDegrees_Resultset_CacheState fiftyoneDegreesResultsetCacheState;
alias e_fiftyoneDegrees_DataSetInitStatus fiftyoneDegreesDataSetInitStatus;
alias fiftyoneDegreesRange_t fiftyoneDegreesRange;
alias fiftyoneDegrees_ascii_string_t fiftyoneDegreesAsciiString;
alias fiftyoneDegrees_component_t fiftyoneDegreesComponent;
/usr/local/Cellar/dmd/2.070.0_1/include/dlang/dmd/std/variant.d(613,27): Error: function core.stdc.string.memcpy (void* s1, const(void*) s2, ulong n) is not callable using argument types (ubyte[32]*, shared(Metadata)*, ulong)
/usr/local/Cellar/dmd/2.070.0_1/include/dlang/dmd/std/variant.d(548,17): Error: template instance std.variant.VariantN!32LU.VariantN.opAssign!(shared(Metadata)) error instantiating
/usr/local/Cellar/dmd/2.070.0_1/include/dlang/dmd/std/concurrency.d(117,18): instantiated from here: __ctor!(shared(Metadata))
/usr/local/Cellar/dmd/2.070.0_1/include/dlang/dmd/std/concurrency.d(628,23): instantiated from here: __ctor!(shared(Metadata))
/usr/local/Cellar/dmd/2.070.0_1/include/dlang/dmd/std/concurrency.d(618,10): instantiated from here: _send!(shared(Metadata))
/usr/local/Cellar/dmd/2.070.0_1/include/dlang/dmd/std/concurrency.d(594,10): ... (1 instantiations, -v to show) ...
../../../../../../vibe.d/source/vibe/core/concurrency.d(1175,65): instantiated from he
15A77F35:15B29335 2016.02.03 21:38:51.817 dbg] Exception while handling request GET /path/in.gif: object
.Exception@../vibe.d/source/vibe/stream/operations.d(164): Reached byte limit before reaching end marker.
[15A77F35:15B29335 2016.02.03 21:38:51.817 dbg] ----------------
/usr/include/dlang/dmd/std/exception.d:405 pure @safe void std.exception.bailOut!(Exception).bailOut(immutable(char)
[], ulong, const(char[])) [0x74ba6f]
/usr/include/dlang/dmd/std/exception.d:363 pure @safe bool std.exception.enforce!(Exception, bool).enforce(bool, laz
y const(char)[], immutable(char)[], ulong) [0x74c52a]
../vibe.d/source/vibe/stream/operations.d:164 void vibe.stream.operations.readUntil!(vibe.stream.wrapper.StreamOutpu
tRange).readUntil(vibe.core.stream.InputStream, ref vibe.stream.wrapper.StreamOutputRange, const(ubyte[]), ulong) [0
x76c270]
class Mylog
this(string timeid, ref HTTPServerRequest req)
{
this.timeid = timeid;
this.unixtime = Clock.currTime.toUnixTime();
this.domain = req.host;
this.ip = req.headers.get("X-Real-IP", req.headers.get("X-Forwarded-For", req.peer));