Skip to content

Instantly share code, notes, and snippets.

@JFickel
JFickel / initializer.coffee
Last active December 30, 2015 17:59
How do I make an Ember initializer for current user? My backend has a /users/current route that simply spits out a serialized current_user. This works, but it fails when there's no current user because Ember tries to build a user model using the nil current_user. Seems kinda messy
Gameway.initializer
name: 'currentUser'
initialize: (container, application) ->
store = container.lookup('store:main')
user = store.find('user', 'current')
# user = Gameway.User.find('current')
container.lookup('controller:currentUser').set('content', user)
container.typeInjection('controller', 'currentUser', 'controller:currentUser')
@JFickel
JFickel / rover.rb
Last active December 30, 2015 13:09
class RoversController
attr_accessor :grid, :rovers
def initialize(x, y)
@rovers = []
end
def add_rover(x, y, direction)
@rovers << Rover.new({x: x.to_i, y: y.to_i}, direction)
end
@import bourbon
@import layout
@import components
@import groups
@import home
@import teams
@import tournaments
@import users
@JFickel
JFickel / error.sh
Last active December 26, 2015 19:29 — forked from anonymous/error.sh
[1] pry(main)> f = FactoryGirl.build(:tournament, :with_teams, teams: 20)
(0.3ms) BEGIN
User Exists (0.9ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'example1@example.com' LIMIT 1
User Exists (0.5ms) SELECT 1 AS one FROM "users" WHERE "users"."username" = 'example1' LIMIT 1
SQL (4.2ms) INSERT INTO "users" ("created_at", "email", "encrypted_password", "first_name", "last_name", "updated_at", "username") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id" [["created_at", Mon, 28 Oct 2013 18:06:58 UTC +00:00], ["email", "example1@example.com"], ["encrypted_password", "$2a$04$pQOTHk9MXOUE8ayPjkFzmOg/ZW5j0VjyEPmz0PbTgJJc0qGs5A7Ii"], ["first_name", "Maggie"], ["last_name", "Gerlach"], ["updated_at", Mon, 28 Oct 2013 18:06:58 UTC +00:00], ["username", "example1"]]
PgSearch::Document Load (0.9ms) SELECT "pg_search_documents".* FROM "pg_search_documents" WHERE "pg_search_documents"."searchable_id" = $1 AND "pg_search_documents"."searchable_type" = $2 ORDER BY "pg_search_documents"."id" ASC
Started PUT "/tournaments/1" for 127.0.0.1 at 2013-10-14 14:13:24 -0700
Processing by TournamentsController#update as */*
Parameters: {"position"=>["0", "0", "1"], "id"=>"1"}
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
Tournament Load (0.4ms) SELECT "tournaments".* FROM "tournaments" WHERE "tournaments"."id" = $1 LIMIT 1 [["id", "1"]]
UserShowing Load (0.6ms) SELECT "user_showings".* FROM "user_showings" WHERE "user_showings"."match_id" = $1 [["match_id", 1]]
User Load (0.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 3]]
(0.3ms) BEGIN
SQL (0.4ms) INSERT INTO "matches" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id" [["created_at", Mon, 14 Oct 2013 21:13:24 UTC +00:00], ["updated_at", Mon, 14 Oct 2013 21:13:24 UTC +00:00]]
(1.9ms) COMMIT
$('.bracket').on('click', 'button.slot', () ->
$.ajax(
type: 'PUT'
url: $('.update_path').text()
data:
position: $(this).data('position')
)
)
@JFickel
JFickel / heroku_logs
Last active December 25, 2015 00:49
assets server error
2013-10-08T20:44:16.760191+00:00 heroku[router]: at=info method=GET path=/assets/application-0ed3cb110cbd2ae74d81b60e04f9f744.js host=gameway-alpha-staging.herokuapp.com fwd="24.130.138.116" dyno=web.1 connect=0ms service=6ms status=404 bytes=1351
2013-10-08T20:44:34.884306+00:00 heroku[router]: at=info method=GET path=/assets/application-65a6873c164edca62ed35f80f75bb8ab.css host=gameway-alpha-staging.herokuapp.com fwd="24.130.138.116" dyno=web.1 connect=1ms service=8ms status=404 bytes=1351
2013-10-08T20:44:34.882168+00:00 app[web.1]: I, [2013-10-08T20:42:50.857986 #2] INFO -- : Started GET "/users/auth/facebook" for 24.130.138.116 at 2013-10-08 20:42:50 +0000
2013-10-08T20:44:34.882168+00:00 app[web.1]: I, [2013-10-08T20:42:50.858620 #2] INFO -- omniauth: (facebook) Request phase initiated.
2013-10-08T20:44:34.882168+00:00 app[web.1]: I, [2013-10-08T20:44:06.359183 #2] INFO -- : Started GET "/users/auth/facebook" for 24.130.138.116 at 2013-10-08 20:44:06 +0000
2013-10-08T20:44:34.882168+00:00 app[web.1]:
@JFickel
JFickel / main.rb
Last active December 24, 2015 06:29
Twitch.tv Spellchecker
require_relative "spellchecker"
spellchecker = SpellChecker.new
while true
print '> '
word = gets.chomp
puts spellchecker.suggest(word)
end
@JFickel
JFickel / index.html
Last active December 19, 2015 06:29 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>