Setup remote repository:
ssh git@example.com
mkdir my_project.git
cd my_project.git
git init --bare
On local machine:
cd my_project
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "VisualEditor0", | |
"Effect": "Allow", | |
"Action": [ | |
"ec2:DescribeNetworkInterfaces", | |
"ec2:AssignIpv6Addresses" | |
], |
# frozen_string_literal: true | |
module DigestQueries | |
def predicate_builder | |
@predicate_builder ||= super.tap do |pb| | |
pb.register_handler(Digest::Instance, DigestHandler.new(pb)) | |
end | |
end | |
class DigestHandler |
require 'rubygems' | |
require 'nokogiri' | |
require 'csv' | |
f = File.open("table.html") | |
doc = Nokogiri::HTML(f) | |
CSV.open("output.csv", 'w') do |csv| | |
doc.xpath('//table/tbody/tr').each do |row| | |
tarray = [] |
def list((head, *tail)) | |
case tail.length | |
when 0 | |
head&.fetch(:name).to_s | |
when 1 | |
"#{list [head]} & #{list tail}" | |
else | |
"#{list [head]}, #{list tail}" | |
end | |
end |
class Invoice < ApplicationRecord | |
include JsonModel::Attribute | |
json_attribute_model :payment, Payment | |
validates_associated :payment | |
end |
[:foo, :bar].map(&{ bar: "BAZ", foo: "QUUX" }) |
class UniqueCollectedValidator < ActiveRecord::Validations::UniquenessValidator | |
def initialize(options) | |
unless options[:within].present? | |
raise ArgumentError, ":within option is required to determine the unique scope's collection." | |
end | |
unless Array(options[:within]).all? { |within| within.respond_to?(:to_sym) } | |
raise ArgumentError, "#{options[:within]} is not a supported format for the :within option. " \ | |
"Pass a symbol or an array of symbols instead: `within: :profiles`" | |
end | |
super |
# lib/attachable_sti_type.rb | |
class AttachableStiType < ActiveRecord::Type::String | |
def cast_value(value) | |
if value =~ /\A([a-z]+)\/([a-z]+)\Z/ | |
"#{$2}/#{$1}_record".classify | |
else | |
super | |
end | |
end |
Setup remote repository:
ssh git@example.com
mkdir my_project.git
cd my_project.git
git init --bare
On local machine:
cd my_project