Skip to content

Instantly share code, notes, and snippets.

@kencoba
kencoba / yohooos.asm
Last active June 28, 2017 06:44
translate nask code in the book "OS自作入門(川合秀実)" to nasm code.
; % nasm -f bin -o yohooos.img yohooos.asm -l yohooos.lst
; 川合秀実著,「OS自作入門」のコードほぼそのまま
; TAB=4
ORG 0x7c00 ; このプログラムがどこに読み込まれるのか
; 以下は標準的なFAT12フォーマットフロッピーディスクのための記述
start: JMP entry
DB 0x90
@kencoba
kencoba / helloos2.nas
Created June 19, 2017 02:50
from "OS自作入門"
; hello-os
; TAB=4
; ..\z_tools\nask.exe helloos2.nas helloos.img
DB 0xeb, 0x4e, 0x90
DB "HELLOIPL"
DW 512
DB 1
DW 1
@kencoba
kencoba / functionPointers.c
Created June 16, 2017 05:36
Variable declarations of pointer to function.
#include <stdio.h>
#include <string.h>
// func1 returns a char.
char func1()
{
return 'a';
}
// func2 returns a pointer to char.
@kencoba
kencoba / copyDirs.sh
Created June 15, 2017 07:30
copy directory tree. exclude files.
#!/usr/bin/env zsh
if [ $# -ne 2 ]; then
echo "$# args specified" 1>&2
echo "usage: sh ./copyDir.sh from_directory to_directory" 1>&2
exit 1
fi
from_dir=$1
to_dir=$2
@kencoba
kencoba / sec_to_hms.rb
Created June 14, 2017 08:29
convert interval into hms format.
interval = gets.to_i
sec = interval % 60
hour = interval / (60 * 60)
min = (interval - (hour * 60 * 60)) / 60
printf("%02d:%02d:%02d", hour, min, sec)
@kencoba
kencoba / MarkerList.sh
Last active June 15, 2017 01:34
List up chapter markers.
#!/usr/bin/env zsh
for difffile in *.txt
do
hms=`sort -n $difffile | awk 'BEGIN{threshold = 1000} $1 < threshold {print $2}' | sort -n | head -n 1 | ruby sec_to_hms.rb`
if [[ $hms == "00:00:00" ]] then
hms=`sort -n $difffile | awk '{print $2}' | head -n 1 | ruby sec_to_hms.rb`
fi
echo "$hms ${difffile}"
done
@kencoba
kencoba / MakeDiffs.sh
Created June 14, 2017 08:27
make difference data.
#!/usr/bin/env zsh
if [ $# -ne 2 ]; then
echo "$# args specified" 1>&2
echo "usage: sh ./makeDiffs.sh marker_directory target_directory" 1>&2
echo "caution! : the subdirectories of target_directory must be same the marker_directory's subdirectories."
exit 1
fi
for marker in $1/**/*.png
@kencoba
kencoba / diffs.sh
Last active July 11, 2017 02:04
compute diffs for each png files in the directory.
#!/usr/bin/env zsh
if [ $# -ne 2 ]; then
echo "$# args specified" 1>&2
echo "usage: sh ./diffs.sh marker_filename target_directory" 1>&2
exit 1
fi
for target in $2/*.png
do
@kencoba
kencoba / mp42png.sh
Last active June 14, 2017 08:26
create thresholded images from mp4 file.
#!/usr/bin/env zsh
if [ $# -ne 2 ]; then
echo "$# args specified" 1>&2
echo "usage: sh ./mp42png.sh mp4_filename output_directory" 1>&2
exit 1
fi
( mkdir -p $2 && rm -rf $2 && ffmpeg -i $1 -r 1 -vcodec png $2/%05d.png && mogrify -threshold 50% $2/*.png )
@kencoba
kencoba / index.html
Last active June 8, 2017 01:36
Video with Chapter Marker button.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
.button {
width: 40%;
text-align: left;
}
</style>