Skip to content

Instantly share code, notes, and snippets.

package main
import (
"encoding/json"
"fmt"
"io/ioutil"
)
type Policy struct {
Name string
@znbailey
znbailey / gist:5499954
Last active December 16, 2015 21:29
trying to get ISO8601 dates in dropwizard JSON
@Override
public void run(ApiServiceConfiguration config, Environment env) throws Exception {
...
// works
env.getObjectMapperFactory().setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"));
// works
env.getObjectMapperFactory().setDateFormat(new ISO8601DateFormat.getInstance());
// doesn't work
env.getObjectMapperFactory().setDateFormat(ISO8601DateFormat.getInstance());
...
@znbailey
znbailey / input.json
Created July 13, 2012 03:53 — forked from rjurney/input.json
Fill in blanks in a time series in Javascript where the range of the data is "00"-"23"
[{"total":16,"sent_hour":"08"},{"total":16,"sent_hour":"09"},{"total":24,"sent_hour":"10"},{"total":14,"sent_hour":"11"},{"total":6,"sent_hour":"12"},{"total":22,"sent_hour":"13"},{"total":32,"sent_hour":"14"},{"total":14,"sent_hour":"15"},{"total":10,"sent_hour":"16"},{"total":10,"sent_hour":"17"},{"total":4,"sent_hour":"18"},{"total":8,"sent_hour":"20"},{"total":6,"sent_hour":"21"},{"total":20,"sent_hour":"22"},{"total":2,"sent_hour":"23"}]
@znbailey
znbailey / bash_bookmarks.sh
Created February 18, 2011 23:31
Add this to your .bashrc or .bash_profile to set up "bookmarks" for your directories. When in a directory, type "s <name>" to store the current path as a bookmark with that name. To move to a bookmark, type "g <name>". Tab completion also works! To l
# Add this to your .bashrc or .bash_profile to set up "bookmarks" for your directories.
# When in a directory, type "s <name>" to store the current path as a bookmark with that name.
# To move to a bookmark, type "g <name>". Tab completion also works!
# To list all bookmarks, type "l".
#
# Credit to: Karthick from http://www.huyng.com/archives/quick-bash-tip-directory-bookmarks/492/
function s {
cat ~/.sdirs | grep -v "export DIR_$1=" > ~/.sdirs1
mv ~/.sdirs1 ~/.sdirs
@znbailey
znbailey / shortest_lines.rb
Created February 7, 2011 21:54
Outputs the n shortest lines from a file
num_longest = ARGV[1].to_i
longest_lines = []
shortest_len = -1
infile = File.new(ARGV[0], "r")
while ( line = infile.gets )
unless line.length > shortest_len
continue
end