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
| # -*- mode: ruby -*- | |
| # vi: set ft=ruby : | |
| Vagrant.configure("2") do |config| | |
| config.vm.box = "bento/ubuntu-18.04" | |
| config.vm.network "private_network", ip: "192.168.33.10" | |
| config.vm.provision "shell", inline: <<-SHELL | |
| curl -fsSL https://get.docker.com -o get-docker.sh | |
| sh get-docker.sh | |
| usermod -aG docker vagrant |
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 Semaphore(max) { | |
| var counter = 0; | |
| var waiting = []; | |
| var take = function() { | |
| if (waiting.length > 0 && counter < max){ | |
| counter++; | |
| let promise = waiting.shift(); | |
| promise.resolve(); | |
| } |
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 Semaphore(max) { | |
| // 排他制御のためのセマフォ | |
| // https://gist.github.com/Gericop/e33be1f201cf242197d9c4d0a1fa7335 | |
| var counter = 0; | |
| var waiting = []; | |
| var take = function() { | |
| if (waiting.length > 0 && counter < max){ | |
| counter++; |
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 'psych' # to_yamlを使うため | |
| def table_name(line) | |
| line.scan(/create_table :(.+), comment: \"(.+)"/) | |
| $LOCALE["ja"]["activerecord"]["models"][$1] = $2 | |
| $LOCALE["ja"]["activerecord"]["attributes"][$1] = {} | |
| $1 | |
| end | |
| def column_name(line) |
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.glob("./*.csv") do |f| | |
| p f | |
| `mv #{f} #{f}.bak` | |
| `nkf -W -s #{f}.bak > #{f}` | |
| 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
| require 'tempfile' | |
| require 'fileutils' | |
| tables = %w| | |
| table1 | |
| table2 | |
| table3 | |
| table4 | |
| table5 | |
| table6 |
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
| #ディスプレイ番号を指定すれば別のコンソールからも起動可能 | |
| # cronの @reboot に書けば自動でブラウザ起動 | |
| DISPLAY=:1 chromium --kiosk |
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
| ffmpeg -i in.MOV -vcodec copy out.mp4 |
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
| dir1 = ARGV[0] | |
| dir2 = ARGV[1] | |
| Dir.glob("#{dir1}/*").sort.each do | file | | |
| filename = File.basename(file) | |
| puts "#{file} vs #{dir2}/#{filename} :" | |
| puts `sdiff -bBWs #{file} #{dir2}/#{filename}` #side-by-sideで差分のある行だけを表示 | |
| 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
| <?php | |
| // SwiftのtimeIntervalSinceReferenceDateは'2001-01-01 00:00:00 UTC'からの経過秒数を返すため | |
| // phpでは'2001-01-01 00:00:00 UTC'のUnixタイムを加算して日付に変換する。 | |
| // see: https://developer.apple.com/documentation/foundation/nsdate/1417376-timeintervalsincereferencedate$reference_time = strtotime('2001-01-01 00:00:00 UTC'); | |
| $reference_time = strtotime('2001-01-01 00:00:00 UTC'); | |
| $swift_time = 541047955; //example | |
| $d = date("Y/m/d H:i:s",$swift_time + $reference_time ); | |
| var_dump($d); //string(19) "2018/02/23 03:05:55" |