Skip to content

Instantly share code, notes, and snippets.

@pollingj
pollingj / timex_date_json.ex
Created April 6, 2016 15:09 — forked from arjan/timex_date_json.ex
Automatically encode Timex datetimes as ISO in JSON
defimpl Poison.Encoder, for: Timex.DateTime do
use Timex
def encode(d, _options) do
fmt = Timex.format!(d, "{ISO}")
"\"#{fmt}\""
end
end
# == Paperclip without ActiveRecord
#
# Simple and lightweight object that can use Paperclip
#
#
# Customized part can be extracted in another class which
# would inherit from SimplePaperclip.
#
# class MyClass < SimplePaperclip
# attr_accessor :image_file_name # :<atached_file_name>_file_name
ENV["WATCHR"] = "1"
system 'clear'
def growl(message)
growlnotify = `which growlnotify`.chomp
title = "Watchr Test Results"
puts message
image = message.match(/\s0\s(errors|failures)/) ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed.png"
options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
system %(#{growlnotify} #{options} &)