Skip to content

Instantly share code, notes, and snippets.

View yoshitsugu's full-sized avatar
🐐
bleat

Kota Yoshitsugu yoshitsugu

🐐
bleat
View GitHub Profile
@yoshitsugu
yoshitsugu / thunderbird.md
Last active December 30, 2015 05:49
ThunderBirdが重いのでglobal検索のインデックスを消す
@yoshitsugu
yoshitsugu / to_ruby_hash.php
Created November 6, 2013 08:40
PHPのArrayをRubyのHashに変換。 PHP Array to Ruby Hash
function to_ruby_hash($array){
$result = "{";
foreach($array as $key => $value){
$result .= "\"".$key."\" => ";
if(is_array($value)){
$result .= to_ruby_hash($value).",\n";
}else{
$result .= "\"".$value."\",";
}
}
@yoshitsugu
yoshitsugu / init.el
Created August 9, 2013 09:55
emacsで選択範囲をFireFoxでgoogle検索 ref: http://qiita.com/yoshitsugu@github/items/9d78915b24bcbff7222f
(defun search-region-by-google ()
"search by google"
(interactive)
(shell-command-on-region (region-beginning) (region-end) "read WORD ; firefox \"http://www.google.com/search?q=$WORD\""))
; C-c sに割り当て
(global-set-key "\C-cs" 'search-region-by-google)
@yoshitsugu
yoshitsugu / proxy.rb
Created August 7, 2013 09:16
proxy with webrick
#!/usr/bin/env ruby
require 'webrick'
require 'webrick/httpproxy'
require 'uri'
# プロキシサーバオブジェクトを作る
s = WEBrick::HTTPProxyServer.new(
# バインドアドレス(デフォルト:nil)
@yoshitsugu
yoshitsugu / dice_ewsn.rb
Last active December 20, 2015 11:09
dice
class Dice
attr_accessor :coords
def initialize
@coords = [[0,0,1],[1,0,0],[0,-1,0],[0,1,0],[-1,0,0],[0,0,-1]]
end
def top
@coords.each_with_index{|coord,i|
if coord == [0,0,1]
return i+1
@yoshitsugu
yoshitsugu / zshrc
Created July 30, 2013 06:34
tramp+zshでうまく動かないときのzshrcの設定
# tramp+zshではうまく動かないときの設定
case "$TERM" in
dumb | emacs)
PROMPT="%m:%~> "
unsetopt zle
;;
esac
@yoshitsugu
yoshitsugu / reset_root_password.sql
Created July 29, 2013 06:23
reset root password on MySQL5.6
-- safeモードでmysql起動してから /usr/bin/mysqld_safe --user=root --skip-grant-tables
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;
@yoshitsugu
yoshitsugu / application_controller.rb
Last active December 20, 2015 06:39
rails application_controller set_locale
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_locale
protected
def set_locale
logger.debug "* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}"
I18n.locale = params[:locale] ||
extract_locale_from_accept_language_header ||
@yoshitsugu
yoshitsugu / gist:6068754
Created July 24, 2013 07:52
install後に編集された/etc以下のファイル一覧を表示
find /etc -type f -newer /root/install.log | xargs ls -alrt
Spork.prefork do
...
RSpec.configure do |config|
....
# for database_clener
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation,{:except => %w{except_tables}})
DatabaseCleaner.strategy = :transaction
end