Skip to content

Instantly share code, notes, and snippets.

View JustinAzoff's full-sized avatar

Justin JustinAzoff

View GitHub Profile
@JustinAzoff
JustinAzoff / solve.py
Last active August 6, 2022 21:04
Summer of Math Exposition 2
#!/usr/bin/env python3
from collections import defaultdict
import string
import sys
def get_words():
words = [w.strip() for w in open("wordle-nyt-allowed-guesses.txt")]
words += [w.strip() for w in open("wordle-nyt-answers-alphabetical.txt")]
words = set(words)
#!/usr/bin/env python
import os
import sys
BRO_CERT_TEMPLATE = """#auto generated
redef SSL::root_certs += {
["%(subject)s"] = "%(cert)s"
};
"""
@JustinAzoff
JustinAzoff / bro.service
Last active March 22, 2021 11:43
Broctl systemd unit
[Unit]
Description=Bro
After=network.target
[Service]
ExecStartPre=-/bro/bin/broctl cleanup
ExecStartPre=/bro/bin/broctl check
ExecStartPre=/bro/bin/broctl install
ExecStart=/bro/bin/broctl start
ExecStop=/bro/bin/broctl stop
@JustinAzoff
JustinAzoff / beat.bro
Created October 11, 2018 21:52
bro zeromq examples
event log_one (n:count)
{
Reporter::info(fmt("Hello %d", n));
if(n != 0) {
schedule 1sec { log_one(n-1) };
}
}
event bro_init()
{
@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 / log_lag.py
Last active April 6, 2018 14:19
Bro log lag
#!/usr/bin/env python
import os
import sys
import time
DEFAULT_LOG = "/usr/local/bro/logs/current/conn.log"
def config():
print """
graph_category network
@JustinAzoff
JustinAzoff / logflood.bro
Created March 1, 2018 15:31
flood bro dns log for testing.
module DNS;
event log_one (n:count)
{
local info: Info;
local id: conn_id;
id$orig_h = 1.2.3.4;
id$orig_p = 23121/udp;
id$resp_h = 5.6.7.8;
@JustinAzoff
JustinAzoff / isolation.pp
Created September 28, 2017 21:17
puppet stuff to enable linux cpu isolation
# This class defines a grub2-mkconfig exec block so that other
# classes can refresh it.
class hardware::grub {
exec { 'grub2-mkconfig':
command => '/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg',
refreshonly => true,
user => 'root',
}
}
@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"
use std::collections::HashMap;
use std::io::{self, BufRead, BufWriter};
use std::io::Write;
fn count(max_rows: usize) -> Result<(), io::Error> {
let stdin = io::stdin();
let mut counts = HashMap::new();
for line in stdin.lock().lines() {
let l = line.unwrap();
let stat = counts.entry(l).or_insert(0);