Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
IPTABLES=/sbin/iptables
# 初期化
$IPTABLES -F
# デフォルトルール(以降のルールにマッチしなかった場合に適用するルール)設定
$IPTABLES -P INPUT DROP # 受信はすべて破棄
$IPTABLES -P OUTPUT ACCEPT # 送信はすべて許可
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", github: "rails/rails"
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", github: "rails/rails"
abc = :'a b c'
xyz = :"x y z"
__END__
% be rubocop --only Style/StringLiterals quoted_symbol.rb
Inspecting 1 file
.
1 file inspected, no offenses detected
# frozen_string_literal: true
def foo(*args, **kwargs)
end
foo(:a, :b, c: :d,
x: 1,
y: 2
)
ActiveRecord::Schema.define do
create_table :posts, force: true do |t|
end
create_table :comments, force: true do |t|
t.integer :post_id
end
end
class ApplicationRecord < ActiveRecord::Base
using Module.new {
refine Enumerable do
alias :orig_sum :sum
end
}
module Enumerable
def sum(...)
p method(:orig_sum)
end
@kamipo
kamipo / lock.rb
Last active December 15, 2020 12:10
# frozen_string_literal: true
require "mysql2"
def client
Mysql2::Client.new(
host: "localhost",
username: "root",
database: "test",
)
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", github: "rails/rails"
```bash
brew install postgresql
pg_config
mkdir -p /usr/local/var/postgres
initdb /usr/local/var/postgres -E utf8
vi /usr/local/var/postgres/postgresql.conf