View get_opencv3.sh
#! /bin/bash | |
set -euf -o pipefail | |
function cleanup { | |
for pid in "${opencv_download_pid:-''}" "${contrib_download_pid:-''}" "${pip_install_pid:-''}"; do | |
if [ -z "${pid}" ]; then | |
kill "${pid}" | |
fi | |
done |
View change_column_to_user.rb
class ChangeColumnToUser < ActiveRecord::Migration[5.0] | |
def change | |
# 追加 | |
add_column :users, :piyo, :string | |
add_column :users, :piyo2, :string | |
# 削除 | |
remove_column :users, :piyo2, :string | |
# rename | |
rename_column :users, :name_x, :name | |
end |
View sampe_spec.rb
# See | |
# http://qiita.com/jnchito/items/640f17e124ab263a54dd | |
require 'spec_helper' | |
class WeatherBot | |
def tweet_forecast | |
twitter_client.update '今日は晴れです' | |
rescue => e |
View 1.txt
# ------ 実行例 | |
$ 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" |
View output.txt
$ rake -T routes | |
rake routes # Print out all defined routes in match order, with names | |
rake routes:csv # Print out all defined routes in CSV format | |
$ rake routes:csv | |
Prefix, Verb, URI Pattern, Controller#Action | |
data, GET, /data(.:format), data#index | |
, POST, /data(.:format), data#create | |
new_datum, GET, /data/new(.:format), data#new | |
edit_datum, GET, /data/:id/edit(.:format), data#edit |
View kditta.rb
# 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 |
View pr0201.rb
# coding: utf-8 | |
# See Book "http://ptgmedia.pearsoncmg.com/images/9780321942043/samplepages/9780321942043.pdf" | |
# "From Mathematics to Generic Programming" | |
def odd?(n) | |
(n & 1) == 1 | |
end | |
def half(n) | |
n >> 1 | |
end |
View pi1.rb
# 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 |
View tree.rb
# coding: utf-8 | |
# See http://ja.stackoverflow.com/questions/4739 | |
# https://gist.github.com/snipsnipsnip/0e267f6a39cc2397da3d | |
# | |
# 2 分木をコンソールにアスキーアートで出力する。 | |
# | |
require 'gviz' # gem install gviz |
View rational.swift
#!/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 |
NewerOlder