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
### [apple store, appstore] | |
# キーと公開鍵認証リクエストを作成 | |
$ openssl req -newkey rsa:2048 -out server.csr -keyout server.pem -days 365 -subj '/emailAddress=your_mail_address@gmail.com/CN=YOUR NAME/C=JP' -batch -nodes | |
# キーのインポート | |
$ security import kaigi.pem | |
$ mv ~/Downloads/ios_distribution.cer kaigi.cer | |
$ openssl x509 -in kaigi.cer -inform DER -out kaigi.cer.pub -outform pem |
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
$ openssl req -new -nodes -newkey rsa:2048 -keyout server.key -batch -subj '/C=JP/ST=Tokyo/L=Tokyo/O=Company/OU=Web/CN=example.jp' > server.csr # 組織の場合 | |
$ openssl req -new -nodes -newkey rsa:2048 -keyout server.key -batch -subj '/emailAddress=your_mail_address@gmail.com/CN=YOUR NAME/C=JP' > server.csr # 個人の場合 | |
$ openssl x509 -days 3650 -req -signkey server.key < server.csr > server.crt | |
$ diff <(openssl x509 -modulus -in server.crt | grep Modulus) <(openssl rsa -modulus -in server.key | grep Modulus) | |
# csr 確認 | |
$ openssl req -text -in server.csr | |
# crt 確認 | |
$ openssl x509 -text -in server.csr |
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
#!/bin/bash -xe | |
# update apt packages | |
sudo apt-get -o Acquire::Check-Valid-Until=false update | |
## | |
# node exporter | |
## | |
version=1.0.1 |
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 'uri' | |
require 'open-uri' | |
require 'nokogiri' | |
module Traversable | |
Target = Struct.new(:url, :depth, keyword_init: true) | |
def traverse(root, max_depth = 2) | |
root_url = URI.parse(root) | |
host = root_url.host | |
targets = [Target.new(url: root_url, depth: 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 'open-uri' | |
module Concern | |
def self.extended(base) | |
base.instance_variable_set(:@__deps, []) | |
end | |
def included(base) | |
if (deps = base.instance_variable_get(:@__deps)) | |
deps << self | |
else |
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 Validatable | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
def validate(attribute, &block) | |
attr_accessor attribute unless defined?(attribute) | |
alias_method "#{attribute}_orig=", "#{attribute}=" | |
define_method("#{attribute}=") do |val| | |
self.__send__("#{attribute}_orig=", val) if block.(val) |
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 Delegatable | |
def self.included(base) | |
base.class_eval do | |
def self.delegate_method(method, to) | |
define_method(method) do |*args| | |
instance_variable_get(to).__send__(method, *args) | |
end | |
end | |
end | |
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 Gmail | |
def initialize(&block) | |
@block = block | |
@items = [] | |
end | |
def run | |
self.instance_eval(&@block) | |
@items.join(" ") | |
end | |
def cond(condition, &block) |
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 'digest/md5' | |
module SecurablePassword | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def has_secure_password(name = :password) | |
include HasSecurePassword.new(name) | |
end |