Skip to content

Instantly share code, notes, and snippets.

View gogogarrett's full-sized avatar

Garrett Heinlen gogogarrett

  • Netflix
  • San Francisco, CA
View GitHub Profile
# phoenix controller
defmodule ExWeb.Api.V3.ArcadeController do
use ExWeb.Web, :controller
alias ExWeb.{Repo, ArcadeGame, Student}
# delegating entire lobic out into a sub app/package (otp or not..)
# Here I am trying to make the `PlayArcadeGame` super generic and _not_ coupled to phoenix.
# I am trying to pass in all the required info needed up front.. but idk how this will scale
# with more complex business things.
@gogogarrett
gogogarrett / lib.play_arcade_game.ex
Last active June 11, 2016 22:50
Stand alone otp elixir application
defmodule PlayArcadeGame do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
worker(PlayArcadeGame.Workflow, []),
]
@gogogarrett
gogogarrett / service.award_acorns.ex
Created June 10, 2016 08:17
Hopscotch like service and workflows in elixir.
defmodule Service.AwardAcorns do
alias ExSeeds.{Repo, Student}
def call(student, amount \\ 3) do
student
|> ExSeeds.Student.changeset(%{acorns: student.acorns + amount})
|> Repo.update
end
end
@gogogarrett
gogogarrett / tests.acceptance.arcade-test.js
Created November 11, 2015 00:01
We are loading async content and embedding a canvas element when the component is `didInsertElement`d. We created this test waiter to make sure the canvas element is on the page and ready to go (and everything works!), but if we run more than one test at a time, it fails..!
import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from '../helpers/start-app';
import StudentProgress from "../helpers/student-progress";
var application = null;
module('Acceptance: ArcadeAuthorization', {
beforeEach () {
application = startApp();
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
actions: {
passDown: function() {
alert('passDownInApplicationController');
},
}
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
actions: {
awesomeRowMouseEnterAction: function() {
alert("this is a MouseEnter from the application controller!!");
}
}
import { moduleFor } from 'ember-qunit';
import test from 'mathseeds/tests/ember-sinon-qunit/test';
moduleFor('service:student-event', 'Unit | Service | student event', {
needs: ['model:student-event']
});
test('it works', function(assert) {
let service = this.subject();
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
@gogogarrett
gogogarrett / learning.md
Last active September 29, 2015 07:16
Learning List
  • Redis
  • MongoDB
  • Riak and/or Cassandra?
  • Set up Continuous Integration server like Jenkins/BuildKite
  • Caching headers, URL design, content negotiation, SPDY
  • Websockets
  • Are you familiar with message queues, pubsub, zeromq?
  • Do you understand basic web app security? XSS, CSRF, clickjacking, OWASP, escape-by-default templating?
  • Do you know what's involved in client-side web performance optimisation (Steve Souders' High Performance Web Sites stuff)?
  • React + Flux
@gogogarrett
gogogarrett / component.js
Last active February 9, 2016 21:58
didUpdateAttrs is not showing the correct oldAttrs. When I create a new associated object both the oldAttr and newAttr's both reflect the newly created Item in the value collection.
import Ember from 'ember';
export default Ember.Component.extend({
didUpdateAttrs: function(attrs) {
// attrs.newAttrs.ownedItems.value =>
// Class {canonicalState: Array[26], store: Class, relationship: ember$data$lib$system$relationships$state$has$many$$ManyRelationship, record: Class, currentState: Array[27]…}
// attrs.oldAttrs.ownedItems.value =>
// Class {canonicalState: Array[26], store: Class, relationship: ember$data$lib$system$relationships$state$has$many$$ManyRelationship, record: Class, currentState: Array[27]…}