Skip to content

Instantly share code, notes, and snippets.

View kleinron's full-sized avatar
🦉
C'est moi

Ron Klein kleinron

🦉
C'est moi
View GitHub Profile
@kleinron
kleinron / drop_many_tables.sql
Created August 18, 2013 18:18
MySQL bulk drop table where table like... See the question and the answers: http://stackoverflow.com/q/11053116/17772
SET @temp_statement = NULL;
SELECT
GROUP_CONCAT(table_schema, '.`', table_name, '`') INTO @temp_statement
FROM
(
SELECT
table_schema, table_name
FROM
information_schema.tables
WHERE
@kleinron
kleinron / launch4j-proj.xml
Created February 13, 2014 10:22
Launch4j project file to create a Windows executable for Apache Chainsaw
<launch4jConfig>
<dontWrapJar>true</dontWrapJar>
<headerType>gui</headerType>
<jar></jar>
<outfile>C:\chainsaw-bundle\chainsaw.exe</outfile>
<errTitle></errTitle>
<cmdLine></cmdLine>
<chdir>.</chdir>
<priority>normal</priority>
<downloadUrl>http://java.com/download</downloadUrl>
@kleinron
kleinron / guake-patch
Created March 11, 2015 10:42
Guake on the right screen
def get_final_window_rect(self):
"""Gets the final size of the main window of guake. The height
is the window_height property, width is window_width and the
horizontal alignment is given by window_alignment.
"""
screen = self.window.get_screen()
height = self.client.get_int(KEY('/general/window_height'))
width = 100
halignment = self.client.get_int(KEY('/general/window_halignment'))
@kleinron
kleinron / dev_installs.sh
Last active August 29, 2015 14:16
Linux goodies for developers
# silver searcher
sudo apt-get install -y silversearcher-ag
# rabbitvcs
sudo add-apt-repository -y ppa:rabbitvcs/ppa
sudo apt-get update
sudo apt-get install -y rabbitvcs-nautilus3 rabbitvcs-cli rabbitvcs-core rabbitvcs-gedit
# couchbase
sudo apt-get install -y libssl0.9.8
@kleinron
kleinron / gist:5c16a9df260cc91595ab
Created March 23, 2015 07:59
Background Request Sequence with shared k/v storage
title Background Request Sequence with shared k/v storage
client->LB: get x
LB->BG Service: get x
note right of BG Service: generate job-id
BG Service->k/v storage: k:job-id, v:empty
BG Service->Queue: enqueue x+job-id
BG Service->LB: job-id
LB->client: job-id
lsof -w -n -i tcp:8080
@kleinron
kleinron / morgan-x-forwarded-for.js
Created May 18, 2015 21:31
When using Morgan as the access log writer, in a Vanilla server, use this snippet to respect the x-forwarded-for header as the original client's ip address.
morgan.token('remote-addr', function (req, res) {
var ffHeaderValue = req.headers['x-forwarded-for'];
return ffHeaderValue || req.connection.remoteAddress;
});
@kleinron
kleinron / tcp_dump.sh
Last active July 16, 2017 10:22
tcpdump specific port
sudo tcpdump -i eth0 'port 8888' -w ./port8888.pcap
@kleinron
kleinron / dir_stat.py
Created November 25, 2015 10:20
Directory stats in Python
import os
import sys
import datetime
class ModCounter(object):
def __init__(self, n, start=None, on_zero_handler=None):
self._n = n
self._counter = start if start else 0
self._on_zero_handler = on_zero_handler if on_zero_handler else lambda: None
@kleinron
kleinron / couchbase_creds.sh
Created December 6, 2015 14:45
Display CouchBase credentials
sudo /opt/couchbase/bin/erl -noinput -eval 'case file:read_file("/opt/couchbase/var/lib/couchbase/config/config.dat") of {ok, B} -> io:format("~p~n", [binary_to_term(B)]) end.' -run init | grep cred