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
| module PaperclipMigrations | |
| def self.included(base) | |
| base.extend ClassMethods | |
| end | |
| module ClassMethods | |
| def add_paperclip_fields(table, prefix) | |
| add_column table, "#{prefix}_file_name", :string | |
| add_column table, "#{prefix}_content_type", :string |
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
| module ActiveRecord | |
| class Base | |
| # FROM http://www.xcombinator.com/2008/08/11/activerecord-from_xml-and-from_json-part-2/ | |
| def self.from_hash( hash ) | |
| h = hash.dup | |
| h.each do |key,value| | |
| h[key].map! { |e| reflect_on_association(key.to_sym ).klass.from_hash e } if value.is_a?(Array) | |
| h[key] = reflect_on_association(key.to_sym).klass.from_hash(value) if value.is_a?(Hash) | |
| 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
| @mixin linked_image($image,$width,$height,$xoffset,$yoffset) { | |
| background: url($image) no-repeat $xoffset $yoffset; | |
| display: block; | |
| width: $width; | |
| height: $height; | |
| text-indent: -9999px; | |
| overflow: hidden; | |
| } | |
| @mixin italic_stack { | |
| font-style: italic; |
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 'digest/sha1' | |
| class Anagram | |
| attr :anagrams | |
| def initialize(file) | |
| @anagrams = {} | |
| File.open(file).each do |word| | |
| add_word_to_anagrams_hash(build_key(word.chomp),word.chomp) | |
| 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
| Given delayed jobs are run # step_definitions/common_steps.rb:1 | |
| --- | |
| - !ruby/object:Delayed::Backend::ActiveRecord::Job | |
| attributes: | |
| id: 1 | |
| priority: 0 | |
| attempts: 1 | |
| handler: |+ | |
| --- !ruby/struct:Delayed::PerformableMethod | |
| object: !ruby/object:Page |
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
| # There is more than one way to skin a cat, different coders prefer different methods. | |
| include ActionView::Helpers | |
| class Link < Struct.new(:title, :url); end | |
| a = Link.new("Google", "http://www.google.com") | |
| b = Link.new("Hacker News", "http://news.ycombinator.com") | |
| array_of_links = [a, b] |
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
| namespace :states do | |
| desc "load state names and abbreviations" | |
| task :load => :environment do | |
| states = { | |
| "Alabama" => "AL", | |
| "Alaska" => "AK", | |
| "Arizona" => "AZ", | |
| "Arkansas" => "AR", | |
| "California" => "CA", | |
| "Colorado" => "CO", |
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
| # Doubt 100% accurate answer, but seems somewhat correct. | |
| TRANSLATOR = { | |
| 1000 => 'M', | |
| 900 => 'CM', | |
| 500 => 'D', | |
| 400 => 'CD', | |
| 100 => 'C', | |
| 90 => 'XC', | |
| 50 => 'L', |
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
| # Not the fastest, but working | |
| def longest_palindrome(input_string) | |
| # default to the first letter, so we return 'a' palindrome if none found | |
| palindrome = input_string.first | |
| max = input_string.size | |
| # Windows over possible substrings and tests for a palindrome | |
| max.downto(0) do |last| | |
| 0.upto(max) do |first| | |
| substring = input_string.slice(first..last) |
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 'formula' | |
| class Stud < Formula | |
| url 'https://github.com/bumptech/stud/tarball/a9b5aca962219ef013afaa73fec4676bb7c056a3' | |
| version '0.3-a9b5aca962' | |
| homepage 'https://github.com/bumptech/stud' | |
| sha256 '448ab2d87dd69dd7db8f5c994c55b692a8748e4228865b0be5af1df41c17ca51' | |
| depends_on 'libev' | |
| #depends_on 'openssl' |
OlderNewer