Skip to content

Instantly share code, notes, and snippets.

View johndstein's full-sized avatar

John Stein johndstein

View GitHub Profile
@johndstein
johndstein / kafka.js
Created October 8, 2014 17:20
kafka.js
#!/usr/bin/env node
var kafka = require('kafka-node');
var winston = require('winston');
var _ = require('lodash');
// Wraps a kafka consumer
// https://github.com/SOHU-Co/kafka-node#consumer
// We intentionally only allow a single topic, group, partition per consumer.
//
@johndstein
johndstein / config.txt
Created October 8, 2014 17:21
kafka config
"kafka": {
"consumers": [{
"client": {
"connectionString": "localhost:2181"
},
"consumer": {
"topic": "job_result",
"groupId": "job_result"
}
}]
@johndstein
johndstein / wrap.promise.js
Created December 23, 2014 09:42
new promise catches all
#!/usr/bin/env node
var Promise = require("bluebird");
// function dosomething(n) {
// if (n === 7) {
// var err = new Error('seven error');
// return Promise.reject(err);
// //throw err;
// }
@johndstein
johndstein / stop_apps.py
Created February 13, 2015 17:25
Ansible stop all upstart jobs that begin with a given list of prefixes
#!/usr/bin/python
from glob import glob
DOCUMENTATION = '''
---
module: stop_apps
short_description: Stop all (upstart) jobs that start with given prefixes.
description:
- Calls stop on every upstart job that begins with one of the given
prefixes.
@johndstein
johndstein / delete.sh
Created March 9, 2015 13:13
One way to "delete" messages from kafka topic
#!/bin/bash
IFS=","
topic="@option.topic@"
for t in $topic
do
echo "Expiring topics: $t"
/opt/tap-kafka/bin/kafka-topics.sh --zookeeper `awk -F'=' '/zookeeper.connect=/ {print $2}' /opt/tap-kafka/config/server.properties | sed -e 's/\/tap-kafka//'`/tap-kafka --alter --topic $t --config retention.bytes=0
/opt/tap-kafka/bin/kafka-topics.sh --zookeeper `awk -F'=' '/zookeeper.connect=/ {print $2}' /opt/tap-kafka/config/server.properties | sed -e 's/\/tap-kafka//'`/tap-kafka --describe --topic $t
done
@johndstein
johndstein / main.yml
Created April 6, 2015 13:41
Ansible HTTP POST templated file
---
- template:
src: cust_info.json.j2
dest: /var/tmp/cust_info.json
mode: 0777
- command: cat /var/tmp/cust_info.json
register: cust_info
- uri:
@johndstein
johndstein / syslog-ng.conf
Last active February 19, 2020 08:27
default syslog-ng.conf
ubuntu@tmpc1:/etc/syslog-ng$ cat syslog-ng.conf
@version: 3.5
@include "scl.conf"
@include "`scl-root`/system/tty10.conf"
# Syslog-ng configuration file, compatible with default Debian syslogd
# installation.
# First, set some global options.
options { chain_hostnames(off); flush_lines(0); use_dns(no); use_fqdn(no);
@johndstein
johndstein / scl.conf
Created August 1, 2015 09:50
default scl.conf
ubuntu@tmpc1:/etc/syslog-ng$ cat scl.conf
#############################################################################
# Copyright (c) 2010-2012 BalaBit IT Ltd, Budapest, Hungary
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published
# by the Free Software Foundation, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@johndstein
johndstein / Package Control.sublime-settings
Created September 7, 2015 21:32
Package Control.sublime-settings
{
"in_process_packages":
[
],
"installed_packages":
[
"GitGutter",
"JsFormat",
"Markdown Preview",
"Package Control",
@johndstein
johndstein / Preferences.sublime-settings
Created September 7, 2015 21:33
Preferences.sublime-settings
{
"color_scheme": "Packages/User/SublimeLinter/Twilight (SL).tmTheme",
"font_face": "Hack",
"font_size": 17,
"ignored_packages":
[
"Vintage"
],
"rulers":
[