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
# Rails production setup via SQLite3 made durable by https://litestream.io/ | |
# Copy this to Dockerfile on a fresh rails app. Deploy to fly.io or any other container engine. | |
# | |
# try locally: docker build . -t rails && docker run -p3000:3000 -it rails | |
# | |
# in production you might want to map /data to somewhere on the host, | |
# but you don't have to! | |
# | |
FROM ruby:3.0.2 |
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
# frozen_string_literal: true | |
source 'https://rubygems.org' | |
gem 'activesupport' | |
gem 'minitest' | |
gem 'minitest-reporters', '>= 0.5.0' | |
gem 'rr' | |
gem 'rubocop' |
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
#!/bin/sh | |
# if you're using ZSH, change the shebang above to "#!/bin/zsh -i" | |
if [ ${#} -ne 2 ]; then | |
echo >&2 Usage: $(basename ${0}) old-version new-version | |
exit 1 | |
fi | |
home_path=$(cd ~; pwd -P) | |
old_version=${1} |
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 Pen | |
include Comparable | |
attr :serialNumber, :length | |
def initialize(serialNumber, length) | |
@serialNumber = serialNumber | |
@length = length | |
end | |
def to_s |
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
import java.util.ArrayList; | |
import java.util.Collections; | |
public class Pen implements Comparable<Pen> { | |
private String serialNumber; | |
private int length; | |
public Pen(String serialNumber, int length) { | |
this.serialNumber = serialNumber; |
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
# Regular way | |
(1..1_000_000_000).select(&:even?) | |
.map { |i| i**2 } | |
.first(10) | |
# Lazy way | |
(1..1_000_000_000).lazy | |
.select(&:even?) | |
.map { |i| i**2 } | |
.first(10) |
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
ActiveRecord::Schema.define do | |
create_table :posts do |table| | |
table.string :title | |
table.string :content | |
end | |
end | |
class Post < ActiveRecord::Base | |
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
irb(main):023:0> uri = URI('http://www.google.com') | |
=> #<URI::HTTP http://www.google.com> | |
irb(main):059:0> Net::HTTP.get(uri) | |
D, [2018-08-13T22:33:30.030400 #19738] DEBUG -- : [httplog] Connecting: www.google.com:80 | |
D, [2018-08-13T22:33:30.055285 #19738] DEBUG -- : [httplog] Sending: GET http://www.google.com:80/ | |
D, [2018-08-13T22:33:30.055377 #19738] DEBUG -- : [httplog] Header: accept-encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3 | |
D, [2018-08-13T22:33:30.055412 #19738] DEBUG -- : [httplog] Header: accept: */* | |
D, [2018-08-13T22:33:30.055579 #19738] DEBUG -- : [httplog] Header: user-agent: Ruby | |
D, [2018-08-13T22:33:30.055605 #19738] DEBUG -- : [httplog] Header: host: www.google.com | |
D, [2018-08-13T22:33:30.055646 #19738] DEBUG -- : [httplog] Data: |
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
# Configure HttpLog to capture the detail we want to know. | |
HttpLog.configure do |config| | |
# Enable or disable all logging | |
config.enabled = true | |
# You can assign a different logger | |
config.logger = Logger.new($stdout) |
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
# Install the gem | |
$ bundle install |
NewerOlder