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
# Slack の入力欄に :muscle: をたくさん打ち込むスクリプト | |
# 3x3 に渡ってたくさんの muscle を自動で打ち込む | |
property channelName : "" | |
on run argv # TIPS: {"arg1", "arg2"...} と複数設定できる | |
if (count of argv) > 0 then | |
set channelName to argv | |
else | |
set channelName to "my-rails" # 未指定の場合、この値を設定 |
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
# Alfred Workflow から利用することを想定 | |
# ユーザ指定の検索キーワードがクリップボードにコピーされていることを期待 | |
# NOTE: すでにアプリケーションが起動している必要がある | |
tell application "Evernote" | |
activate | |
delay 0.2 | |
# キーストロークをシステムイベントとして送信 | |
# NOTE: 適宜 delay を入れないと操作が速すぎて 受け付けてもらえない |
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
on run argv # TIPS: {"arg1", "arg2"...} と複数設定できる | |
if (count of argv) > 0 then | |
set searchWord to argv | |
else | |
set searchWord to "test_keystroke" | |
end if | |
# NOTE: すでにアプリケーションが起動している必要がある | |
tell application "Slack" |
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) |