Skip to content

Instantly share code, notes, and snippets.

@kencoba
kencoba / .vimrc
Last active June 5, 2017 00:32
This is the current setting. sudo apt-get install vim-gnome.
" vimrc に以下のように追記
" プラグインが実際にインストールされるディレクトリ
let s:dein_dir = expand('~/.cache/dein')
" dein.vim 本体
let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim'
" dein.vim がなければ github から落としてくる
if &runtimepath !~# '/dein.vim'
if !isdirectory(s:dein_repo_dir)
@kencoba
kencoba / WhyWeNeedCommentOnSourceCode.md
Last active June 2, 2017 06:19
Why we need comment on source code?

This is a good example. Fall-through works when we don't write anything. Without comment, reader can't see whether this code is correct or mistake.

飯尾淳「C言語によるスーパーLinuxプログラミング」、ソフトバンククリエイティブ、2011、p.112 Column10 フォールスルー ... ただし、フォールスルーの活用は1点、注意が必要です。 フォールスルーとして意図的にbreak文を省略したのか、プログラマーのミスでbreak文が省略されているのか、 プログラムのロジックから区別することができません。 したがってフォールスルーを使う場合には、コメントでそれがわかるように書いておくべきでしょう。

@kencoba
kencoba / index.html
Created June 2, 2017 03:54
video tag sample.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
.button {
width: 40%;
text-align: left;
}
</style>
@kencoba
kencoba / duration.rb
Created June 1, 2017 09:59
Listing duration of mp4s.
#! /bin/sh
exec ruby -S -x "$0" "$@"
#! ruby
def h_mm_ss(sec)
min, ss = sec.to_i.divmod(60)
hh , mm = min.divmod(60)
"%dh%02dm%02ds" % [hh, mm, ss]
end
@kencoba
kencoba / tohtml.rb
Created June 1, 2017 09:58
Listing video files.
#! /bin/sh
exec ruby -S -x "$0" "$@"
#! ruby
BEGIN {
puts <<-EOS
<!DOCTYPE html>
<html>
<head>
<meta charset=\"UTF-8\">
</head>
@kencoba
kencoba / Add-Type_for_PowerPoint.ps1
Created May 15, 2017 05:52
Add-Type_for_PowerPoint.ps1
Add-Type -AssemblyName Microsoft.Office.Interop.PowerPoint
[int][Microsoft.Office.Core.MsoAutoShapeType]::msoShapeCloud
@kencoba
kencoba / Points.ps1
Created May 15, 2017 05:50
This is for control PowerPoint with PowerShell.
Class Points {
[double] $Left
[double] $Top
[double] $Width
[double] $Height
[Points] Magnify([double] $percent) {
$center_X = $this.Left + ($this.Width / 2)
$center_Y = $this.Top + ($this.Height /2)
$newWidth = $this.Width * $percent
@kencoba
kencoba / Markdown_AddHeaderNumber.awk
Last active May 12, 2017 04:38
Add header number to markdown file.
# Markdown_AddHeaderNumber
# input: Markdown.md
# output: Markdown.md added number on headers
#
# header format
#
# ```Markdown
# # 1. header
# ## 1.1. header
# ```
@kencoba
kencoba / ListUtils.java
Created May 5, 2017 05:28
A partition method.
import java.util.ArrayList;
import java.util.List;
public class ListUtils {
public static <T> List<List<T>> partition(
List<T> list,
int size) {
if (list == null) { throw new NullPointerException("List must not be null.");}
if (size <= 0) { throw new IllegalArgumentException("Size must be greater than 0.");}
@kencoba
kencoba / ConfigProducer.java
Created March 25, 2017 04:52
LocalDate injection with Producer method. this is useful for unit test.
package producer;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Properties;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;