Skip to content

Instantly share code, notes, and snippets.

@Tatsh
Tatsh / log-reader.py
Created March 7, 2014 20:30
Read in a typical Apache log and parse into consumable YAML format.
#!/usr/bin/env python
import re
import sys
import yaml
line_prog = re.compile(r"""^(?P<ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) # IP Address
[^\]]+ # ? What do the numbers represent in this field(s)?
\[(?P<date>\d{1,2}\/(?:[^\/]+)\/\d{4})\: # Date
(?P<time>(?:\d{2}\:){2}\d{2}\s+[\-\+]\d{1,4})\]\s # Time
@Tatsh
Tatsh / show_dump.c
Created May 10, 2014 03:31
dumps bytes to something readable
#include "show_dump.h"
void show_dump(unsigned char *data, unsigned int len, FILE *stream) {
const static char hex[] = "0123456789abcdef";
static unsigned char buff[67]; /* HEX CHAR\n */
unsigned char chr,
*bytes,
*p,
*limit,
*glimit = data + len;
@Tatsh
Tatsh / .gitignore
Last active August 29, 2015 14:01 — forked from octocat/.gitignore
# Compiled
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc
*.pyo
__pycache__/
@Tatsh
Tatsh / README.md
Created June 2, 2014 02:16
Apache Bloodhound with virtualenv, PostgreSQL, Supervisor, uWSGI, and nginx

Install virtualenv nginx, Supervisor, PostgreSQL, and uwsgi

I recommend the latest versions for Supervisor and uwsgi. I am using nginx 1.4.7 as that is the latest available on Gentoo (unmasked for ~amd64).

Gentoo

Unmask app-admin/supervisor and www-servers/uwsgi. In the case of x86-64:

app-admin/supervisor ~amd64
@Tatsh
Tatsh / mysql_db_utils.py
Created July 30, 2014 21:48
General MySQL database utility functions.
# coding: utf-8
from sh import cat, mysql, mysqladmin, ErrorReturnCode as ShellReturnCodeError
from pipes import quote as shell_quote
import re
def _drop_create_common_args(database_name, action='create', user=None, passwd=None, host='localhost', verbose=False):
args = []
if user:
@Tatsh
Tatsh / Avery_11528_01.template.xml
Last active August 29, 2015 14:05
Avery 11528 gLabel templates. These go in `~/.config/libglabels/templates/`. Starts from the top (01) to the last. Rename to `.template`.
<?xml version="1.0"?>
<Glabels-templates xmlns="http://glabels.org/xmlns/3.0/">
<Template brand="Avery" part="11528-1" size="US-Letter" description="Avery 11528 first tab (top)">
<Label-rectangle id="0" width="13mm" height="46mm" round="0mm" x_waste="0mm" y_waste="0mm">
<Markup-margin size="1mm"/>
<Layout nx="1" ny="1" x0="198mm" y0="12mm" dx="14mm" dy="51mm"/><!-- 198 = 216 mm - width - margin -->
</Label-rectangle>
</Template>
</Glabels-templates>
@Tatsh
Tatsh / git-unclean.py
Created September 5, 2014 17:38
Recursively find all unclean directories managed by Git.
#!/usr/bin/env python
# Recursively find all unclean directories managed by Git.
from __future__ import print_function
from os import listdir
from os.path import isdir, join as path_join, realpath
import os
from sh import git
git = git.bake('-c', 'color.status=false')
@Tatsh
Tatsh / php-bash-completion.sh
Last active August 29, 2015 14:07
PHP Bash completion
# kate: hl bash
_php() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-a
-c
-n
from datetime import datetime, timedelta
from os import listdir, stat
from os.path import getsize, isdir, join as path_join, realpath
import argparse
import logging
import sys
from Crypto.Random.random import StrongRandom
from osext.filesystem import isfile

Keybase proof

I hereby claim:

  • I am tatsh on github.
  • I am tatsh (https://keybase.io/tatsh) on keybase.
  • I have a public key whose fingerprint is 60AF 74F3 88EF 4F49 31C0 8E38 1AFD 9AFC 120C 26DD

To claim this, I am signing this object: