Skip to content

Instantly share code, notes, and snippets.

View rjohnsondev's full-sized avatar

Richard Johnson rjohnsondev

  • Brisbane -> London -> Melbourne
View GitHub Profile
@rjohnsondev
rjohnsondev / gist:4605551
Created January 23, 2013 13:24
Add coloured labels to logging output :D
import os
import logging
def initLogging(level = logging.DEBUG):
if "color" in os.environ["TERM"]:
logging._levelNames[logging.CRITICAL]= '\033[1m\033[91mCRITICAL\033[0m'
logging._levelNames[logging.ERROR]= '\033[91mERROR\033[0m'
logging._levelNames[logging.WARNING]= '\033[93mWARNING\033[0m'
logging._levelNames[logging.INFO]= '\033[94mINFO\033[0m'
logging._levelNames[logging.DEBUG]= '\033[92mDEBUG\033[0m'
@rjohnsondev
rjohnsondev / gist:5142166
Created March 12, 2013 11:24
Snippet I found online to quickly rename processes for easy tracking in top.
def set_proc_name(newname):
from ctypes import cdll, byref, create_string_buffer
libc = cdll.LoadLibrary('libc.so.6')
buff = create_string_buffer(len(newname)+1)
buff.value = newname
libc.prctl(15, byref(buff), 0, 0, 0)
@rjohnsondev
rjohnsondev / sub_seq.py
Last active December 23, 2015 12:59
For an arbitrary sequence of integers, identify all sub-sequences with a sum of 0.
"""
For an arbitrary sequence of integers, identify all sub-sequences
with a sum of 0.
"""
import sys
def build_tree(ints, x):
"""
### Keybase proof
I hereby claim:
* I am rjohnsondev on github.
* I am rjohnsondev (https://keybase.io/rjohnsondev) on keybase.
* I have a public key whose fingerprint is 6BDB 29B4 497E 7532 E9AA 9288 2215 D5A0 D0BB FEBF
To claim this, I am signing this object:
@rjohnsondev
rjohnsondev / Linux kernel .config
Last active January 4, 2016 14:40
Dell XPS 13 9350 - Linux kernel config to get git://anongit.freedesktop.org/drm-intel drm-intel-nightly mostly working with Ubuntu 15.10
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 4.4.0-rc6 Kernel Configuration
#
CONFIG_64BIT=y
CONFIG_X86_64=y
CONFIG_X86=y
CONFIG_INSTRUCTION_DECODER=y
CONFIG_PERF_EVENTS_INTEL_UNCORE=y
CONFIG_OUTPUT_FORMAT="elf64-x86-64"
@rjohnsondev
rjohnsondev / autocomplete.py
Created July 19, 2016 23:12
Google Cloud Platform gcloud tab completion for fish shell.
#!/usr/bin/python
# To activate: complete --command gcloud --arguments="(/home/richard/gcloud/google-cloud-sdk/autocomplete.py (commandline -cp))"
import re
import subprocess
import sys
def parse_help(h):
commands = {}
parser.add_argument(
'--mode',
default="test",
choices=["test", "launch", "populate", "worker"],
help='''What operation to run:
"test": Run in testing mode (single process, all local).
"launch": Launch and run everything.
"populate": Populate the central redis queue.
"worker": Run as a worker against the redis server.'''
)
@rjohnsondev
rjohnsondev / config.lua
Created August 8, 2017 12:21
lsyncd example config which creates a copy of file with timestamp when moved / renamed
local src = "/test_lsyncd/src"
local dest = "/test_lsyncd/dest"
timestampFiles = {
delay = 0,
maxProcesses = 99,
action = function(inlet)
local event, dstEvent = inlet.getEvent()
@rjohnsondev
rjohnsondev / lsyncd.conf
Created August 23, 2017 12:33 — forked from oscarsmx/lsyncd.conf
Multiple Server, Host Lsync Config 2016
settings {
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd-status.log",
statusInterval = 10
}
-- Slaves
targetList = {
"127.0.0.1",
@rjohnsondev
rjohnsondev / lsyncd.conf
Created August 23, 2017 12:33 — forked from oscarsmx/lsyncd.conf
Multiple Server, Host Lsync Config 2016
settings {
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd-status.log",
statusInterval = 10
}
-- Slaves
targetList = {
"127.0.0.1",