Skip to content

Instantly share code, notes, and snippets.

@jlintz
jlintz / focal_length.py
Created December 28, 2010 00:01
Print out a count of focal lengths from canon raw image files
#!/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
focals = {}
@jlintz
jlintz / c
Created March 18, 2011 03:11 — forked from terrycojones/c
#
# c - bash directory changing functions that maintain a
# most-recently used stack.
#
# Run with -help as an argument to see invocation options, or find the
# d_usage function below.
#
# To use these functions, store this in a file someplace and
# then execute
#
@jlintz
jlintz / gist:1192247
Created September 4, 2011 04:19
Useful C debug macro
#ifdef DEBUG
#define _DEBUG(fmt, args...) printf("%s:%s:%d: "fmt, __FILE__, __FUNCTION__, __LINE__, args)
#else
#define _DEBUG(fmt, args...)
#endif
@jlintz
jlintz / gist:1721082
Created February 2, 2012 02:46
parsing command line arguments in bash
function usage() {
echo ".$0 --argument=foo --argument-two=bar"
exit 1
}
while [ "$1" != "" ]; do
param=${1%=*}
value=${1#*=}
case $param in
--argument) argument=$value
>>> import boto
>>> boto.set_stream_logger('foo')
>>> ec2 = boto.connect_ec2(debug=2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/pymodules/python2.6/boto/__init__.py", line 113, in connect_ec2
return EC2Connection(aws_access_key_id, aws_secret_access_key, **kwargs)
File "/usr/lib/pymodules/python2.6/boto/ec2/connection.py", line 79, in __init__
https_connection_factory, path)
File "/usr/lib/pymodules/python2.6/boto/connection.py", line 498, in __init__
{
"report_name" : "util",
"report_type" : "standard",
"title" : "util",
"vertical_label" : "Count",
"series" : [
{ "metric": "iostat_sdi_util", "color": "660099", "label": "sdi", "type": "line", "line_width": "2" },
{ "metric": "iostat_sdj_util", "color": "99FF00", "label": "sdj", "type": "line", "line_width": "2" },
{ "metric": "iostat_sdk_util", "color": "FF9900", "label": "sdk", "type": "line", "line_width": "2" },
{ "metric": "iostat_sdl_util", "color": "CC3300", "label": "sdl", "type": "line", "line_width": "2" }
@jlintz
jlintz / gist:5388236
Created April 15, 2013 13:55
happy birthday snakes, compile and run on production
package main
import "fmt"
func main() {
fmt.Printf("happy birthday snakes\n")
}
@jlintz
jlintz / gist:5674085
Created May 29, 2013 21:46
patch for pagerduty.coffee to remember email addresses properly
--- ./node_modules/hubot-scripts/src/scripts/pagerduty.coffee 2013-04-12 18:05:20.000000000 -0400
+++ ./custom_scripts/pagerduty.coffee 2013-05-28 14:29:25.000000000 -0400
@@ -40,8 +40,13 @@
if missingEnvironmentForApi(msg)
return
- emailNote = if msg.message.user.pagerdutyEmail
- "You've told me your PagerDuty email is #{msg.message.user.pagerdutyEmail}"
+ users = robot.brain.usersForFuzzyName(msg.message.user.name)
+ if users.length is 1
@jlintz
jlintz / gist:477697ba07e6851d161b
Last active August 13, 2017 02:44
syslog logstash filter
filter {
if [type] == "syslog" {
grok {
match => { "message" => [ "%{SYSLOGPAMSESSION}", "%{CRONLOG}", "%{SYSLOGLINE}" ] }
add_field => [ "received_at", "%{@timestamp}" ]
add_field => [ "received_from", "%{host}" ]
overwrite => [ "message" ] # After we've processed the log we dont need the raw message anymore
}
grep {
@jlintz
jlintz / gist:feb0f2f797179074b223
Created May 20, 2015 19:10
Logstash log_format for Nginx
log_format logstash_json '{ "@timestamp": "$time_iso8601", '
'"@version": "1", '
'"remote_addr": "$remote_addr", '
'"body_bytes_sent": "$body_bytes_sent", '
'"request_time": "$request_time", '
'"upstream_addr": "$upstream_addr", '
'"upstream_status": "$upstream_status", '
'"upstream_response_time": "$upstream_response_time", '
'"status": "$status", '
'"uri": "$uri", '