Skip to content

Instantly share code, notes, and snippets.

View skoji's full-sized avatar
:octocat:
Working from home

Satoshi KOJIMA skoji

:octocat:
Working from home
View GitHub Profile
@skoji
skoji / profile.md
Created October 4, 2017 22:58
Profile

小嶋 智(こじま さとし)

テキスト処理・ページ記述言語・マークアップ言語の周辺をぐるぐるまわりながら仕事をしつつ、趣味のEPUB制作環境をちまちま作っているエンジニア。 アサガヤデンショ店長、MastodonインスタンスBookwor.ms運営者。

@skoji
skoji / mastodon-search-hashtag-and-createpage.rb
Last active January 2, 2018 12:06
userlocalのMastodonリアルタイム検索に頼ってhashtag検索結果をHTMLにする
require 'open-uri'
require 'json'
require 'nokogiri'
require 'uri'
raise 'should specify keyword' if ARGV.size < 1
keyword = ARGV[0]
title = keyword
title = ARGV[1] if ARGV.size >= 2
.latin {
font-family: HelveticaNeueLT Std, sans-serif;
}
.japanese {
font-family:'A-OTF 新ゴ Pro',A-OTF Shin Go Pro,sans-serif;
}
body {
font-family: HelveticaNeueLT Std, 'A-OTF 新ゴ Pro',A-OTF Shin Go Pro,sans-serif;
}
Containers: 5
Running: 5
Paused: 0
Stopped: 0
Images: 20
Server Version: 17.12.1-ce
Storage Driver: devicemapper
Pool Name:
Pool Blocksize: 65.54kB
Base Device Size: 10.74GB
@skoji
skoji / diff.sh
Last active April 9, 2018 06:25
Comparing UTF-8 text with git diff
git diff --word-diff-regex=$'[^\x80-\xbf][\x80-\xbf]*' --word-diff=color ...
require 'gepub'
rendition_layout = GEPUB::Book.parse(File.open('/path/to/epub/file.epub')).rendition_layout
if rendition_layout == 'pre-paginated'
puts "rendition:layout is #{rendition_layout}, which means fixed layout"
else
puts "rendition:layout is #{rendition_layout}, which means reflow"
end
// 参考: https://codereview.stackexchange.com/questions/173338/calculate-mean-median-and-mode-in-rust
use std::collections::HashMap;
fn mean(data : &Vec<i32>) -> f32 {
let mut r = 0;
for i in data {
r = r + i;
}
r as f32 / data.len() as f32
}
fn median(data: &Vec<i32>) -> i32 {
@skoji
skoji / FromEscapeToJapanese_eisuu.json
Created November 20, 2018 12:43
karabinier : ~/.config/karabiner/assets/complex_modifications/FromEscapeToJapanese_eisuu.json
{
"title": "Terminal等でESCあるいは^[で日本語入力を英数に",
"rules": [
{
"description": "Terminal, iTerm2またはMacVimでESCあるいは^[を押したときに日本語入力を英数に切り替える。",
"manipulators": [
{
"type": "basic",
"from": { "key_code": "escape", "modifiers": { "optional": [ "any" ] } },
"to": [ { "key_code": "japanese_eisuu" }, { "key_code": "escape" } ],
@skoji
skoji / update.sh
Created May 16, 2019 01:03
Update Let's Encrypt (Ubuntu 16.04)
sudo apt-get update
sudo apt-get upgrade certbot -y
# follow the instructions here https://community.letsencrypt.org/t/how-to-stop-using-tls-sni-01-with-certbot/83210
sudo certbot renew
# change e-mail
sudo certbot update_account --email <new email address>