Skip to content

Instantly share code, notes, and snippets.

Non-federal Acute Care Hospital Health IT Adoption

Mix.install([
  {:explorer, "~> 0.5.0"},
  {:vega_lite, "~> 0.1.4"},
  {:kino_vega_lite, "~> 0.1.1"}
])
@rogerleite
rogerleite / PlainEnglish.livemd
Created April 30, 2021 22:12
Interpret and evaluate arithmetic expressions written in plain English (Livebook Elixir)

Arithmetic expressions in plain English

Interpret and evaluate arithmetic expressions written in plain English

Example: "one plus two times four"

  • numbers are [zero-ten]
  • numbers can be negative, for example: "negative five"
  • "plus" and "times" are the only supported operations natural order of operations apply, multiply before add.
  • "negative" is optional string before the number and is not an operation "one minus two" is expressed as "one plus negative two"
@rogerleite
rogerleite / defensive-ruby.rb
Created June 12, 2019 11:32
Example of defensive ruby
# example 1: adopting default values and trying to not break things
def adapter(action)
action = action.to_sym unless action.is_a?(Symbol)
batch = {
active_products: "ProductsActive",
inactive_products: "ProductsInactive",
download_products: "ProductsDownload"
}
batch.fetch(action, "UnknownAction")
end
@rogerleite
rogerleite / gemfile_inline.rb
Created July 3, 2015 14:21
Template for ruby script with Gemfile inline and thor to map actions and arguments
#!/usr/bin/env ruby
begin
require "bundler/inline"
rescue LoadError => e
puts "You should install bundler with >= 1.10.3 version."
puts "* Current Ruby: #{`ruby -v`}"
puts "* Current Bundler: #{`gem list bundler`}"
puts "* Original Exception: \"#{e.message}\""
exit 1
@rogerleite
rogerleite / list-units
Created April 15, 2015 18:17
fleetctl list-units
UNIT MACHINE ACTIVE SUB
api_v28.web.1.service 15499c5f.../10.21.2.149 active running
dashboard_v34.web.1.service c98d2f7c.../10.21.1.230 active running
deis-builder.service 15499c5f.../10.21.2.149 activating start-post
deis-cache.service c98d2f7c.../10.21.1.230 active running
deis-controller.service 15499c5f.../10.21.2.149 active running
deis-database.service 25992000.../10.21.1.229 active running
deis-logger.service 25992000.../10.21.1.229 active running
deis-logspout.service 15499c5f.../10.21.2.149 active running
deis-logspout.service 25992000.../10.21.1.229 active running
@rogerleite
rogerleite / fluentd_links.md
Created March 19, 2015 16:24
Fluentd links
@rogerleite
rogerleite / converters.rb
Last active September 17, 2018 22:39
Ruby and CSV examples
require "csv"
require "date"
puts CSV::HeaderConverters.keys.inspect # => [:downcase, :symbol]
# Add new header converter
CSV::HeaderConverters[:remap] = lambda do |raw_value|
raw_value = raw_value.to_sym
case raw_value
when :country
@rogerleite
rogerleite / _install.md
Last active May 19, 2023 16:57
Some scripts to install things

Introduction

Some install scripts. Target to work with Ubuntu 12 or greater.

Table of Scripts

@rogerleite
rogerleite / test.sh
Created June 26, 2013 17:42
Using Shell Script to test your server
#!/bin/bash
URL=http://localhost:8080
## Unit-Testable Shell Scripts (http://eradman.com/posts/ut-shell-scripts.html)
typeset -i tests_run=0
function try { this="$1"; }
trap 'printf "$0: exit code $? on line $LINENO\nFAIL: $this\n"; exit 1' ERR
function assert {
let tests_run+=1