Skip to content

Instantly share code, notes, and snippets.

View tsmsogn's full-sized avatar
:octocat:
Set your status

tsmsogn tsmsogn

:octocat:
Set your status
View GitHub Profile
@tsmsogn
tsmsogn / maintenance.txt
Last active December 14, 2015 15:18
[.htaccess]Snippets
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^foo.bar.baz$
RewriteRule ^(.*)$ http://foo.bar/$1 [L,R=301]
</IfModule>
@tsmsogn
tsmsogn / _error_messages.html.erb
Last active December 14, 2015 21:28
[rails]Snippets
<% if object.errors.any? %>
<div id="error_explanation">
<div class="alert alert-error">
The form contains <%= pluralize(object.errors.count, "error") %>.
</div>
<ul>
<% object.errors.full_messages.each do |msg| %>
<li>* <%= msg %></li>
<% end %>
</ul>
@tsmsogn
tsmsogn / gist:5167806
Last active December 14, 2015 23:48
[rails]Command snippets
rails new app --skip-test-unit
cd app
bundle update
bundle install --without production
rails generate rspec:install
rails generate model User name:string
rails generate controller Users new --no-test-framework
rails generate integration_test user_pages
require 'spec_helper'
describe User do
before { @user = User.new(name: "Example User", email: "user@example.com", password: "foobar", password_confirmation: "foobar") }
subject { @user }
it { should respond_to(:name) }
it { should respond_to(:email) }
@tsmsogn
tsmsogn / class.php
Last active December 15, 2015 06:49
[php]Snippets
<?php
class Foo {
var $bar;
var $baz;
function Foo($options = array()) {
if (!empty($options)) {
$this->setOptions($options);
}
}
@tsmsogn
tsmsogn / gist:5250502
Last active December 15, 2015 11:09
[rails]How to implement with nested resources.

Models

app/models/group.rb

class Group < ActiveRecord::Base
  attr_accessible :name
  has_many :users, dependent: :destroy
end
@tsmsogn
tsmsogn / branch_comment.html
Last active December 16, 2015 02:09
[html]Snippets
<!--[if lt IE 7]>
<p>IE 7 未満</p>
<![endif]-->
<![if gte IE 7 ]>
<p>IE 7 以上 && IE 以外</p>
<![endif]>
@tsmsogn
tsmsogn / gist:5418468
Created April 19, 2013 06:16
Vim: Snippets
置換
controll + V の ^M
export SVN_EDITOR=vim
export PATH=$HOME/bin:$HOME/.phpenv/bin:$HOME/.rbenv/shims:/usr/local/bin:/usr/local/mysql/bin/:/Users/Shared/android-sdk-macosx/platform-tools:/Users/Shared/android-ndk-r8:$PATH
. ~/nvm/nvm.sh
### Titanium Mobile
#alias androidbuilder='$HOME/Library/Application\ Support/Titanium/mobilesdk/osx/2.1.2.GA/android/builder.py'
#alias iosbuilder='$HOME/Library/Application\ Support/Titanium/mobilesdk/osx/2.1.2.GA/iphone/builder.py'
##phpfarm
#export PHP_HOME=$HOME/local/php/versions
@tsmsogn
tsmsogn / gist:5530301
Last active December 17, 2015 01:39
PHP: Snippets: Hiraga table
<?php
$hiraganaTable = array(
'a' => array('a' => 'あ', 'ka' => 'か', 'sa' => 'さ', 'ta' => 'た', 'na' => 'な', 'ha' => 'は', 'ma' => 'ま', 'ya' => 'や', 'ra' => 'ら', 'wa' => 'わ'),
'i' => array('i' => 'い', 'ki' => 'き', 'shi' => 'し', 'chi' => 'ち', 'ni' => 'に', 'hi' => 'ひ', 'mi' => 'み', 'yi' => '', 'ri' => 'り', 'wi' => ''),
'u' => array('u' => 'う', 'ku' => 'く', 'su' => 'す', 'tsu' => 'つ', 'nu' => 'ぬ', 'hu' => 'ふ', 'mu' => 'む', 'yu' => 'ゆ', 'ru' => 'る', 'wu' => ''),
'e' => array('e' => 'え', 'ke' => 'け', 'se' => 'せ', 'te' => 'て', 'ne' => 'ね', 'he' => 'へ', 'me' => 'め', 'ye' => '', 're' => 'れ', 'we' => ''),
'o' => array('o' => 'お', 'ko' => 'こ', 'so' => 'そ', 'to' => 'と', 'no' => 'の', 'ho' => 'ほ', 'mo' => 'も', 'yo' => 'よ', 'ro' => 'ろ', 'wo' => ''),
);