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 'rack' | |
require 'rack/static' | |
class App | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
req = Rack::Request.new(env) |
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] pry(main)> require "active_support/testing/time_helpers" | |
=> true | |
[2] pry(main)> include ActiveSupport::Testing::TimeHelpers | |
=> Object | |
[3] pry(main)> travel_to("1969-01-01".to_time){ puts Time.current } | |
1969-01-01 00:00:00 +0100 |
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
@charset "utf-8"; | |
@import "normalize"; | |
html { | |
font-size: 62.5%; | |
} | |
body { | |
font-family: -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif; |
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 normal nc | |
nc -l -p 8888 | |
# in bsd nc | |
nc -l 0.0.0.0 8888 | |
# throw in a -k to keep listening to subsequent requests |
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
<script>alert('hello');</script> |
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
class RecipeForm | |
ATTRIBUTES = [:name, :cooking_time_minutes] | |
attr_reader :recipe | |
attr_accessor *ATTRIBUTES | |
def initialize(recipe) | |
@recipe = recipe | |
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
# RDoc can use a custom generator but it isn't that well documentated. Here is a | |
# sample custom generator to get you going. | |
# | |
# Ruby comes with an `rdoc` executable but most of us generate our docs via Rake. To | |
# use your custom generator with Rake do something like the following in your Rakefile.. | |
# | |
# require 'rdoc/task' | |
# require 'simple_rdoc' | |
# | |
# RDoc::Task.new('simple_doc') do |i| |
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
# A Capybara Cheatsheet |
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 rails 3 | |
Post.select(:id, :created_at).count #=> SELECT COUNT(*) FROM posts | |
# In rails 4 | |
Post.select(:id, :created_at).count #=> SELECT COUNT(id, created_at) FROM posts ... bang | |
Post.select(:id, :created_at).count(:all) #=> SELECT COUNT(*) FROM posts |
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 'pg' | |
gem 'activerecord' |
NewerOlder