Skip to content

Instantly share code, notes, and snippets.

Avatar

Joe Sak joemsak

View GitHub Profile
View controller_spec.rb
#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
View screenshot.js
//
// 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) {
@joemsak
joemsak / gol.exs
Created Jun 3, 2016 — forked from avdi/gol.exs
Game of life in Elixir (take 1)
View gol.exs
# 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
@joemsak
joemsak / states_hash.json
Created Jan 30, 2017 — forked from mshafrir/states_hash.json
US states in JSON form
View states_hash.json
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
View convert_duration_to_seconds.rb
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)