Skip to content

Instantly share code, notes, and snippets.

View robyurkowski's full-sized avatar

Rob Yurkowski robyurkowski

View GitHub Profile
@robyurkowski
robyurkowski / board.rb
Created July 8, 2013 01:50
Tic Tac Toe Board
class Board
def initialize
self.squares = Array.new(9)
end
def rows
self.squares.each_slice(3)
end
App.ApplicationRoute = Ember.Route.extend
setupController: () ->
@controllerFor('discussionPosts').set('model', App.DiscussionPost.find())
[ -n "$BASH_VERSION" ] || [ -n "$ZSH_VERSION" ] || return
source /usr/local/share/chruby/chruby.sh
source /usr/local/share/chruby/auto.sh
chruby ruby-1.9.3
Meloria.Customer = DS.Model.extend({
name: DS.attr('string'),
phone: DS.attr('string'),
email: DS.attr('string'),
dateOnWaitingList: DS.attr('date'),
status: DS.attr('number'),
local: DS.attr('boolean'),
Ember.Application.initializer({
name: 'debug'
initialize: (container, app) ->
app.d = app.debug =
controller: (name) -> container.lookup("controller:#{name}")
c: (name) -> container.lookup("controller:#{name}")
route: (name) -> container.lookup("route:#{name}")
r: (name) -> container.lookup("route:#{name}")
array = %w(dog cat aardvark)
array.each {|animal| puts animal.upcase }
array.map! {|animal| animal.reverse }
array.select {|animal| animal.include? 'a' }
array.sort_by(&:length)
array << 'dog'
array.uniq!
hash = {cat: "meow", dog: "woof", aardvark: "sluuurp"}
hash.keys.join(" and ")
@robyurkowski
robyurkowski / comments_new_route.js
Last active August 29, 2015 14:03
sending reload to parent route
App.CommentsNewRoute = Ember.Route.extend({
model: function() {
return this.store.createRecord('comment', {post: this.modelFor('post')});
},
actions: {
save: function() {
var model = this.modelFor('commentsNew');
model.save().then(
private def confirm_failure(error)
self.error = error
run_failure_callbacks
end
private def run_failure_callbacks
# This line fails because on_failure responds_to #call ?!
on_failure.call(self) if on_failure.respond_to?(:call)
end
require 'active_record'
module Skywalker
class Command
################################################################################
# Class interface
################################################################################
def self.call(*args)
new(*args).call
end
@robyurkowski
robyurkowski / skywalker-slash-command.rb
Created December 9, 2014 14:21
override skywalker transaction for non-transactional ORMs
require 'skywalker/command'
module Skywalker
class Command
def transaction(&block)
block.call
end
end
end