Skip to content

Instantly share code, notes, and snippets.

View willnet's full-sized avatar
👶
parenting

Shinichi Maeshima willnet

👶
parenting
View GitHub Profile
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# ログローテーションでできた古いログファイルを整理するためのスクリプト
# script/runner で実行する
Dir.chdir(RAILS_ROOT + "/log")
today = DateTime.now.strftime("%Y%m%d")
thismonth = DateTime.now.strftime("%Y%m")
Dir.glob("*").each do |filename|
#
# log rotatation
#
# script/runner & cron で実行する
SERVER_PID = configatron.server.pid
ACCESS_LOG = configatron.server.access_log
ACCESS_LOG_STRFTIME = configatron.server.access_log_strftime
RAILS_LOG = configatron.server.rails_log
RAILS_LOG_STRFTIME = configatron.server.rails_log_strftime
#!/usr/bin/env ruby
# ActiveRecordで管理している古いsessionを削除するスクリプト
# デフォルトで14日以上前のレコードを削除
ENV["RAILS_ENV"] ||= "production"
require File.dirname(__FILE__) + '/../config/boot'
require File.dirname(__FILE__) + '/../config/environment'
num = ARGV.shift || 14
num = num.to_i
# puts RAILS_ENV
@willnet
willnet / rails_template_for_3.1.rb
Created August 29, 2011 11:49
rails template for 3.1
# -*- coding: utf-8 -*-
#
# Usage
#
# rails new yourapp -m https://raw.github.com/gist/1178242/3c77cfffeb99f32d19333de986ff41283aa9eb26/rails_template_for_3.1.rb -T --skip-bundle
#
git :init
append_file '.gitignore', <<-END
@willnet
willnet / ext_array.rb
Created September 12, 2011 04:10
devquiz2011スライドパズル用コード
# -*- coding: utf-8 -*-
class Array
def point(x, y)
self[y][x]
end
def set_point(x, y, char)
self[y][x] = char
self
@willnet
willnet / webgame.coffee
Created September 12, 2011 04:45
devquiz2011webgame用コード
click = (id) ->
element = document.getElementById('card' + id)
myevent = document.createEvent('MouseEvents')
myevent.initEvent('click', false, true)
element.dispatchEvent(myevent)
element
size = $('.card').size() - 1
ary = new Array(size)
@willnet
willnet / hitorigame.rb
Created September 12, 2011 04:48
devquiz2011一人ゲーム用コード
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
input =<<EOS
100
2
10 11
3
0 9 9
4
@willnet
willnet / gist:1232034
Created September 21, 2011 13:31
qt install error log
==> Downloading http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4
File already downloaded and cached to /Users/maeshima/Library/Caches/Homebrew
==> ./configure -prefix /usr/local/Cellar/qt/4.7.3 -system-libpng -system-zlib -
==> make
cd src/tools/bootstrap/ && make -f Makefile
/usr/bin/c++ -c -O3 -w -pipe -fvisibility=hidden -I/usr/X11/include -Xarch_x86_64 -mmacosx-version-min=10.5 -O2 -fPIC -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_BOOTSTRAPPED -DQT_LITE_UNICODE -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_CODECS -DQT_NO_DATASTREAM -DQT_NO_GEOM_VARIANT -DQT_NO_LIBRARY -DQT_NO_QOBJECT -DQT_NO_STL -DQT_NO_SYSTEMLOCALE -DQT_NO_TEXTSTREAM -DQT_NO_THREAD -DQT_NO_UNICODETABLES -DQT_NO_USING_NAMESPACE -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I../../../mkspecs/macx-g++ -I. -I../../../include -I../../../include/QtCore -I../../../include/QtXml -o .obj/release-static/qisciicodec.o ../../corelib/codecs/qisciicodec.cpp
/usr/bin/c++ -c -O3 -w -pipe -fvisibility=hidden -
@willnet
willnet / setup_chef.sh
Created January 24, 2012 04:48
ec2 amazon instance に chef を導入するまでの手順
sudo yum install emacs git zsh gcc make readline readline-devel libyaml libyaml-devel zlib zlib-devel openssl openssl-devel
mkdir src
cd src
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz
tar zxvf ruby-1.9.3-p0.tar.gz
cd ruby-1.9.3-p0
./configure
make
sudo make install
cd /home/ec2-user/src/ruby-1.9.3-p0/ext/openssl
@willnet
willnet / gist:1698698
Created January 29, 2012 12:54
install and setting manual for mysql on ec2-micro
sudo yum install mysql mysql-server mysql-devel
sudo cp /etc/my.cnf /etc/my.cnf.orig
wget https://raw.github.com/willnet/config/master/my.cnf.ec2-micro
sudo mv my.cnf.ec2-micro /etc/my.cnf
sudo mysql_install_db
sudo mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &
mysql -u root
TRUNCATE TABLE mysql.user;
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'xxxxxxxx' WITH GRANT OPTION;