Skip to content

Instantly share code, notes, and snippets.

View katoy's full-sized avatar

revers katoy

  • japan/tokyo
View GitHub Profile
@katoy
katoy / yes-no.sh
Created March 12, 2014 14:23
yes/no を聞く bash スクリプト
#!/bin/bash
# bash で yes/no を聞く。
#
# See http://yuki.silk.to/2006/04/000161.html
# http://usaturn.net/memo/shell_tech_yesorno.html
function yes_no() {
echo "-------------------------------------------"
echo "よろしいですか?(yes/no)"
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>Canvas でお絵描き</title>
<style>
#mycanvas {
border: 3px solid #999;
cursor: crosshair;
}
@katoy
katoy / client.rb
Created December 13, 2014 01:28
druby のサンプル (remote のファイル内容を得る)
# coding: utf-8
# See http://docs.ruby-lang.org/ja/2.0.0/library/drb.html
require 'pp'
require 'drb/drb'
# 接続先の URI
SERVER_URI="druby://localhost:8787"
# DRbサーバを起動する
@katoy
katoy / fukumen.rb
Created December 13, 2014 13:49
覆面算を ruby で解く。
# encoding: utf-8
# See http://web-salad.hateblo.jp/entry/2014/04/06/164312
# このコードを元に、少し変更して、全解を得るようにした。
# 文字に日本語もあつかえるようにした。
#
# 覆面算の例: http://ja.wikipedia.org/wiki/%E8%A6%86%E9%9D%A2%E7%AE%97
#
DOCUMENT = <<EOS
Find solutions to alphametic equations.
@katoy
katoy / rational.swift
Last active August 29, 2015 14:13
Swift での 分数 (Rational number)
#!/usr/bin/xcrun swift
// See https://gist.github.com/kristopherjohnson/eb7dc5b6af06eb42ef38
// http://codereview.stackexchange.com/questions/56872/fraction-rational-number-structure-with-custom-operators
import Cocoa
public struct Rational {
let numer: Int
let denom: Int
@katoy
katoy / tree.rb
Last active August 29, 2015 14:14
二分木のAA
# coding: utf-8
# See http://ja.stackoverflow.com/questions/4739
# https://gist.github.com/snipsnipsnip/0e267f6a39cc2397da3d
#
# 2 分木をコンソールにアスキーアートで出力する。
#
require 'gviz' # gem install gviz
@katoy
katoy / pi1.rb
Last active August 29, 2015 14:14
ruby で円周率
# See http://keibakuroku.jp/category/brain-teaser
def pi_1(len)
count = 0
k, a, b, a1, b1 = 2, 4, 1, 12, 4
while TRUE
# Next approximation
p, q, k = k*k, 2*k+1, k+1
a, b, a1, b1 = a1, b1, p * a + q * a1, p * b + q * b1
@katoy
katoy / kditta.rb
Created April 7, 2015 22:01
plantuml の ditaa モードの日本語対応版 (in progress ...)
# coding: utf-8
File.open(ARGV[0], "r:utf-8" ) do |f|
while line = f.gets
line2 = ''
line.chars do |c|
line2 += c
code = c.ord
line2 += ' ' unless 0 <= code && code <= 255
end
@katoy
katoy / 1.txt
Last active August 29, 2015 14:18
camunda の rest api を呼び出してみる
# ------ 実行例
$ ruby rest.rb
id:064c0150-db48-11e4-835e-12f5ba1407e2, name:"ローン申請の 審査"
id:073f66b2-db36-11e4-bc81-12f5ba1407e2, name:"Assign Approver"
id:077a4cf8-db36-11e4-bc81-12f5ba1407e2, name:"Review Invoice"
id:0bd16b17-db39-11e4-b167-12f5ba1407e2, name:"Assign Approver"
id:0bf6a67d-db39-11e4-b167-12f5ba1407e2, name:"Review Invoice"
id:247d07d5-db14-11e4-9656-12f5ba1407e2, name:"Prepare Bank Transfer"
id:304be6fb-db4e-11e4-b444-12f5ba1407e2, name:"Assign Approver"
id:3079fbeb-db4e-11e4-b444-12f5ba1407e2, name:"Approve Invoice"
@katoy
katoy / tree.json
Created February 18, 2012 00:19
jqgrid - treegrid using json
{
"total":5,
"records":5,
"page":1,
"rows":[{
"id":"1",
"cell":[
"a",
"AAA",
0,"",false,true,true