Skip to content

Instantly share code, notes, and snippets.

View katsuyoshi's full-sized avatar

Katsuyoshi Ito katsuyoshi

  • ITO SOFT DESIGN Inc.
  • Akita, Japan
View GitHub Profile
@katsuyoshi
katsuyoshi / find debug p
Last active December 12, 2015 09:28
rubyでデバックプリントとしていれた p の行を検索する正規表現
^\s*p\s+[^=(?+\-\*\/{]
@katsuyoshi
katsuyoshi / http_req
Last active December 14, 2015 18:59
http request にjsonデータを渡すスクリプト
#!/usr/bin/env ruby
# @see: http://stackoverflow.com/questions/5658510/curl-json-post-request-via-terminal-to-a-rails-app
unless ARGV.size == 3
puts <<EOB
Usage: http_req url method data
ex) http_req http://localhost:3000/movies/new.json post "{ movie:{ title:'Star Wars IV'} }"
EOB
exit
<!DOCTYPE html>
<html>
<head>
<title>ITO SOFT DESIGN.</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>
<% info = @personal_info %>
<% english = info["company"]["name"] == 'ITO SOFT DESIGN Inc.' %>
<dl>
@katsuyoshi
katsuyoshi / gist:5831514
Last active December 18, 2015 19:18
10.8.4へRubyのインストール
参照
http://blog.lampetty.net/blog_ja/index.php/archives/475
http://mxcl.github.io/homebrew/
http://qiita.com/marutanm/items/3da5d8895d0059df24d2
$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
$ brew doctor
$ brew install ruby
$vi ~/.bash_profile
require 'open-uri'
url = URI.escape('http://marking.herokuapp.com/reports.json?category=コイン精米所&place=39.49591064453125,140.5938110351562&r=20')
open(url).read
@katsuyoshi
katsuyoshi / gist:6018022
Created July 17, 2013 06:06
connect to sqlserver by rails
# 参照:
# http://ameblo.jp/murajun1/entry-11266484358.html
$ brew install freetds
$ gem install tiny_tds
$ gem install activerecord-sqlserver-adapter
$ rails new sqlserver-test
$ cd sqlserver-test
# Windows設定
@katsuyoshi
katsuyoshi / Issue of KVC
Last active December 20, 2015 06:59
KVCで値をセットする時にRubyのsetterを使ってるとRubyのsetterの方が呼び出されない問題
# -*- coding: utf-8 -*-
#
# KVCの問題:
# Rubyのsetterを定義した場合にKVCでRubyのsetterが呼び出されない。
#
# 結果:
# WARN: bazはnilにしないでください。
#
# 問題:
# WARN: quuzはnilにしないでください。
# -*- coding: utf-8 -*-
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
controller = MainViewController.alloc.init
@window.rootViewController = UINavigationController.alloc.initWithRootViewController(controller)
@window.makeKeyAndVisible
true
end
end
@katsuyoshi
katsuyoshi / 三菱電機サンプル.csv
Created April 13, 2014 03:45
irBoardの三菱電機サンプルプロジェトをCSVファイルとして書き出したファイル
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 4 in line 1.
project
name,launch_page_no,style,transition
三菱電機サンプル,0,irPanel,push
page
page_no,class,title,background_color_name,locked,right_page_no
0,Page,,,0,1
page::items
class,x,y,width,height,style,title,alternate_title,line_width,corner_radius,padding,shape,lamp_negative,interlock_negative,switch_device_name,switch_mode,switch_negative,title_for_button,device_name,alternate_text_color_name,lamp_color_name,page_no
@katsuyoshi
katsuyoshi / output_of_gen_page.rb.csv
Created April 13, 2014 04:19
gen_page.rbの出力結果
We can make this file beautiful and searchable if this error is corrected: It looks like row 5 should actually have 1 column, instead of 8 in line 4.
page
page_no
3
page::items
class,x,y,width,height,style,device_name,title
Button,0,0,256,153,Square,M0,ランプ1
Button,0,153,256,153,Square,M1,ランプ2
Button,0,306,256,153,Square,M2,ランプ3
Button,0,459,256,153,Square,M3,ランプ4