This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cw = ChatWindow.new(user, other_user) | |
cw.avatar | |
cw.lasst_update | |
cw.messages.each do |m| | |
render m | |
end | |
cw.last_updated | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in your Gemfile | |
gem 'prawn' | |
gem 'prawn-table' | |
# then run bundle install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# goes to PagesController, home action | |
root 'pages#home' | |
class CharacterImporter | |
def initialize(character) | |
@character = character |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /waiters/tables_calling.json | |
# in the controller | |
# | |
# you want an array of table IDs as the output | |
def tables_calling | |
calling = [] | |
@tables.where(calling: true).each do |table| | |
calling << table.id | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'open-uri' | |
# This file should contain all the record creation needed to seed the database with its default values. | |
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). | |
#while testing use the seeds data for parsing.. | |
#when not testing create new ruby model(s) for parsing data | |
# step 0 - figure out which 'character' this is about | |
c = Character.find_or_initialize_by(name: 'Wraithshadow', server: 'Runetotem') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in a migration | |
create_table :orders_dishes do |t| | |
t.belongs_to :order, index: true | |
t.belongs_to :dish, index: true | |
end | |
# in the models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Song.destroy_all | |
soundcloud_data = [] | |
soundcloud_data << OpenStruct.new(title: 'Deep Electronics #71 - Faidel', track: '189683856') | |
soundcloud_data << OpenStruct.new(title: 'SP 109 Deepmeister', track: '176212562') | |
soundcloud_data << OpenStruct.new(title: 'Casiokids - Det Haster!', track: '24255336') | |
soundcloud_data << OpenStruct.new(title: 'Fetty Wap - Trap Queen', track: '155798913') | |
soundcloud_data << OpenStruct.new(title: 'Jon Hopkins - Form by Firelight', track: '170000664') | |
soundcloud_data << OpenStruct.new(title: 'Major Lazer & DJ Snake - Lean On (feat. MØ)', track: '193781466') | |
soundcloud_data << OpenStruct.new(title: 'Zero 7 vs Mos Def - Umi Says', track: '21694756') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"color_scheme": "Packages/User/Monokai (SL).tmTheme", | |
"enable_telemetry": "disable", | |
"ensure_newline_at_eof_on_save": true, | |
"font_size": 13.0, | |
"ignored_packages": | |
[ | |
"Vintage" | |
], | |
"rulers": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Uses Google Image Search to get an image URL for a search term. | |
# | |
# ImageFetcher.new.fetch('dog') | |
# => "http://www.cdc.gov/animalimportation/images/dog2.jpg" | |
# | |
# | |
# The `fetch` method returns an image URL, or an empty string if no image was found. | |
class ImageFetcher | |
def fetch(term) | |
url = query_url(term) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts 'Clearing any existing Item data...' | |
Item.destroy_all | |
# Learn about how `find_or_create_by` works: | |
# http://apidock.com/rails/v4.0.2/ActiveRecord/Relation/find_or_create_by | |
puts 'Adding item types...' | |
ItemType.find_or_create_by!(name: 'Magazine Article') | |
ItemType.find_or_create_by!(name: 'Book') | |
ItemType.find_or_create_by!(name: 'Movie') |