Skip to content

Instantly share code, notes, and snippets.

View ctavan's full-sized avatar

Christoph Tavan ctavan

View GitHub Profile
@ctavan
ctavan / parse_broken_csv.py
Created October 12, 2012 11:46
Decode CSV file with broken encodings.
#!/usr/bin/env python
"""
This script parses a tab-separated CSV-file where fields may contain strings
with broken encodings. Each line of the CSV-file is parsed into a dictionary.
"""
import csv
import json
import sys
@ctavan
ctavan / gist:4482825
Last active February 18, 2019 16:09
Init-script for optionally starting multiple redis instances on the same host running Ubunut/Debian. Highly inspired by the memcached init script that comes with the Ubuntu package. This is useful since redis is single-threaded.
#! /bin/bash
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@ctavan
ctavan / remove-merged-branches.sh
Created May 14, 2013 15:54
Remove merged git branches
#!/bin/sh
REMOTE=${1:-origin}
BRANCH=$(git symbolic-ref -q HEAD) || BRANCH='(unknown branch)'
BRANCH=${BRANCH##refs/heads/}
REMOTE_MERGED=$( git branch -r --merged |
grep -v master |
grep -v "$BRANCH" |
sed -n "s,$REMOTE/,,p"
{
- title: "openrtb-v2_0-schema-bid_request"
+ title: "openrtb-v2_1-schema-bid_request"
- description: "json schema for an openrtb v2.0 bid request (http://www.iab.net/media/file/OpenRTB_API_Specification_Version2.0_FINAL.PDF)"
+ description: "json schema for an openrtb v2.1 bid request (http://www.iab.net/media/file/OpenRTB-API-Specification-Version-2-1-FINAL.pdf)"
definitions: {
+ vast_companion_type: {
+ type: "integer"
+ minimum: 1
+ maximum: 3
var RTBkit = require('../build/x86_64/bin/rtb.node');
var services = require('../build/x86_64/bin/services.node');
var zookeeperUri = "localhost:2181"; //must point to same Zookeeper as routers
var services = new services.ServiceProxies();
services.bootstrap('bootstrap.json');
var agent = new RTBkit.BiddingAgent('myAgent', services);
@ctavan
ctavan / gist:6185925
Created August 8, 2013 16:01
user-agent-of-the-day
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; Sie gehen über die Firewall der Gemeinde Alfter ins Internet)
@ctavan
ctavan / aggregation-rules.conf
Last active August 29, 2015 14:06
carbon.conf
# The form of each line in this file should be as follows:
#
# output_template (frequency) = method input_pattern
#
# This will capture any received metrics that match 'input_pattern'
# for calculating an aggregate metric. The calculation will occur
# every 'frequency' seconds and the 'method' can specify 'sum' or
# 'avg'. The name of the aggregate metric will be derived from
# 'output_template' filling in any captured fields from 'input_pattern'.
#
net.netfilter.nf_conntrack_max = 655350
net.netfilter.nf_conntrack_generic_timeout = 60
net.netfilter.nf_conntrack_tcp_timeout_established = 600
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 5
@ctavan
ctavan / git-shortcuts
Last active December 13, 2018 14:43
git-shortcuts
# Originally authored by https://github.com/dohse
#
# To activate you have to save this to a file and add:
# source /path/to/these/git-shortcuts
# to your ~/.bashrc or ~/.zshrc depending on which shell you're using.
#
GIT="command git"
# Detect shells (like zsh) that do not split variables into arguments
@ctavan
ctavan / mutatable.jsx
Created January 17, 2017 12:13
mutatable react HOC
import hoistNonReactStatic from 'hoist-non-react-statics';
import React from 'react';
function getDisplayName(WrappedComponent) {
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
}
// See: https://facebook.github.io/react/docs/higher-order-components.html
export default function mutatable({ mutationName = 'mutate' } = {}) {
return (SourceComponent) => {