Skip to content

Instantly share code, notes, and snippets.

@hyuki0000
hyuki0000 / gengo.rb
Created January 10, 2017 03:43
gengo.rb - 元号ジェネレータ。これまでに元号で使われた漢字からなるすべての二文字列を生成する(4900個)
a = '万中久乾亀亨享仁保元勝化吉同和喜嘉国大天字安宝寛寿平康延建弘徳応感慶成承授政文斉昌明昭景暦正武永治泰白祚神祥禄禎福老至興衡観護貞銅長雉雲霊養'
a.split(//).each do |x|
a.split(//).each do |y|
print "#{x}#{y},"
end
end
@hyuki0000
hyuki0000 / hyper.tex
Created November 26, 2016 11:09
y = 90/x (1 <= x <= 90) のグラフで格子点をプロットする
\documentclass[dvipdfmx,a4paper,10pt]{jsbook}
\usepackage{tikz}
\usepackage{ifthen}
\usepackage{calc}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[line join=round,line cap=round,>=latex,x=1mm,y=1mm]
\tikzset{AXIS/.style={color=black,thin,->}}
\tikzset{GRID/.style={color=gray!50!white,very thin}}
@hyuki0000
hyuki0000 / face.rb
Last active October 17, 2016 22:34
EYE = %w( შ ๑ ะ ๏ ཅ ⌑ ◌ მ פ இ ௫ ° •)
MOUTH = %w( _ ⌓ ﹏ ⌄)
EYE.each do |e|
MOUTH.each do |m|
print "(#{e}#{m}#{e}) "
end
puts
end
@hyuki0000
hyuki0000 / check.rb
Last active February 28, 2017 07:41
何か行動するときのチェックリストをチェックする簡単なRubyスクリプト
#!/usr/bin/env ruby
DIRECTORY = '/Users/USERNAME/.check'
def check(file)
File::open(file) do |f|
f.each_line do |line|
puts line
STDIN.gets.chomp
end
@hyuki0000
hyuki0000 / pi.rb
Created July 22, 2016 00:47
一年で、月と日の比が円周率に近いのはいつか?
#!/usr/bin/ruby
(1..12).each do |month|
(1..31).each do |day|
r = (month.to_f / day).to_s
s = (day.to_f / month).to_s
puts "#{month}月#{day}日 #{month}/#{day} = #{r}" if r.match(/^3\.1/)
puts "#{month}月#{day}日 #{day}/#{month} = #{s}" if s.match(/^3\.1/)
end
end
@hyuki0000
hyuki0000 / index.html
Created July 19, 2016 06:14
an html file.
<ol>
<li>ex ea commodo consequat
<ol>
<li>Lorem ipsum dolor sit amet</li>
<li>consectetur adipiscing elit</li>
<li>sed do eiusmod tempor</li>
</ol>
</li>
<li>Duis aute irure dolor in
<ol start="4">
@hyuki0000
hyuki0000 / .vimrc
Last active July 7, 2016 00:49
一行目に書いた文字列を利用して、指定した範囲の先頭にそれを書き込むVim のformatprg
set formatexpr=""
set formatprg=/YOUR/BIN/DIR/formatprg.rb
@hyuki0000
hyuki0000 / book.rb
Last active February 12, 2017 06:17
Mac用簡易PDF表示スクリプト。ファイル名の一部を入力すると一覧を番号付きで表示する。番号も付けて入力するとそのファイルを表示する。
#!/usr/bin/env ruby
DIRECTORY = '/YOUR/PDF/DIR'
keyword = nil
number = nil
if ARGV.length != 1 and ARGV.length != 2
puts "Usage (1): book keyword"
puts "Example (1): book Galois"
puts "Usage (2): book keyword number"
N = 2016_06_01
(1..N).each do |n|
if (N / n) * n == N
puts "#{N} can be divided by #{n}."
end
end
__END__
20160601 can be divided by 1.
20160601 can be divided by 20160601.
@hyuki0000
hyuki0000 / ni.rb
Created April 8, 2016 14:31
von Neumann Integer.
class Fixnum
def to_ss
if self == 0
""
elsif self == 1
"{}"
else
(self - 1).to_ss + ',' + (self - 1).to_s
end
end