This file contains 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 'rake' | |
require 'active_record' | |
require 'erb' | |
require 'yaml' | |
ActiveRecord::Tasks::DatabaseTasks.migrations_paths = [File.expand_path('db/migrate')] | |
module Rails | |
def self.env | |
'development' |
This file contains 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 "matrix" | |
require "readline" | |
class ToyRobot | |
PROMPT = "> " | |
PLACE = /\APLACE\s+(\d+),(\d+),(NORTH|SOUTH|EAST|WEST)\z/ | |
COMMAND = /\ALEFT|RIGHT|MOVE|REPORT\z/ | |
QUIT = /\AQUIT\z/ | |
LEFT = Matrix[[0, 1], [-1, 0]] | |
RIGHT = Matrix[[0, -1], [ 1, 0]] |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>FSM</title> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.css" type="text/css"> | |
<style> | |
body { | |
font-family: "Helvetica Neue", Helvetica, Arial, Sans-Serif; | |
margin: 0; |
This file contains 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 | |
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
gemfile(true) do |
This file contains 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 TurbolinksHelpers | |
def assert_turbolinks_redirected_to(options = {}, message = nil) | |
assert_response(:success, message) | |
assert_equal("text/javascript", @response.content_type) | |
redirect_is = @response.body[/Turbolinks.visit\("([^"]+)/, 1] | |
redirect_expected = normalize_argument_to_redirection(options) | |
assert_operator redirect_expected, :===, redirect_is, message | |
end |
This file contains 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 AddTimestampsEverywhere < ActiveRecord::Migration[5.1] | |
def change | |
now = Time.current | |
%i[ | |
candidates | |
evaluations | |
interviewers | |
questions | |
responses |
This file contains 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 "abstract_unit" | |
require "active_support/time" | |
require "time_zone_test_helpers" | |
class DateAndTimeCompatibilityTest < ActiveSupport::TestCase | |
include TimeZoneTestHelpers | |
def setup | |
@utc_time = Time.utc(2016, 4, 23, 14, 11, 12) | |
@date_time = DateTime.new(2016, 4, 23, 14, 11, 12, 0) |
This file contains 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 'date' | |
require 'time' | |
ENV['TZ'] = 'America/New_York' | |
time = Time.new(2017, 1, 1, 0, 0, 0, "+02:00").freeze | |
date = Date.new(2017, 1, 1).freeze | |
datetime = DateTime.new(2017, 1, 1, 0, 0, 0, Rational(2, 24)).freeze | |
# Time | |
puts "Time#to_time | #{RUBY_VERSION} " |
This file contains 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 'csv' | |
require 'faraday' | |
require 'json' | |
require 'uri' | |
url = URI.parse('https://petition.parliament.uk/archived/petitions.json') | |
response = Faraday.get(url) | |
unless response.success? |
This file contains 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 Postgis21 < Formula | |
desc "Adds support for geographic objects to PostgreSQL" | |
homepage "http://postgis.net" | |
url "http://pkgs.fedoraproject.org/repo/pkgs/postgis/postgis-2.1.8.tar.gz/c33923e37424978a1306ce461c1d14ed/postgis-2.1.8.tar.gz" | |
sha256 "7c2380b895fe7bda34c2e70deab3fcf4c12b13ab40d7501cdaa6fa36f1a6c662" | |
revision 1 | |
def pour_bottle? | |
# Postgres extensions must live in the Postgres prefix, which precludes | |
# bottling: https://github.com/Homebrew/homebrew/issues/10247 |