Skip to content

Instantly share code, notes, and snippets.

View JustinAzoff's full-sized avatar

Justin JustinAzoff

View GitHub Profile
@JustinAzoff
JustinAzoff / solr_searcher.py
Created March 24, 2009 02:35
minimal client for the solr REST api
from urllib2 import urlopen
from urllib import urlencode
import simplejson
class SolrSearcher:
def __init__(self, url):
self.url = url
def search(self, q, **kwargs):
args = {'q': q, 'wt': 'json'}
class approx::server {
package {'approx':
ensure => latest;
}
config_file { "/etc/approx/approx.conf":
source => "puppet://$servername/approx/approx.conf",
require => Package['approx'],
}
#!/usr/bin/env python
# Author: Justin Lintz
# usage: ./focal_length dir
# Requiresments: dcraw http://www.cybercom.net/~dcoffin/dcraw/
import os
import sys
from subprocess import Popen, PIPE
from operator import itemgetter
DCRAW='dcraw' # or /path/to/dcraw
@JustinAzoff
JustinAzoff / gen_regex.py
Created November 8, 2011 20:28
Generate a case insensitive regex for bro
#!/usr/bin/env python
import sys
phrase = sys.argv[1]
parts = [l + l.upper() for l in phrase.lower()]
regex = ''.join(['[%s]' % part for part in parts])
print regex
@JustinAzoff
JustinAzoff / install_nfsen.sh
Created February 9, 2013 16:45
setup nfsen. from https://github.com/JustinAzoff/nfsen_box, but made to work standalone
#!/bin/sh
apt-get update
apt-get upgrade -y
apt-get install -y nfdump
apt-get install -y libapache2-mod-php5 librrds-perl libmailtools-perl libsocket6-perl rrdtool whois
if [ ! -e /etc/apache2/mods-enabled/rewrite.load ] ; then
@JustinAzoff
JustinAzoff / install_pfring.sh
Created February 11, 2013 17:38
script that I use via puppet to install pf_ring
#!/bin/sh -e
cd /var/tmp
rm -rf pf_ring_trunk*
tar xvzf /var/lib/puppet/modules/sniffer/pf_ring_trunk_2012-03-15.tgz
#fix stupid build issues with snort module
ln -sf /var/tmp/pf_ring* /root/PF_RING
@JustinAzoff
JustinAzoff / gist:5350879
Created April 10, 2013 01:04
test of dogpile.cache async_creation_runner behavior
import time
import random
import threading
from dogpile.cache import make_region
from dogpile.cache.api import NO_VALUE
def async_creation_runner(cache, somekey, creator, mutex):
''' Used by dogpile.core:Lock when appropriate '''
def runner():
try:
@JustinAzoff
JustinAzoff / nsqclient.py
Created April 17, 2013 22:27
A sort of functional NSQ python client
import time
import requests
import random
import json
class nsqd:
def __init__(self, servers):
self.last_fetch = 0
self.servers= ["http://%s/put" % h for h in servers]
@JustinAzoff
JustinAzoff / dump_rt_tickets.sh
Created July 10, 2013 16:29
Simple script that uses wget to download a usable copy of every RT ticket in HTML form. useful for disabling the web application but maintaining access to all ticket information in the standard format.
#!/bin/zsh
URL=$1
MAX=$2
echo -ne "User: "
read user
echo -ne "PW: "
read pw
wget --no-check-certificate --keep-session-cookies --save-cookies cookies.txt $URL/search/ticket?id=1 --post-data "user=$user&pass=$pw" -O/dev/null
@JustinAzoff
JustinAzoff / convert_rrd.sh
Created July 26, 2013 13:42
Script to dump and restore rrd files on another machine.
#!/bin/sh -x
# cd /path/to/application/root
# convert_rrd.sh otherhost /new/application/root
HOST=$1
DIR=$2
for f in `find -name '*.rrd'`; do
rrdtool dump $f | ssh $HOST "cat > ~/dump.xml"
ssh $HOST "cd $DIR;rrdtool restore -f ~/dump.xml $f"