Skip to content

Instantly share code, notes, and snippets.

View alexdunae's full-sized avatar

Alex Dunae alexdunae

View GitHub Profile
@alexdunae
alexdunae / Gemfile
Created April 15, 2015 18:01
prawn-for-mike
# in your Gemfile
gem 'prawn'
gem 'prawn-table'
# then run bundle install
@alexdunae
alexdunae / kerene.rb
Created April 8, 2015 22:24
kerene apr 8
# goes to PagesController, home action
root 'pages#home'
class CharacterImporter
def initialize(character)
@character = character
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')
@alexdunae
alexdunae / habtm.rb
Created April 1, 2015 18:21
Raphael habtm
# 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
@alexdunae
alexdunae / seeds.rb
Last active August 29, 2015 14:16
IMG 240: Loudcloud seeds
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')
@alexdunae
alexdunae / sublime.json
Created February 25, 2015 20:53
Alex's sublime > pref > user
{
"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":
@alexdunae
alexdunae / image_fetcher.rb
Created February 11, 2015 18:11
IMG 240: ImageFetcher
# 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)
@alexdunae
alexdunae / seeds.rb
Last active August 29, 2015 14:15
IMG 240: Library seeds.rb
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')
@alexdunae
alexdunae / fb-share.coffee
Last active August 29, 2015 14:12
fb-share
initFacebook: ->
facebookLoaded = false
openShareDialog = (url) ->
FB.ui {method: 'feed', link: url}
window.fbAsyncInit = ->
facebookLoaded = true
FB.init({
@alexdunae
alexdunae / gist:1df70618b23e8c0b69da
Created December 23, 2014 20:02
IMG 240 ST3 User Preference
{
"ignored_packages":
[
"Vintage"
],
"tab_size": 2,
// Set to true to insert spaces when tab is pressed
"translate_tabs_to_spaces": true,
"trim_automatic_white_space": true,