Skip to content

Instantly share code, notes, and snippets.

@directionless
directionless / recipe_example.rb
Created April 29, 2013 15:28
chef sneakyness for managed_directory
managed_directory nrpechef_dir do
action :nothing
notifies :restart, "service[nagios-nrpe-server]"
end
directory nrpechef_dir do
owner "root"
group "root"
mode "0755"
notifies :clean, "managed_directory[#{nrpechef_dir}]", :delayed
end
rindge:graphs seph$ ./test-irr.rb
-0.8461538461538315
-0.5233728905609968
-0.3055754160809478
-0.16941929133206396
-0.08153134104840357
-0.02240080635339052
0.018877821951107262
-1.7310946662195288
0.07055058069605046
@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 / policy.xml
Last active September 11, 2021 13:15
ImageMagick policy.xml for blocking various exploits
<!-- This is my imagemagick policy.xml file. It's a collection of various
recommendations cargo culted from around the internet to block various
exploits. It is effective in stopping CVE-2021-3781 (https://twitter.com/ducnt_/status/1434534373416574983
and https://github.com/duc-nt/RCE-0-day-for-GhostScript-9.50) -->
<policymap>
<policy domain="cache" name="shared-secret" value="passphrase" stealth="true"/>
<policy domain="coder" rights="none" pattern="EPHEMERAL" />
<policy domain="coder" rights="none" pattern="EPI" />
<policy domain="coder" rights="none" pattern="EPS" />
<policy domain="coder" rights="none" pattern="MSL" />