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 'pp' | |
| require 'representable/json' | |
| class Album < Struct.new(:name, :songs); end | |
| class Song < Struct.new(:title, :track); end | |
| module AlbumPresenter | |
| include Representable::JSON | |
| property :name |
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
| source 'https://rubygems.org' | |
| gem 'dropbox' |
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
| <html> | |
| <head> | |
| <style type="text/css"> | |
| label { display: block; } | |
| </style> | |
| <body> | |
| <form> | |
| <label><input type="radio" name="q" id="radio-a" value="A"> A</label> | |
| <label><input type="radio" name="q" id="radio-b" value="B"> B</label> | |
| <label><input type="radio" name="q" id="radio-c" value="C"> C</label> |
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
| 1.9.3p194 :001 > %w(a b c).each_with_object(['foo']) { nil } | |
| => ["foo"] | |
| 1.9.3p194 :002 > %w(a b c).each_with_object(['foo']) { break } | |
| => nil |
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
| adapter_version = ARGV[0] || '1.2.5' | |
| require 'rubygems' | |
| require 'active_record' | |
| gem 'activerecord-jdbcpostgresql-adapter', adapter_version | |
| require 'active_record/connection_adapters/jdbcpostgresql_adapter' | |
| if ActiveRecord::Base.respond_to?('jdbcpostgresql_connection') | |
| puts "jdbcpostgresql_connection method available in #{adapter_version}" |
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 'rubygems' | |
| gem 'nokogiri', ENV['NOKOGIRI_VERSION'] || '1.5.6' | |
| require 'nokogiri' | |
| n = Nokogiri::XML('<foo empty="" whitespace=" "/>') | |
| puts " Ruby: #{RUBY_DESCRIPTION}" | |
| puts "Nokogiri: #{Nokogiri::VERSION}" | |
| puts | |
| puts " Empty attribute value: #{n.root['empty'].inspect}" |
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 'rubygems' | |
| gem 'nokogiri', ENV['NOKOGIRI_VERSION'] || '1.5.6' | |
| require 'nokogiri' | |
| xml = <<-XML | |
| <xs:schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:ncs="http://www.nationalchildrensstudy.gov" xmlns:ncsdoc="http://www.nationalchildrensstudy.gov/doc" xmlns:xlink="http://www.w3.org/TR/WD-xlink" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.nationalchildrensstudy.gov" elementFormDefault="unqualified" attributeFormDefault="unqualified"> | |
| <xs:element ncsdoc:pii="P"/> | |
| </xs:schema> | |
| XML |
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 'pp' | |
| require 'rubygems' | |
| GEM_NAME = ARGV.pop or fail "Please give a gem name" | |
| api_result = `curl http://rubygems.org/api/v1/dependencies?gems=#{GEM_NAME}` | |
| pp Marshal.load(api_result).sort_by { |dep| Gem::Version.new(dep[:number]) }.reverse | |
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
| task :mustache_check => :environment do | |
| require 'mustache/parser' | |
| mustache_error = Struct.new(:record_type, :reference_identifier, :error_message) | |
| text_error = lambda do |text| | |
| begin | |
| Mustache::Parser.new.compile(text) | |
| nil | |
| rescue Mustache::Parser::SyntaxError => e |
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
| rm -rf threefoursix | |
| rails --version | |
| rails new threefoursix --skip-bundle | |
| cd threefoursix | |
| echo "gem 'surveyor'" >> Gemfile | |
| bundle install | |
| script/rails g surveyor:install |