Skip to content

Instantly share code, notes, and snippets.

View cia-rana's full-sized avatar
🌌
get everyone involved

Koya IWAMURA cia-rana

🌌
get everyone involved
View GitHub Profile
@cia-rana
cia-rana / index.md
Created May 29, 2017 18:37
PDFjamによるPDFの加工

PDFjamによるPDFの加工

PDFjam はpdfLaTex用に作られたPDFファイルを加工するツールです.中身はpdfpagesパッケージを呼ぶスクリプトになっています.
PDFjamには様々な派生コマンドが用意されています.

コマンド一覧

pdfnup

複数ページあるPDFファイルをn-upします.ページは左から右,上から下に配置されます.

8upのPDFファイルを作成

@cia-rana
cia-rana / answer.rb
Created May 29, 2017 18:42
トリオミノの分類 2017.3.22 問題
$patterns = {
?J=>[[2,2],[1,5,6]],
?L=>[[2,2],[0,5,6]],
?T=>[[2,2],[0,1,6]],
?R=>[[2,2],[0,1,5]],
?I=>[[1,3],[0,5,10]],
?B=>[[3,1],[0,1,2]],
}
def solve(input)
@cia-rana
cia-rana / memo.md
Last active November 28, 2021 04:04
APNGの構造メモ

APNGの構造メモ

PNG

Portable Network Graphics。

全体構造

PNGの構造は非常に単純で、ファイルをPNG画像と認識するためのシグネチャと、様々なデータを表すチャンクからなる。

PNGの構造
シグネチャ
@cia-rana
cia-rana / primeGenerator.clojure.go
Created May 29, 2017 18:54
Prime Number Generator with Sieve of Eratosthenes in Golang
package main
import (
"fmt"
)
type PrimeGenerator struct {
Next func() uint32
}
func NewPrimeGenerator() *PrimeGenerator {
@cia-rana
cia-rana / post_pgl_ranking.rb
Created May 29, 2017 18:56
To Get Pokémon Global Link Season Ranking
require "net/http"
require "uri"
require "json"
require "pp"
def post_pgl_ranking(season_id, battle_type, page_number)
url = "https://3ds.pokemon-gl.com/frontendApi/gbu/getSeasonRanking"
uri = URI.parse(url)
timestamp = Time.now.to_i
@cia-rana
cia-rana / sauvola.py
Created May 29, 2017 18:57
sauvolaの手法による二値化
import numpy as np
import cv2
def sauvola(src, kernel_size, k, r):
''' sauvolaの手法により二値化を行う '''
height, width = src.shape[:2]
border_size = kernel_size / 2 + 1
kernel_pixels = kernel_size * kernel_size
src_with_border = cv2.copyMakeBorder(src, border_size, border_size, border_size, border_size, cv2.BORDER_REPLICATE)
@cia-rana
cia-rana / bench.py
Created May 29, 2017 18:58
実対称行列の逆行列のベンチマーク
import numpy as np
import time
time1 = 0.
time2 = 0.
for i in range(10000):
a = (np.random.rand(3,3)*2-1.0)*100
a += a.T
if a.shape[0] == a.shape[1] and np.linalg.matrix_rank(a) == a.shape[0]:
# with Builtin
@cia-rana
cia-rana / bunkasai.rb
Created May 29, 2017 18:59
「文化祭で人数と来ている方々を記録するコード」のリファクタリング
# http://qiita.com/Thenagao72/items/312b9eb9c78329825502
class Person
attr_accessor :name, :occupation
end
class Questionnaire
def initialize
@people = []
@occupation_table = { 1 => "校内生",
@cia-rana
cia-rana / orde07_7seg.rb
Created May 29, 2017 19:01
7セグパネルがよく見えない 横へな2016.9.3 問題
# http://nabetani.sakura.ne.jp/hena/orde07_7seg/
LIGHT = %w!3f 06 5b 4f 66 6d 7d 27 7f 6f!.map(&:hex)
def solve l, u
# 7セグパネルのビットが全て立っていないときは,注目桁の最小値に空白を挿入するが
# 注目桁より上位の桁の最小値の中に空白でない桁が存在するときfalseとなるフラグ
flg = true
a = l.zip(u).map.with_index{|(a,b), i|
@cia-rana
cia-rana / answer.rb
Created May 29, 2017 19:02
どきどきトロッコ
transition = {}
transition[0] = {
1 => [0, 1],
2 => [0, 2],
3 => [0, 2],
4 => [0],
5 => [0],
6 => [0, 1],
7 => [0],
8 => [],