Skip to content

Instantly share code, notes, and snippets.

View elskwid's full-sized avatar
🤡

Don Morrison elskwid

🤡
View GitHub Profile
@elskwid
elskwid / presenter.rb
Last active January 12, 2018 05:16
Simple Rails Presenter and View Presenter (so I don't forget)
# frozen_string_literal: true
module Foo
# Simple presenter module
#
# Uses Charlatan to create an `Foo::Presenter` module for use in the app.
# This isn't *strictly* a presenter - it's somewhere between a presenter,
# proxy, and/or decorator.
#
# Including `Foo::Presenter.new(:presented_thing)` in a class will
@elskwid
elskwid / domain_service.rb
Created February 11, 2016 00:27
Base service object
require "concord"
require "procto"
# Small wrapper module for domain services.
#
# Creates a service object with a ::call method that delegates to the instance
# method name given in the `call` option. Defaults to :call. (Procto)
#
# Provides initializer arguments, sets the ivars, and optional public reader
# methods for the attribute names passed in for `attrs`. (Concord)
@elskwid
elskwid / ex.scala
Created October 6, 2015 23:16 — forked from penryu/ex.scala
object Example {
def main(args: Array[String]): Unit = {
println("Scala!")
// create some values to use
// TERM: assignment
val a = 1
val b = 2
val c = 3
importPackage(java.io);
importPackage(java.lang);
System.out.println("JavaScript!");
// create some variables to use
// TERM: assignment
var a = 1;
var b = 2;
var c = 3;
@elskwid
elskwid / warmup.rb
Created April 9, 2015 23:18
Warmup for TECH603 day 6
# 1. Create a class named Country
# 2. Add read/write support for the following attributes:
# :id
# :name
# :population
# :capital
# 3. Create an instance of your Country class
@elskwid
elskwid / warmup.rb
Created April 8, 2015 00:17
Warmup for TECH603 Day 5
# 1. Create a class named Country
# 2. Add the ability to read and write an attribute named "name". This should
# be done using two methods.
# HINT: the writer method has the `=` at the end
# HINT HINT: use an ivar to store the name in the scope of the class
# 3. Create an instance of your Country class
# 4. Set the name attribute
@elskwid
elskwid / function.rb
Created April 3, 2015 00:02
TECH603 - Example function (Day 4 Quiz)
def function(a)
a = a.to_i
if a == 1
a + 5 / 2
elsif a == 2
a + 5 + 3
elsif a > 2 && a <= 1000
a
end
@elskwid
elskwid / countries.json
Created March 27, 2015 00:50
Country data for TECH603-Spring 2015 : raw data
[
{
"id": "AGO",
"name": "Angola",
"population": 21471618,
"capital": "Luanda",
"latitude": -8.81155,
"longitude": 13.242,
"income_level": "Upper Middle",
"high_income": false
# our list of countries created using a "literal" array and hashes.
countries = [
{
"id" => "AGO",
"name" => "Angola",
"population" => 21_471_618,
"capital" => "Luanda",
"latitude" => -8.81155,
"longitude" => 13.242,
"income_level" => "Upper Middle",
@elskwid
elskwid / country_1.rb
Created March 13, 2015 00:01
Country data for TECH601-Spring 2015 : One country
# Angola
country0_id = "AGO"
country0_name = "Angola"
country0_population = 21_471_618
country0_capital = "Luanda"
country0_latitude = -8.81155
country0_longitude = 13.242
country0_income_level = "Upper Middle"
country0_high_income = false