Skip to content

Instantly share code, notes, and snippets.

View katoy's full-sized avatar

revers katoy

  • japan/tokyo
View GitHub Profile
@katoy
katoy / output.txt
Last active April 6, 2020 05:25
Rails の routes 情報を csv 書式で出力する。 (rake routes:csv)
$ 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
@katoy
katoy / csv-html-grid.html
Created March 10, 2012 03:18
csv, html-table, jqgrid
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Treegrid using json</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/ui-lightness/jquery-ui-1.8.17.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
@katoy
katoy / Book1.xlsx
Created October 7, 2012 04:11
prototype for xlsx -> html using apache poi
@katoy
katoy / get_opencv3.sh
Created April 21, 2018 22:20 — forked from n8henrie/get_opencv3.sh
Download, build, and install opencv on Raspberry Pi 3
#! /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
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
@katoy
katoy / pr0201.rb
Created February 15, 2015 11:16
From Mathematics to Generic Programming
# 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
@katoy
katoy / draw.swift
Last active October 28, 2016 09:48
draw line in playground (Xcode 6.1)
// See http://techlife.cookpad.com/entry/2014/11/12/170041
//
// 本来はplayground用に用意されているXCPlaygroundフレームワークのXCPShowViewを使って
// Timelineに表示することが可能ですが、現行のXcode6.1でiOS用にUIKitを使って表示した場合
// コンソールにエラーが出てしまうため使用していません。
//
import UIKit
// ビューのサイズ
@katoy
katoy / sampe_spec.rb
Last active June 15, 2016 22:51
rspec の mock の例
# See
# http://qiita.com/jnchito/items/640f17e124ab263a54dd
require 'spec_helper'
class WeatherBot
def tweet_forecast
twitter_client.update '今日は晴れです'
rescue => e
@katoy
katoy / num10.rb
Last active January 1, 2016 02:39
puzzle for 4-numbers. 4 つの数字から四則演算して 10 になるような計算式を得る。(num10.rb) 指定した個数の数字から四則演算して、指定した値になるような計算式を得る。(num10ex.rb)
# -*- 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' },
@katoy
katoy / test.rb
Created November 30, 2013 12:57
using daemons.
# -*- 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