Skip to content

Instantly share code, notes, and snippets.

View michaelrkn's full-sized avatar

Michael Kaiser-Nyman michaelrkn

View GitHub Profile
@michaelrkn
michaelrkn / scripts.js
Last active July 11, 2021 23:51
JavaScript for Pig Dice
var Player = {
setNumber: function(number) {
this.number = number;
},
addPoints: function(points) {
this.score += points;
},
score: 0
};

This blog post builds off the ideas started by Preston Sego, Dan Gebhardt, and many others.

Moving Past Controllers

It's been really exciting to see Ember turn a new page with its move towards modern JavaScript and slimming of its API surface. Routes rendering a template that is backed by a controller remains the most obviously clunky part of the Ember API. Getting consensus on moving query parameters and having routes load components will give us an API that we don't have to make excuses for (especially in conjunction with Component Templates Co-location).

This might go without saying, but as part of this change, the loading and error substates should render components, rather than templates.

Continuing Through the Hierarchy of Skepticism

@michaelrkn
michaelrkn / setup.sh
Last active April 6, 2019 16:29
to do: figure out how to clear databases and files nightly; make everybody save their code in a code folder or something, and don't let them write to other folders (except .gem, homebrew, etc)
# run this block as root to avoid typing password
sudo rm -rf /Applications/GarageBand.app/ /Applications/iMovie.app/ /Applications/iPhoto.app/ /User\ Information
mkdir /usr/local
curl -L https://github.com/Homebrew/homebrew/tarball/master | tar xz --strip 1 -C /usr/local
sudo chown -R epicodus /usr/local
xcode-select --install
# manually click to start command line tools install, then run everything else as current user

Address the Hierarchy of Skepticism

Like most Ember developers, I want to see Ember's marketshare and mindshare grow in 2018. At EmberConf 2017, Tom presented the Ember Hierarchy of Skepticism:

  1. Metamorph Tags/ {{bindAttr}} (addressed!)
  2. No Documentation (addressed!)
  3. Custom Object Model
  4. Big File Size
  5. Monolothic
@michaelrkn
michaelrkn / instagram.rb
Created March 20, 2013 05:41
getting the access token for instagram from the command line
require 'launchy'
CLIENT_ID = 'a3506a51a28b4d639ca680123c43f88d'
REDIRECT_URI = 'http://www.epicodus.com/'
puts 'To use InstaCommandLine, you need to grant access to the app.'
puts 'Press enter to launch your web browser and grant access.'
gets
Launchy.open "https://instagram.com/oauth/authorize/?client_id=#{CLIENT_ID}&redirect_uri=#{REDIRECT_URI}&response_type=token"
@michaelrkn
michaelrkn / say_smaller.rb
Created September 3, 2013 18:18
a simple example of recursion
def say_smaller(word)
if word.length > 0
word + " " + say_smaller(word[0..-2])
else
""
end
end
puts say_smaller("piglet")
def factorial(number)
(1..number).inject(&:*) || 1
end
@michaelrkn
michaelrkn / spacing.js
Created August 10, 2013 20:31
epicodus javascript spacing guide
// include a space after most keywords (eg var, if, else, for, return)
var foo = "bar";
// include a space around operators
foo === "bar";
foo += "qux";
// put a space after most closing parentheses
// indent within if statements
@michaelrkn
michaelrkn / js-cheat-sheet.js
Created August 10, 2013 20:13
js cheat sheet
// VARIABLES
// assign a variable to something - use the `var` keyword
var myVariable = "i love variables";
// change the value of an existing variable - don't use `var`
myVariable = "i REALLY love variables";
// change the value of a variable in place
myVariable = myVariable + " - don't you?";
class Triangle
def initialize(sides)
@sides = sides
end
def type
@sides.sort!
if @sides[0] + @sides[1] <= @sides[2]
:invalid
else