$ mkdir file_field_test1
$ cd file_field_test1
$ mkdir -p case1/foo
$ mkdir -p case2/foo
$ touch case1/foo/foo.txt
$ touch case2/foo/foo.txt
$ touch case2/bar.txt
This file contains hidden or 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 'benchmark' | |
n = 50_000 | |
Benchmark.bm do |x| | |
x.report { n.times{ I18n.t('controller.acquisitions.cancel_execution') } } | |
x.report { n.times{ I18n.t(:cancel_execution, scope: 'controller.acquisitions') } } | |
x.report { n.times{ I18n.t(:cancel_execution, scope: "controller.acquisitions") } } | |
x.report { n.times{ I18n.t(:cancel_execution, scope: [:controller, :acquisitions]) } } | |
end |
This file contains hidden or 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
# Usage: | |
# $ GCP_PROJECT=... ruby update-fwrules4appsscript.rb | |
# | |
# See https://cloud.google.com/appengine/kb/#static-ip | |
APP_ENGINE_IP_RANGE = (8000...9000) | |
def run(cmd) | |
puts cmd | |
raise "Failed to #{cmd}" unless system(cmd) | |
end |
This file contains hidden or 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
# Summarize JSON structure | |
# cat source.json | ruby sum_json.rb --key-pattern '\A\-|\-test\z' --format json | |
require 'json' | |
require 'yaml' | |
require 'getoptlong.rb' | |
parser = GetoptLong.new | |
parser.set_options( | |
['--key-pattern', '-k', GetoptLong::OPTIONAL_ARGUMENT], |
This file contains hidden or 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
## ねらい | |
プログラミング言語の習得に取り掛かろうとすると腰が重くなることってありますよね。 | |
しかし、種類の異なるプログラミング言語を理解して、その長所を理解すると、元々知っていた言語でのプログラミングについての理解が深まることもあります。 | |
ここでは普段DelphiやAIRを使っている皆さんの視界をちょっとだけ広げるために、いくつかの言語の特徴をお話します。 | |
## Erlang | |
携帯電話とかを作っているエリクソンが作った言語です。 | |
https://www.erlang.org/ |
This file contains hidden or 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
package main | |
import "fmt" | |
func main() { | |
foo := map[bool]string{true: "OK", false: "NG"}[2 > 1] | |
fmt.Printf("foo: %v\n", foo) | |
} |
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"sync" | |
) | |
type Fetcher interface { | |
// Fetch returns the body of URL and | |
// a slice of URLs found on that page. |
This file contains hidden or 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
#!/usr/bin/env ruby | |
# coding: utf-8 | |
# | |
# ## Setup | |
# gem install vpim activesupport | |
# | |
# ## Usage | |
# ENCODING=SJIS vcard_to_csv.rb input.vcf > path/to/output.csv | |
# | |
# input.vcf は連絡先アプリ(Address Book)のグループなどから出力したファイル |
This file contains hidden or 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
# coding: utf-8 | |
class DeviseCreateUsers < ActiveRecord::Migration[5.0] | |
def change | |
create_table :users, comment: 'ユーザ' do |t| | |
## Database authenticatable | |
t.string :email, null: false, default: "", comment: 'メールアドレス' | |
t.string :encrypted_password, null: false, default: "", comment: '暗号化済みパスワード' | |
(snip) | |
end | |
end |
This file contains hidden or 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
$ LANG=ja_JP.sjis grep -rn `echo 検索文字列 | nkf -s` . | nkf -w |