Skip to content

Instantly share code, notes, and snippets.

View hyuki's full-sized avatar

Hiroshi Yuki / 結城浩 hyuki

View GitHub Profile
@hyuki
hyuki / a.go
Created April 9, 2018 13:42
■をh1に、●をh2に変換するテスト
package main
import (
"bufio"
"fmt"
"os"
"log"
"regexp"
)
@hyuki
hyuki / a.go
Created April 10, 2018 03:30
環境変数の値を得る
package main
import (
"fmt"
"os"
)
func main() {
fmt.Printf("SALT=%s\n", os.Getenv("SALT"))
}
@hyuki
hyuki / README.md
Last active April 14, 2018 00:59
メールマガジンのepub表紙画像にVol番号をプログラムで埋め込みたい

メールマガジン用に毎回表紙画像にVol番号をプログラムで埋め込みたい

  • write-vol-to-image.rb で引数に表紙画像のベースとVol番号を与える
  • できた画像をpandocに与えてepubを作る
  • 以下に例(mm.css, metadata.xml, input.mdなどは自分で準備)
$ cp cover-base.jpg _cover.jpg"
$ ruby write-vol-to-image.rb _cover.jpg Vol.275
$ pandoc --epub-stylesheet=mm.css --epub-metadata=metadata.xml --epub-cover-image=_cover.jpg --output=output.epub input.md
@hyuki
hyuki / execute_command.go
Last active April 14, 2018 01:13
手抜きのコマンド実行。1個スペース区切りの文字列を任意個与えられ、それをつないで実行する。
package main
import (
"os/exec"
"strings"
)
func execute_command(commands ...string) {
cmd := strings.Join(commands, " ")
param := strings.Split(cmd, " ")
@hyuki
hyuki / hello.go
Created April 16, 2018 10:14
Goでshebang(的な動作)
//usr/bin/env go run $0 $@ ; exit
package main
import "fmt"
func main() {
fmt.Println("Hello")
}
// https://qiita.com/ando-masaki/items/323c6b08e07ec4538c3d
@hyuki
hyuki / lint1.go
Created April 16, 2018 10:57
簡単なテキストチェッカ(実験中。とりあえず「をを」だけを見つける)
//usr/bin/env go run $0 $@ ; exit
package main
import (
"bufio"
"fmt"
"os"
"regexp"
)
@hyuki
hyuki / kagome-sample.go
Last active April 18, 2018 12:29
kagomeを使ってみる。 See: https://github.com/ikawaha/kagome
package main
import (
"fmt"
"strings"
"github.com/ikawaha/kagome/tokenizer"
)
func main() {
@hyuki
hyuki / sample.tex
Last active April 25, 2018 08:52
数式でディスプレイスタイルとそれ以外を自動判定するLaTeXマクロはどう書くの?(コメントで解決)
\documentclass{jsarticle}
\begin{document}
\newcommand{\TEST}{(\ifinner \texttt{i} \fi%
\ifmmode \texttt{m} \fi)}
\section*{1}
$\TEST$
@hyuki
hyuki / edit.js
Created May 8, 2018 14:59
edit.js - いまいるURLの数字部分を切り出して、それに対応しているファイルを編集するためのコマンドを作って表示するブックマークレット
/*
* https://math.hyuki.net/20180508235800/ のようなページにアクセスしているとき、
* "vi ~/Documents/doc/math.hyuki.net/txt/20180508235800.txt"というコマンド文字列を表示してくれる。
*/
function start() {
if (location.href.match(/math.hyuki.net\/(\d+)/)) {
prompt('Edit Me!', 'vi ~/Documents/doc/math.hyuki.net/txt/' + RegExp.$1 + '.txt');
} else {
alert("math.hyuki.net/YYYYMMDDhhmmss is not found.");
}
@hyuki
hyuki / twitter-get-image.rb
Created May 18, 2018 04:23
twitter-get-image.rb - ツイートのURLを与えると添付画像をダウンロードするRubyスクリプト
#!/usr/bin/env ruby
# encoding: utf-8
# cf. https://qiita.com/mataneko_boy/items/852ca5484b80d2530560
require 'twitter'
require 'open-uri'
CLIENT = Twitter::REST::Client.new do |config|
config.consumer_key = "XXXXXXXXXXXXXXXXXXXXXXXXX"