Skip to content

Instantly share code, notes, and snippets.

View hyuki's full-sized avatar

Hiroshi Yuki / 結城浩 hyuki

View GitHub Profile
@hyuki
hyuki / README.md
Last active March 5, 2019 12:39
compare_escape.rb - Compare CGI.escapeHTML, CGI.escape, and URI.encode.
CGI.escapeHTML('< > &') #=> &lt; &gt; &amp;
CGI.escape('< > &')     #=> %3C+%3E+%26
URI.encode('< > &')     #=> %3C%20%3E%20&

CGI.escapeHTML('https://example.com/')  #=> https://example.com/
CGI.escape('https://example.com/')      #=> https%3A%2F%2Fexample.com%2F
URI.encode('https://example.com/')      #=> https://example.com/

CGI.escapeHTML('結') #=&gt; 結

見出し

  • 一つ
  • 二つ
  • 三つ
@hyuki
hyuki / stairs.rb
Created May 31, 2019 01:01
stairs.rb - 階段昇降
# 毎日『m段上ってn段下がる』を繰り返したら、
# x日目にd段目に初めて着いた。
# xをd,m,nで表せ。文字はすべて正の整数で、m>nとする。#数学の問題
# https://twitter.com/hyuki/status/1134018952416321536
# current段目から「m段上ってn段下がる」ときに通過する
# 「段目」を引数にブロックをyieldして
# 最終的な段目を戻り値に
def daily(current,m,n)
m.times do
@hyuki
hyuki / stairs.rb
Last active May 31, 2019 01:04
stairs.rb - 階段昇降
# 毎日『m段上ってn段下がる』を繰り返したら、
# x日目にd段目に初めて着いた。
# xをd,m,nで表せ。文字はすべて正の整数で、m>nとする。#数学の問題
# https://twitter.com/hyuki/status/1134018952416321536
# current段目から「m段上ってn段下がる」ときに通過する
# 「段目」を引数にブロックをyieldして
# 最終的な段目を戻り値に
def daily(current,m,n)
m.times do
# For setting color for my prompt.
# https://qiita.com/PruneMazui/items/8a023347772620025ad6
# https://gist.github.com/hyuki/3eef0b67e30f2839c1dd556e9f10c9c1
# https://snap.textfile.org/20190706230113/
PROMPT = %Q(export COLOR='%d';) + %q(PS1="[\[\e[38;5;${COLOR}m\]\u@HOSTNAME\[\e[0m\] \w] \\$ ")
256.times do |n|
s = sprintf(PROMPT, n)
printf("\e[38;5;%dm%s\e[m\n", n, s)
end
@hyuki
hyuki / index.html
Created July 25, 2019 20:24
oneline-memo - Store any input text to your browser.
<!DOCTYPE html>
<html lang="ja">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>一行メモ</title>
<style>
input {
width: 50%;
height: 2em;
@hyuki
hyuki / kuku.rb
Created July 26, 2019 11:45
kuku.rb - 九九表の中にユニークな数は何個あるか?
h = Hash.new(0)
9.times do |y|
9.times do |x|
n = (x + 1) * (y + 1)
h[n] += 1
printf("%3d", n)
end
puts
end
@hyuki
hyuki / circle.java
Last active August 16, 2019 11:19
draw a circle (processing)
float th = 0.0;
float R = 100;
float r = 10;
void setup(){
size(300, 300);
background(0);
noStroke();
}
@hyuki
hyuki / a.java
Created August 15, 2019 14:15
for processing
float theta = 0.0;
void setup(){
size(600, 600);
background(0);
noStroke();
}
void draw() {
clear();
@hyuki
hyuki / processing.java
Created August 17, 2019 08:57
processing.java
int N = 1;
void setup(){
size(600, 600);
background(0);
noStroke();
}
void draw() {
clear();