This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# 実行例1:sssh を実行すると ~/bin/server_list の一覧からserver選択して自動ssh接続 | |
# 実行例2:sssh $server を実行すると ssh $ssh_user@$server を実行する | |
ssh_user="ssh user" | |
ssh_pass="ssh password" | |
ssh_login(){ | |
if [ $# -ne 1 ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git config --global color.diff auto | |
git config --global color.status auto | |
git config --global color.branch auto | |
git config --global color.interactive auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreatePdmRevisions < ActiveRecord::Migration | |
def self.up | |
create_table :pdm_revisions do |t| | |
t.column :commit_message, :string | |
t.column :attachment, :string | |
t.column :created_by, :string | |
t.column :created_date, :datetime | |
t.column :document_type, :string | |
t.column :pdm_document_id, :int | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat known_ssh_hosts.sh | |
#!/bin/sh | |
# see : http://d.hatena.ne.jp/youhey/20110112/1294830362 | |
SSH_CONFIG=$HOME/.ssh/config | |
echo "known hosts:" | |
if test -f $SSH_CONFIG; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# nginx – this script starts and stops the nginx daemon | |
# | |
# chkconfig: - 85 15 | |
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \ | |
# proxy and IMAP/POP3 proxy server | |
# processname: nginx | |
# config: /opt/nginx/conf/nginx.conf | |
# pidfile: /opt/nginx/logs/nginx.pid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# credit cart number | |
def normalize_credit_card_number | |
self.cc_number.gsub!(/[-\s]/, '') | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
s = "こんにちは" | |
puts s.tr("あ-ん", "ア-ン") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Encrypter | |
# We're passed a list of attributes that should # be stored encrypted in the database | |
def initialize(attrs_to_manage) | |
@attrs_to_manage = attrs_to_manage | |
end | |
# Before saving or updating, encrypt the fields using the NSA and # DHS approved Shift Cipher | |
def before_save(model) | |
@attrs_to_manage.each do |field| model[field].tr!("a-z", "b-za") | |
end end | |
# After saving, decrypt them back |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#railsでsaveをするときにerrorをcountingしてredirectする。 | |
def save | |
order = Order.new(params[:order]) if order.save | |
redirect_to action: "display" else | |
session[:error_count] ||= 0 session[:error_count] += 1 if session[:error_count] < 4 | |
self.notice = "Please try again" else | |
# Give up -- user is clearly struggling | |
redirect_to("/help/order_entry.html") end | |
end end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tableless < ActiveRecord::Base | |
def self.column(name, sql_type = nil, default = nil, null = true) | |
columns << ActiveRecord::ConnectionAdapters::Column.new( name.to_s, default, sql_type.to_s, null ) | |
end | |
def self.columns() | |
@columns ||= []; | |
end |
OlderNewer