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
| // SwiftのtimeIntervalSinceReferenceDateは'2001-01-01 00:00:00 UTC'からの経過秒数を返すため | |
| // jsでは'2001-01-01 00:00:00 UTC'のUnixタイムを加算して日付に変換する。 | |
| // またjsでは時刻をミリ秒単位で扱うので注意を要する。 | |
| // see: https://developer.apple.com/documentation/foundation/nsdate/1417376-timeintervalsincereferencedate | |
| process.stdin.resume(); | |
| process.stdin.setEncoding('utf8'); | |
| // Your code here! | |
| var reference_time = Date.parse('2001-01-01 00:00:00 UTC'); | |
| var swift_time = 541047955; //example | |
| var d = new Date(swift_time * 1000 + reference_time); |
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
| dir = ARGV[0] | |
| dbs = %w(d1 d2) # 複数DBに対して処理をする | |
| tables = %w(t1 t2 t3)# 複数テーブルに対して処理をする | |
| dbs.each do |d| | |
| db_name = "./dir/#{d}" # DBファイル名から拡張子を除いたもの | |
| puts db_name | |
| tables.each do |t| | |
| sql = "select * from #{t}" | |
| # h2.jarは http://repo1.maven.org/maven2/com/h2database/h2/1.4.185/h2-1.4.185.jar |
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
| # Ctrl-Cで止めてください | |
| # bashで以下を実行すると同期元と同期先の差分が調べられます。 | |
| # diff <(ls -l src/) <(ls -l dst/) | |
| require "fileutils" | |
| include FileUtils | |
| mkdir_p("src") | |
| mkdir_p("dst") | |
| t1 = Thread.start do | |
| while true do |
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
| function sort_diff() { | |
| filename=$1 | |
| echo $filename | |
| sort dst/$filename | (sort src/$filename | diff /dev/fd/3 -) 3<&0 | |
| } | |
| sort_diff sample.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
| times = [ | |
| "02h 37m 59s", | |
| "18m 43s", | |
| "09s", | |
| "09s", | |
| "09s", | |
| "09s", | |
| "09s", | |
| "09s", | |
| "09s", |
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
| class ApplicationRecord < ActiveRecord::Base | |
| self.abstract_class = true | |
| # Validationエラーの時、メッセージは出したくないが、フィールドに色はつけたいので | |
| # errors.add()でメッセージ部分にnilを入れた時はfull_messagesでメッセージが返らないようにした。 | |
| class ActiveModel::Errors | |
| def full_messages | |
| map { |attribute, message| full_message(attribute, message) if message }.delete_if{|message| message.nil?} | |
| 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
| #リモートホスト(serversman.gohannnotomo.org)の8081にアクセスが有った時にローカルホストの8081が応答するようなssh。 | |
| # 8081はmotionのストリーミングを想定 | |
| #ローカルホストから実行する | |
| ssh -N serversman.gohannnotomo.org -R 8081:localhost:8081 | |
| # 8081がhttpで喋っている場合、リモートホストから更に外部に公開したい場合はリモートホストのhttpd.confに追記 | |
| ProxyPass /motion http://localhost:8081 |
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
| # ファイルは(接頭辞)_(連番).dat という名前で作成される | |
| # ex)1024バイトのファイルを1000個作成。ファイル名は1k_(連番).dat | |
| # $ ruby mk_random_file.rb 1024 1000 1k | |
| $FILESIZE = ARGV[0].to_i # 作成したいファイルのバイト数 | |
| $FILENUM = ARGV[1].to_i # 作成したいファイルの個数 | |
| $PREFIX = ARGV[2] # ファイル名の接頭辞 | |
| seq_digits_num = $FILENUM.to_s.length | |
| 1.upto($FILENUM) do |i| |
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
| I18n.load_path.grep(/_locale_name_/) # railsならコンソールモード(rails c)で。 | |
| # 以下は例 | |
| irb(main):004:0> pp I18n.load_path.grep(/ja/) | |
| ["/var/lib/gems/2.3.0/gems/devise-bootstrap-views-0.0.11/lib/../locales/ja.yml", | |
| "/var/lib/gems/2.3.0/gems/devise-i18n-1.1.2/lib/devise-i18n/../../rails/locales/ja.yml", | |
| "/var/lib/gems/2.3.0/gems/devise-i18n-views-0.3.7/lib/../locales/ja.yml", | |
| "/var/lib/gems/2.3.0/gems/rails-i18n-5.0.4/lib/rails_i18n/../../rails/locale/ja.yml", | |
| "/var/lib/gems/2.3.0/gems/rails-i18n-5.0.4/lib/rails_i18n/../../rails/pluralization/ja.rb", | |
| "/vagrant/railsapp/config/locales/devise.views.ja.yml"] |
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
| <html> | |
| <body> | |
| <form> | |
| <input type="email"/> <!-- これだけでブラウザが簡易的なバリデーションを行う --> | |
| <input type="submit"/> | |
| </form> | |
| </body> | |
| </html> |