Skip to content

Instantly share code, notes, and snippets.

View danslimmon's full-sized avatar

Dan Slimmon danslimmon

View GitHub Profile
@danslimmon
danslimmon / degrees_to_mindec.py
Created March 5, 2014 16:21
Test cases for converting a floating-point number of degrees to the format DDDMM.MMM where 'DDD' is the up-to-three-digit number of degrees and 'MM.MMM' is the 0-padded number of minutes to exactly three decimal places.
test_cases = [
{'in': (31.21972,), 'out': '3113.183'},
{'in': (149.999999,), 'out': '15000.000'},
{'in': (-179.999999,), 'out': '18000.000'},
{'in': (-7.000991,), 'out': '-0700.059'},
{'in': (3.141593,), 'out': '0308.496'},
{'in': (0.0,), 'out': '0000.000'},
{'in': (-0.999999,), 'out': '-0100.000'},
{'in': (-86.83141,), 'out': '-8649.885'},
]
evl='val$q=%q(puts q(10210/{1 if1==21}}/.i resce##/
1 "[13,213].ay|s|.siz}#"#")gsub(\d/){["=\47eval$q=%q(#q)#\47##47
",:eval,:instan_,"||9"][eval$&]}
exit)#'##'
instance_eval=eval$q=%q(puts %q(10210/#{1 1 if 1=21}/.i rescue##/
1 1"[13,213].max_by|s|ssize}#"#").gsub(/\d/){["=\47eval$q=q(#$q)#\47#\47
@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
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({