Skip to content

Instantly share code, notes, and snippets.

@mitaku
mitaku / TestCoin.sol
Created April 20, 2022 13:20
TestCoin
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.7;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.5.0/contracts/token/ERC20/ERC20.sol";
contract TestCoin is ERC20 {
constructor(
string memory name,
string memory symbol
) ERC20(name, symbol) {
@mitaku
mitaku / get_routings.rb
Created May 12, 2016 06:46
rails/info/routes.rb
Rails.application.routes.routes.named_routes.values.map { |v| v.path.source }
=> ["\\A/letter_opener",
"\\A/\\Z",
"\\A/users/sign_in(?:\\.([^/.?]+))?\\Z",
"\\A/users/sign_in(?:\\.([^/.?]+))?\\Z",
"\\A/users/sign_out(?:\\.([^/.?]+))?\\Z",
"\\A/users/password(?:\\.([^/.?]+))?\\Z",
"\\A/users/password/new(?:\\.([^/.?]+))?\\Z",
"\\A/users/password/edit(?:\\.([^/.?]+))?\\Z",
"\\A/users/cancel(?:\\.([^/.?]+))?\\Z",
module HogeHelper
def simple_label(model_name, column)
i18n_scope = "simple_form.labels"
t("#{model_name}.#{column}", scope: i18n_scope, default: t("defaults.#{column}", scope: i18n_scope))
end
end
# I18n.locale = :ja
# simple_label(:article, :title)
# => ja.simple_form.labels.article.titleを見に行く
Process: Python [30436]
Path: /usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/Resources/Python.app/Contents/MacOS/Python
Identifier: org.python.python
Version: 3.5.1 (3.5.1)
Code Type: X86-64 (Native)
Parent Process: zsh [633]
Responsible: iTerm [548]
User ID: 501
Date/Time: 2016-01-21 21:58:57.213 +0900
@mitaku
mitaku / diary.thor
Last active January 20, 2016 07:21
分報書くためのやつ
# NOTE
# 分報を書くためのツール
# ずっとファイルをひらっきぱなしってのも無いなと思ったので、ずっとターミナルは開いてるだろうからコマンドでかけるようにしたらいいんじゃないかと思った
# USAGE
# thor install https://gist.githubusercontent.com/mitaku/4040ca77a4f8dcc545c8/raw/3b881ac6c0faff7c75a9cc861f43a1d1f5002d71/diary.thor --as diary
# export DIARY_PATH=~/diary
# thor diary hogehgoe
class ReversibleEncryptedString < BasicObject
def initialize(str)
@str = str
end
def decrypted_string
@raw ||= ::ReversibleCryptography::Message.decrypt(@str, ::ENV["REVERSIBLE_CRYPTOGRAPY_SECRET"])
end
alias_method :to_s, :decrypted_string
@mitaku
mitaku / vim_command.md
Last active December 29, 2015 17:09
vimでふと調べたコマンドまとめ

特定文字列の数を数える

:%s/WORD/&/gn

//以降を削除

:%s;//.*;;g

先頭の空白を削除

%s/^\s*//g

@mitaku
mitaku / traverse.rb
Created August 1, 2013 04:25
ディレクトリ探索メソッド
def traverse(dir, &block)
Dir.glob("#{dir}/*").each do |f|
if File.file?(f)
block.call(dir, f)
elsif File.directory?(f)
traverse(f, &block)
end
end
end
@mitaku
mitaku / benchmark_test.rb
Last active December 17, 2015 23:29
benchmark
# RubimaTest::Application.routes.draw do
# resources :users
# root :to => "welcome#index"
# end
Benchmark.bmbm do |x|
x.report("named_helper") do
10000.times do
app.url_for(app.users_url)
end

ActionPack

Webアプリはリクエストを受け、処理をし、レスポンス(結果)を返す。 その一連の流れに必要なモジュールがまとまっているのがActionPackである

Web MVCのView, Controller部分のモジュールがまとまっている。

  • View
  • ActionView