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
#ディスプレイ番号を指定すれば別のコンソールからも起動可能 | |
# cronの @reboot に書けば自動でブラウザ起動 | |
DISPLAY=:1 chromium --kiosk |
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
ffmpeg -i in.MOV -vcodec copy out.mp4 |
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
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 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" |
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
// 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 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 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 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 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 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 |