This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See http://techlife.cookpad.com/entry/2014/11/12/170041 | |
// | |
// 本来はplayground用に用意されているXCPlaygroundフレームワークのXCPShowViewを使って | |
// Timelineに表示することが可能ですが、現行のXcode6.1でiOS用にUIKitを使って表示した場合 | |
// コンソールにエラーが出てしまうため使用していません。 | |
// | |
import UIKit | |
// ビューのサイズ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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サーバを起動する |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Canvas でお絵描き</title> | |
<style> | |
#mycanvas { | |
border: 3px solid #999; | |
cursor: crosshair; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# 演算子の優先度を返す | |
OP_INFO = { | |
# 演算子 => [優先度、演算] | |
'+' => { priority: 1, func: 'func_add' }, | |
'-' => { priority: 1, func: 'func_sub' }, | |
'*' => { priority: 2, func: 'func_mul' }, | |
'/' => { priority: 2, func: 'func_div' }, | |
# '**' => { priority: 3, func: 'func_exp' }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
require 'logger' | |
STDOUT.sync = true | |
STDERR.sync = true | |
def get_logger | |
ret = Logger.new(File.join(File.dirname(File.expand_path(__FILE__)), 'test.log')) | |
ret.level = Logger::INFO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See http://refm.rubicle.net/sp/1.9.3/class/Open3 | |
require 'open3' | |
puts "====== system ======" | |
ret = system('ps > /tmp/1') | |
puts ret | |
puts File.read('/tmp/1') | |
puts "====== Open3.capture3 ======" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
require 'erb' | |
require 'time' | |
def make_body(template, name, time, params) | |
erb = ERB.new(template) | |
result = erb.result(binding) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'net/scp' | |
host = "xxxxxxx.ne.jp" | |
user = "youichikato" | |
src_path = "/tmp/1" | |
dest_path = "/tmp/2" | |
opts = {:password => "xxxxxxxx"} | |
Net::SCP.start(host, user, opts){|scp| |