Skip to content

Instantly share code, notes, and snippets.

View Keita-N's full-sized avatar
🏠
Working from home

Keita-N

🏠
Working from home
View GitHub Profile
@Keita-N
Keita-N / gist:badd0b4cbe774a22d0c92a3ec9e7df43
Last active April 4, 2022 15:24
Ubuntu ホストのタイムゾーンを変更する方法

timezone を変更

sudo timedatectl set-timezone UTC

timezone の一覧を確認

timedatectl list-timezones
require 'csv'
require 'json'
lines = readlines.join('')
json = JSON.parse(lines)
puts json.first.map{ |k,v| k }.join(',')
json.each do |node|
puts node.map { |k,v| v }.join(',')
end
@Keita-N
Keita-N / gist:7fd5f565903f87d8aa013ab28ee2eb69
Created April 24, 2017 03:26
remote ブランチのheadに移動
git fetch origin
git reset --hard origin/master
@Keita-N
Keita-N / gist:0e277b811f74ae46ce94aef63ce406d7
Created April 17, 2017 07:04
postgreql upgrade 9.5 -> 9.6
brew info postgresql
```
/usr/local/Cellar/postgresql/9.5.4 (3,147 files, 35MB)
Poured from bottle on 2016-09-05 at 10:59:38
/usr/local/Cellar/postgresql/9.6.2 (3,251 files, 36.5MB) *
Poured from bottle on 2017-03-13 at 13:20:21
```
mkdir /usr/local/var/postgres9.6.2
{def f(a:Int,n:Int,m:Int):Stream[Int]=if(a==m)f(a+n,n+1,m+1)else m #::f(a,n,m+1)
f(1,2,1)}.takeWhile(_<101).foreach(println)
@Keita-N
Keita-N / index.html
Created June 16, 2015 06:38
スプライトアニメーション・サンプル
<!DOCTYPE html>
<html>
<head>
<title>Splite Animation Sample</title>
<script type="text/javascript" src="splite.js"></script>
</head>
<body>
<div id="canvasDiv"></div>
</body>
</html>
# ffmpegで動画のキャプチャを取得
ffmpeg -i input.mp4 -s 320x180 -r 10 -f image2 output-%03d.jpeg
# ImageMagickで画像を連結
convert -append output-*.jpeg conncat.jpeg
@Keita-N
Keita-N / stateMachine.js
Created June 4, 2015 12:44
State Machine Implimentation
// state machine
var stm = {
'stateA': {
events: {
'ev1': function(){
this.state = 'stateB';
// a certain action
},
'ev2': function(){
this.state = 'stateC';
@Keita-N
Keita-N / fibonacci.rb
Created January 29, 2015 02:27
SICP フィボナッチ数列 問題1.19 http://sicp.iijlab.net/fulltext/x124.html
def fib(n)
return 0 if n == 0
return 1 if n == 1
fib(n - 1) + fib(n - 2)
end
def fib2(n)
fib_iter2(1, 0, n)
end
require 'thread'
queue = Queue.new
(1..1000).each { |i| queue.push i }
threads = []
concurrency = 5
concurrency.times do |thread_id|
threads << Thread.new(thread_id) { |id|
until queue.empty?