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 / manifest.json
Created September 13, 2011 03:25
GDD2010JP DevQuiz WebGame
{
"name": "ChromeExtensionSolver",
"version": "1.0",
"description": "Open the first card and show background color of the card.",
"content_scripts": [
{
"matches": [
"http://gdd-2011-quiz-japan.appspot.com/webgame/problem*"
],
"js": [
@skoji
skoji / solve.rb
Created September 13, 2011 03:27
GDD2011JP DevQuiz 一人ゲーム solver
gets.to_i.times do
gets
nums = gets.split(' ').map(&:to_i)
queue = [[nums, 0]]
while !queue.empty?
node, ct = queue.shift
if (node.all? { |x| x % 5 == 0})
puts ct + 1
break
end
@skoji
skoji / gopng.go
Created September 13, 2011 03:38
GDD2011JP DevQuiz Go!
package main
import (
"fmt"
"io"
"strings"
"image/png"
)
func CountColor(pngdata io.Reader) int {
@skoji
skoji / gist:1539290
Created December 30, 2011 10:55
why this code won't run on ruby 1.8.7? (it runs on 1.9.3)
require 'pp'
class Bar
attr_accessor :foo_bars
def initialize(&block)
@foo_bars = []
yield self
end
def foo_bar(&block)
@skoji
skoji / builder_sample.rb
Created February 21, 2012 21:15
GEPUB::Builder API example
# -*- coding: utf-8 -*-
# GEPUB::Builder example.
require 'ruby gem'
require 'gepub'
builder = GEPUB::Builder.new {
# In the root block, you can define metadata.
# You can define title, creator(s), contributor(s), publisher(s), date, unique_identifier, identifier, language.
# Title can be specified with title, subtitle, collection, short_title, expanded_title, edition.
# You can also define description, format, relation, right, source, subject, type.
@page :first {
margin: 0;
}
@skoji
skoji / Usage
Last active December 31, 2015 12:09
遅すぎですが。 ちょっと変更しました。EPUB前提なら、XMLで読んだようがいろいろとよいのでNokogiri::HTMLではなくNokogiri::XMLにしてみました
$ gem install nokogiri
$ ruby zen-to-han.rb < source.html > destination.html
@skoji
skoji / zundoko-kiyoshi.ps
Last active March 17, 2016 04:31
ズンドコキヨシ (PostScript版、Ghostscript 9.18で動作確認)
% zundoko-kiyoshi in postscript
/Palatino-Italic findfont 40 scalefont setfont
/height 50 def
clippath pathbbox /top exch def pop pop pop newpath
10 top moveto
/zd {
rand 2 mod 0 eq
@skoji
skoji / .py
Created February 6, 2017 13:50
Convert all fonts opened in Glyphs to TTF
# Write this in Macro Panel and click on the Run button
for myFont in Glyphs.fonts:
for ins in myFont.instances:
print "Exporting:", ins.familyName
ins.generate(Format='TTF',AutoHint=False, RemoveOverlap=False,FontPath='path_to_the_converted_fonts/')
@skoji
skoji / pockebell.rb
Last active June 28, 2017 02:46
ポケベル入力を読む
pockebell = [%w(わ を ん ゛ °),
%w(あ い う え お),%w(か き く け こ),%w(さ し す せ そ),
%w(た ち つ て と),%w(な に ぬ ね の),%w(は ひ ふ へ ほ),
%w(ま み む め も),%w(や ( ゆ )よ),%w(ら り る れ ろ)]
s = ARGV[0].strip.scan(/.{1,2}/).map do |c|
a,b = c.split(//)
pockebell[a.to_i][b.to_i - 1]
end
puts s.join