Skip to content

Instantly share code, notes, and snippets.

@directionless
directionless / gist:cc561241acfeee98020d
Created May 12, 2015 17:16
Python describing functions
class TestClass(object):
STRINGS={}
STRINGS["func1"] = lambda t: "func1 {0}".format(t)
def func1(self, t):
return "I did func1"
STRINGS["func2"] = lambda t: "func2 {0}".format(t)
def func2(self, t):
return "I did func2"
@directionless
directionless / firefox.txt
Created May 13, 2015 15:28
Simple python server
get
<__main__.RequestHandler instance at 0x104e677a0>
['MessageClass', '__doc__', '__init__', '__module__', 'address_string', 'client_address', 'close_connection', 'command', 'connection', 'date_time_string', 'default_request_version', 'disable_nagle_algorithm', 'do_GET', 'do_POST', 'end_headers', 'error_content_type', 'error_message_format', 'finish', 'handle', 'handle_one_request', 'headers', 'log_date_time_string', 'log_error', 'log_message', 'log_request', 'monthname', 'parse_request', 'path', 'protocol_version', 'raw_requestline', 'rbufsize', 'request', 'request_version', 'requestline', 'responses', 'rfile', 'send_error', 'send_header', 'send_response', 'server', 'server_version', 'setup', 'sys_version', 'timeout', 'version_string', 'wbufsize', 'weekdayname', 'wfile']
127.0.0.1 - - [13/May/2015 11:28:17] "GET / HTTP/1.1" 200 -
@directionless
directionless / solar notes.md
Last active February 11, 2016 15:45
Notes about Solar (Massachusetts, circa 2014)

I wrote this in Feburary 2014, as a note to a friend, about solar. Though the market has changed, it might be useful to you.


My partner and I bought a house a couple years ago, and our roof is pretty ideal for solar. This fall, we spent awhile trying to understand the options, and we completed our installation in December. How programs work vary by state and year.

@directionless
directionless / example1.rb
Last active February 9, 2017 06:06
Ruby CSV Converters What's Wrong
require 'csv'
CSV::Converters[:num2] = lambda do |num|
puts "Converter called with #{num}"
return num unless num.is_a?(Numeric)
sprintf('%.2f', num)
end
CSV.instance($stdout,
{ headers: [:name, :val] , write_headers: true,
@directionless
directionless / pg_dump_cleaner.pl
Created February 28, 2017 15:54
Postgres Dump Sanitizer
#!/usr/bin/perl
# We'd like to have a sanitized/elided copy of the database suitable
# for letting various people run reporting against. Thus, we need to
# strip out sensitive or noisy data.
#
# One "obvious" way to do that is with a table by table
# pg_dump. Unfortunatly, that ends up omiting the non-table data (like
# views) which we do need. thus, we have this awkward script.
#
@directionless
directionless / hash_formatter.rb
Created February 12, 2019 18:28
rails hash log formatter
class HashFormatter
def parse_json(string)
JSON.parse(string)
rescue
nil
end
def call(severity, timestamp, progname, msg)
base_struct = {
severity: severity,
@directionless
directionless / main.cpp
Created February 16, 2019 06:49
boost::algorithm::split_regex hangs and consumes CPU on dangling alternatives
#include <stdlib.h>
#include <iostream>
#include <boost/regex.hpp>
#include <boost/algorithm/string/regex.hpp>
int main() {
// Works
{
@directionless
directionless / main.go
Created September 17, 2019 15:48
Playing with go subcommand styles
// Some snippets of how I'm current doing subcommands.
package main
type subCommand struct {
Name string
Command func(context.Context, []string) error
Description string
}
@directionless
directionless / README.md
Last active May 19, 2022 07:47
osquery manual release notes