Skip to content

Instantly share code, notes, and snippets.

@tigawa
tigawa / gist:36c3a9db698f41634560
Created August 15, 2014 04:31
WebsocketRailsのチュートリアル
# ■クライアントにブロードキャストで送る方法
# サーバ側
WebsocketRails[:message_channel].trigger "message", message
# クライアント側
var dispatcher = new WebSocketRails(location.host + '/websocket', true);
var channel = dispatcher.subscribe("message_channel");
// メッセージ受信時の処理
channel.bind("message", function(message){
@tigawa
tigawa / gist:304a55b5895c81c2a9e0
Last active February 27, 2017 09:25
rails ベストプラクティス heroku,bootstrap
# 1. rails new project
rails new test-app --database=postgresql --skip-test-unit --skip-bundle
# 2. .ignoreファイルの編集
gibo OSX Ruby Rails Sass SublimeText > .gitignore
#.gitignoreから以下のファイルを削除する。
/config/initializers/secret_token.rb
#secret_token.rbの編集 ※Herokuはアプリケーション名 application.rbにアプリケーション名が記載されている。
/config/initializers/secret_token.rb
@tigawa
tigawa / gist:a99466564f1615419119
Last active August 29, 2015 14:04
rails モデルの作成
1. スケルトンを生成
bin/rails g model Administrator #モデルはクラス名を指定する(単数形)
2. マイグレーションスクリプトファイルの編集
# カラムの追加
t.string :email, null: false
t.boolean :suspended, null: false, dafault: false
t.date :start_date, null: false
# 索引の追加
@tigawa
tigawa / gist:4cac7f3cf491d6c046ec
Created July 13, 2014 12:51
Railsでproductionモードの場合のみに、実行させたい。
if Rails.env.production?
#!/bin/bash
#git インストール
sudo apt-get install -y git gitk git-gui
#rbenv本体のインストール
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
@tigawa
tigawa / gist:c3a2b5251defc692939a
Created June 18, 2014 03:56
sublime text 3 SublimeCodeIntel の rbenvの場合の設定
{
"PHP": {
"php": "/usr/bin/php",
"phpExtraPaths": [],
"phpConfigFile": "php.ini"
},
"JavaScript": {
"javascriptExtraPaths": []
},
"Perl": {
@tigawa
tigawa / gist:9e87c52c1fe59783d1bd
Last active August 29, 2015 14:02
JQuery CDN
【jQuery 1.x 系の最新】
http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
【jQuery 1.8 系の最新】
http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js
【jQuery 2.1.1】
http://code.jquery.com/jquery-2.1.1.min.js
@tigawa
tigawa / gist:e7e62f45164db53e7d4d
Last active August 29, 2015 14:01
テストと対象のクラスの、特定のメソッドの返り値を指定する方法 mockitoというライブラリが必要です。 -> https://code.google.com/p/mockito/downloads/list
TragetTestClass tragetTestClass = spy(/*ターゲットテストクラスのオブジェクト*/);
doReturn(3L).when(tragetTestClass).getA();
@tigawa
tigawa / shimane.kml
Last active August 29, 2015 13:57
島根県のKMLファイル
<?xml version="1.0" encoding="utf-8" ?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document><Folder><name>shimane</name>
<Placemark>
<!-- ▼▼▼ ここを編集します。▼▼▼ -->
<Style>
<LineStyle>
<color>ff0000ff</color><!--透明度+カラーコード(#ff0000)の逆順(a+bgr)-->
<width>1</width><!--線の太さ-->
</LineStyle>
@tigawa
tigawa / shimane.html
Created March 16, 2014 15:07
島根県のKMLファイルを表示する
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>KML Layers</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;