Instantly share code, notes, and snippets.

View policies.go
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
)
type Policy struct {
Name string
View gist:5499954
@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());
...
View input.json
[{"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"}]
View bash_bookmarks.sh
# 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
View shortest_lines.rb
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