Skip to content

Instantly share code, notes, and snippets.

View danslimmon's full-sized avatar

Dan Slimmon danslimmon

View GitHub Profile
@danslimmon
danslimmon / regexhimself
Created January 17, 2014 15:20
You've got to make him/Regular express himself
Python 2.7.4 (default, Jul 7 2013, 10:52:14)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re.search("^([Hh]ey ?){4}$", "Hey hey hey hey") is not None
True
>>> re.search("^([Hh]ey ?){4}$", "Hey hey hey hey ") is not None
True
>>> re.search("^([Hh]ey ?){4}$", "Hey hey hey hey ") is not None
False
# Says something comforting
function comfort() {
messages[0]="I hear you."
messages[1]="I'm sorry. That's a bummer."
messages[2]="That blows."
messages[3]="Ouch. Okay, let's take a deep breath together."
messages[4]="Damn. Sounds like you're having a rough day."
messages[5]="Hey, we'll get through this together."
messages[6]="Aw man."
ind=$[$RANDOM % ${#messages[@]}]
event_chan := make(chan *FileEvent, 16)
publisher_chan := make(chan []*FileEvent, 1)
registrar_chan := make(chan []*FileEvent, 1)
danslimmon@localhost:~$ /usr/sbin/munin-node-configure --help
Usage:
munin-node-configure [options]
danslimmon@localhost:~$
@danslimmon
danslimmon / fremeusul_test.py
Last active December 29, 2015 06:59
Test of barcode learning opp creation and notification for https://github.com/danslimmon/oscar/issues/13
#!/usr/bin/python
import os
os.chdir('/var/oscar')
import sys
sys.path.append('.')
print 'sys.path: '
print sys.path
from datetime import datetime
@danslimmon
danslimmon / lumberjack.log
Created November 15, 2013 20:55
Cycling lumberjack log entries
2013/11/15 20:48:32.606758 Connected to logs.example.com:12345
2013/11/15 20:48:47.607096 Read error looking for ack: read tcp 192.168.0.14:12345: i/o timeout
2013/11/15 20:48:47.607209 Setting trusted CA from file: /etc/ssl/certs/lumberjack.crt
2013/11/15 20:48:47.607669 Connecting to logs.example.com:12345
2013/11/15 20:48:47.661692 Connected to logs.example.com:12345
2013/11/15 20:49:02.662033 Read error looking for ack: read tcp 192.168.0.14:12345: i/o timeout
2013/11/15 20:49:02.662207 Setting trusted CA from file: /etc/ssl/certs/lumberjack.crt
2013/11/15 20:49:02.662676 Connecting to logs.example.com:12345
@danslimmon
danslimmon / upgrade_lumberjack_configs.py
Last active December 28, 2015 03:49
Script that takes supervisor configs describing lumberjack commands and converts them to a new-style Go-based lumberjack config file.
#!/usr/bin/python
"""Converts Lumberjack supervisor configs to the new-style JSON configs.
USAGE: upgrade_lumberjack_configs.py SUPERVISOR_CONF [SUPERVISOR CONF ...]
Assumptions:
* All your lumberjack commands use the same --host, --port, and
--ssl-ca-path arguments"""
danslimmon@localhost:~$ /opt/lumberjack/bin/lumberjack --version
version unknown. Could be awesome.
@danslimmon
danslimmon / server.R
Created October 11, 2013 14:10
The server part of my error-tracking Shiny app.
library(shiny)
# Load the data from our CSV file
logfreq <- read.csv('portalserr.csv')
logfreq$date <- as.POSIXct(logfreq$date)
# Calculate error rate per thousand accesses
logfreq$perthou <- logfreq$error.count / logfreq$access.count * 10^3
shinyServer(function(input, output) {
output$freqPlot <- renderPlot({
@danslimmon
danslimmon / ui.R
Created October 11, 2013 13:50
Defines the browser part of my error tracking Shiny app.
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("PHP errors by time"),
sidebarPanel(
checkboxGroupInput("errors_shown", "Most common errors:", c(
"davidbowie.php:50"="lib/exosite/robot/davidbowie.php:50",
"heehaw.php:728"="inc/spoot/heehaw.php:728",