Skip to content

Instantly share code, notes, and snippets.

View koriroys's full-sized avatar
🐢
Slow and Steady

Kori Roys koriroys

🐢
Slow and Steady
View GitHub Profile
@koriroys
koriroys / 01a_conditionals.rb
Created February 20, 2014 20:34
Ruby Scoping
#####################
# CONDITIONALS
#####################
def variables_in_passing_conditionals
special_string = "Awesome!"
if true
result = "You win!"
end
"When then do a group critique, three minutes per idea." # => "We then do a group critique, three minutes per idea."
"HTML and CSS wireframes are built using Bourbon and Neat in the browser so the team can get understand the core experience as fast as possible." # => "HTML and CSS wireframes are built using Bourbon and Neat in the browser so the team can begin to understand the core experience as fast as possible."
"Out blog is called GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS." => "Our blog is called GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS."
@koriroys
koriroys / deaf_grandma.rb
Last active August 29, 2015 13:57
Grandma is deaf!
def deaf_grandma
conversation = []
puts "Say something to Grandma, dear."
until end?(conversation) do
conversation << gets.chomp
puts response(conversation.last)
end
end
GOODBYE = ->(m) { m == "I love ya, Grandma, but I've got to go." }
# gem install artii
# gem install term-ansicolor
require 'artii'
require 'term/ansicolor'
class String
include Term::ANSIColor
end
@koriroys
koriroys / caros_first_ruby.rb
Last active August 29, 2015 14:04
Caro learns Ruby
[2] pry(main)> puts "ha" 3
SyntaxError: unexpected tINTEGER, expecting $end
[2] pry(main)> puts "ha" * 3
hahaha
=> nil
[3] pry(main)> "string 5 "
=> "string 5 "
[4] pry(main)> 5
=> 5
[5] pry(main)> "cat" + "food"
@koriroys
koriroys / login.js
Created February 3, 2015 14:24
testing ember
export default function(username, password) {
visit('/login');
fillIn('input.identification', username);
fillIn('input.password', password);
click('button.submit');
}
@koriroys
koriroys / controller.js
Created February 6, 2015 14:16
compiling a template from a controller in ember js
export default Ember.Controller.extend({
setup: function() {
var template = Handlebars.compile("<p>Name: {{userName}}</p>");
var content = template({ userName: this.get('username') });
this.set('model', this.store.createRecord('post', { content: content }));
false;
}
});
@koriroys
koriroys / example.js
Created February 11, 2015 13:25
fill in a template from a controller?
var template = get('template:example').compiledTemplateString; // how to actually do this?
var templateWithFilledInValues = template({ username: 'Mr. Whiskers', email: 'meow@example.com' });
@koriroys
koriroys / feed.js
Created February 13, 2015 10:48
specify model type
// app/serializers/feed.js
import DS from 'ember-data';
export default DS.RESTSerializer.extend({
typeForRoot: function() {
return this._super("micropost");
}
});
// app/sessions/custom.js
import Session from 'simple-auth/session';
import Ember from 'ember';
import ENV from 'hivebench-web/config/environment';
export default Session.extend({
currentUser: null,
setCurrentUser: function() {
// http://emberjs.com/guides/models/finding-records/