Skip to content

Instantly share code, notes, and snippets.

View joemsak's full-sized avatar

Joe Sak joemsak

View GitHub Profile
@joemsak
joemsak / convert_duration_to_seconds.rb
Created November 12, 2020 20:18 — forked from natritmeyer/convert_duration_to_seconds.rb
Ruby ISO 8601 duration converter
require 'test/unit'
# implementation
class Duration
def in_seconds(raw_duration)
match = raw_duration.match(/PT(?:([0-9]*)H)*(?:([0-9]*)M)*(?:([0-9.]*)S)*/)
hours = match[1].to_i
minutes = match[2].to_i
seconds = match[3].to_f
seconds + (60 * minutes) + (60 * 60 * hours)
@joemsak
joemsak / states_hash.json
Created January 30, 2017 21:21 — forked from mshafrir/states_hash.json
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@joemsak
joemsak / gol.exs
Created June 3, 2016 04:30 — forked from avdi/gol.exs
Game of life in Elixir (take 1)
# Updated for 1.2.5
defmodule Life do
def run(board) when is_binary(board) do
board |> parse_board |> run
end
def run(board) do
IO.write("\e[H\e[2J")
Life.print_board board
//
// Example usage: phantomjs screenshot.js http://yahoo.com /tmp/yahoo.png
//
var system = require('system');
var url = system.args[1];
var filename = system.args[2];
var page = new WebPage();
page.open(url, function (status) {
#controller
def index
@ordered_medications = @visit.pds_prescriptions.ordered_medications.order(:label)
@prn_medications = @visit.pds_prescriptions.prn.order('start_datetime DESC')
#raise params[:print].inspect
#raise get_report_model(params[:print] == 'active').inspect
report_model = get_report_model(params[:print] == 'active')
respond_with :report_model => report_model, :visit => @visit, :print => params[:print]
end