Skip to content

Instantly share code, notes, and snippets.

View aeppert's full-sized avatar

Aaron Eppert aeppert

View GitHub Profile
@aeppert
aeppert / filter.go
Created February 5, 2020 15:14
go-macaron Filter for Open Redirect attempts
// Use with:
// m.Before(filter.Filter)
//
package filter
import (
"fmt"
"net/http"
@aeppert
aeppert / SimpleAuthServer.py
Created September 26, 2019 14:03 — forked from fxsjy/SimpleAuthServer.py
SimpleAuthServer: A SimpleHTTPServer with authentication
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
import sys
import base64
key = ""
class AuthHandler(SimpleHTTPRequestHandler):
''' Main class to present webpages and authentication. '''
def do_HEAD(self):
@aeppert
aeppert / broctl_mem_total_kludge.sh
Created May 29, 2019 15:25
Kludge to add up memory when running broctl top
#!/bin/sh
broctl top | awk '{print $6}' | sed 's/M//' | tail -n +2 | paste -sd+ | bc
@aeppert
aeppert / TuneBro.py
Last active May 13, 2019 19:03
Broctl plugin to tune optimizations and system parameters on startup
import BroControl.plugin
import sys
import os
class TuneBro(BroControl.plugin.Plugin):
def __init__(self):
super(TuneBro, self).__init__(apiversion=1)
def name(self):
return "TuneBro"
#!/usr/bin/env python
#
# ~5 is average and okay
#
import os
import sys
import time
DEFAULT_LOG = "/usr/local/bro/logs/current/dns.log"
@aeppert
aeppert / send_to_slack.py
Created February 4, 2019 16:17
Slack messages via Python
import os
import socket
import slack
import slack.chat
from optparse import OptionParser, OptionGroup
G_USERNAME = 'MY_USERNAME'
G_CHANNEL = '#MY_CHANNEL'
G_API_TOKEN = 'MY_API_TOKEN'
@aeppert
aeppert / send_to_slack.go
Created February 4, 2019 16:11
Send a message to Slack
package main
import (
"os"
"fmt"
"github.com/bluele/slack"
)
var (
Version string
Build string
@aeppert
aeppert / jemalloc.spec
Created January 10, 2019 21:04
jemalloc 5.0.X RPM Spec
Name: jemalloc
Version: 5.1.0
Release: 3%{?dist}
Summary: General-purpose scalable concurrent malloc implementation
Group: System Environment/Libraries
License: BSD
URL: http://www.canonware.com/jemalloc/
Source0: https://github.com/jemalloc/%{name}/releases/download/%{version}/%{name}-%{version}.tar.bz2
Name: jemalloc
Version: 5.1.0
Release: 3%{?dist}
Summary: General-purpose scalable concurrent malloc implementation
Group: System Environment/Libraries
License: BSD
URL: http://www.canonware.com/jemalloc/
Source0: https://github.com/jemalloc/%{name}/releases/download/%{version}/%{name}-%{version}.tar.bz2
@aeppert
aeppert / librdkafka_rrpart.cc
Last active April 12, 2018 16:49
librdkafka round-robin partitioner
class RRPartitionerCb : public RdKafka::PartitionerCb {
public:
RRPartitionerCb() { partition = 0; }
int32_t partitioner_cb(const RdKafka::Topic *topic,
const std::string *key,
int32_t partition_cnt,
void *msg_opaque) {
if((partition+1) > (partition_cnt-1)) {
partition = 0;
return partition;