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
property statusMessageAs : "" | |
on run argv # TIPS: {"arg1", "arg2"...} と複数設定できる | |
if (count of argv) > 0 then | |
set statusMessageAs to argv | |
else | |
set statusMessageAs to "AppleScriptIsFun" | |
end if | |
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
property channelName : "" | |
on run argv # TIPS: {"arg1", "arg2"...} と複数設定できる | |
if (count of argv) > 0 then | |
set channelName to argv | |
else | |
set channelName to "my_home_channel" | |
end if | |
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 | |
require 'faker' | |
require 'json' | |
result = | |
Array.new(100).map do |i| | |
gender = %w[Male Female].sample | |
first_name, last_name = | |
if gender.eql?('Male') |
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
# 次のコードで登場する User モデルの各定数には Hash で値が代入されている + コントローラやビューで <form/> の値として使われている | |
# eg. FROZEN_FRUITS = {'0' => 'Apple', '1' => 'Banana'}.freeze | |
# values にはUser モデルの定数に定義された value 側の値が代入されている | |
# eg. ['Apple', 'Banana'] | |
# 呼び出し元はループ処理でこのメソッドを呼び出して、最終的に 条件群、パラメータ群の配列に纏めている | |
# コントローラ内で分解された params 内の Hash から Model#where で検索できる値のペアを生成する | |
def params_to_sql_fragment(field, values) |
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
# 哀しみのドットつなぎテーブル名・カラム名が View か Controller か、どこからかやってくる | |
def search(table_and_column, search_values) | |
# table_and_column : 'member_types.name' | |
# search_values : %w[foo, bar] | |
result = | |
case table_and_column | |
# New code | |
when 'member_types.name' #, 'other_attr.name', 'some_attr.name' | |
model_name = |
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
// Ref: | |
// * [Mocha - the fun, simple, flexible JavaScript test framework](https://mochajs.org/) | |
// * [Chai](https://www.chaijs.com/) | |
// Run commands as bellow: | |
// yarn install | |
// yarn run mocha --watch | |
var expect = require('chai').expect |
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
# Ref: https://github.com/gouf/scholar_ps/blob/7b4b4bbe79197cbb2683af9cae95ada7e5418c46/ScholarPs/scraper/scraper.rb#L14 | |
def process! | |
html = | |
@watir.yield_self(&method(:login!)) | |
.yield_self(&method(:loan_id_confirm!)) | |
.yield_self(&method(:findout_loan_detail!)) | |
.yield_self(&:html) | |
detail_page = Nokogiri::HTML(html) |
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
(new Intl.NumberFormat('ja-JP', { | |
style: 'currency', | |
currency: 'JPY' | |
})).format( | |
Array.from(document.querySelectorAll('span.a-price-whole').values()) | |
.map(function(v) { return v.innerText }) | |
.map(function(v) { return parseInt(v.split(',').join('')) }) | |
.reduce(function(ret, v) { return ret + v }) | |
) |
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
# | |
# 変数の宣言 | |
# | |
variable "vpc_id" { | |
type = "string" | |
default = "vpc-0a84e4b7d165f8525" | |
} | |
variable "vpc_subnet_id" { | |
type = "string" |
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 | |
# Ref: <https://en.wikipedia.org/wiki/Kiyoshi_Hikawa> | |
# Ref: <https://twitter.com/kumiromilk/status/707437861881180160> | |
# See also: <https://qiita.com/shunsugai@github/items/971a15461de29563bf90> | |
# 「ズン」「ドコ」のいずれかをランダムで出力し続けて | |
# 「ズン」「ズン」「ズン」「ズン」「ドコ」の配列が出たら | |
# 「キ・ヨ・シ!」って出力して終了 | |
class Zundoko | |
WORD_PAIR = %w[ズン ドコ] |