Skip to content

Instantly share code, notes, and snippets.

View reyesyang's full-sized avatar

Yang Hailong reyesyang

View GitHub Profile
@reyesyang
reyesyang / mysql_outfile.sql
Created February 25, 2014 09:00
Export MySQL query result to CSV file
SELECT id, username, (total_point - spent_point) AS point
FROM users
ORDER BY point DESC
LIMIT 50
INTO OUTFILE '/tmp/bbs_points_top50.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
;
@reyesyang
reyesyang / mysql_outfile.sh
Created February 27, 2014 08:43
Save Mysql query result to csv file, When you have no write permission on mysql server.
mysql -N -hhostname -uusername -ppassword database_name -e "select id, DATE(updated_at) from topics where status < 10 limit 10" | sed 's/\t/,/g'
@reyesyang
reyesyang / kill_all_process_by_name.sh
Last active August 29, 2015 13:57
Kill all process by name
# Way 1
killall ${process_name}
# Way 2
for pid in $(ps aux | grep ${process_name} | awk '{print $2}')
do
kill ${pid}
done
su -
#dependcies
#centos 6.2 | http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-7.noarch.rpm
rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/5/x86_64/epel-release-5-4.noarch.rpm
yum -y groupinstall 'Development Tools' 'Additional Development'
yum -y install readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc sqlite-devel gcc-c++ libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui python-devel redis
@reyesyang
reyesyang / 69-language-selector-zh-cn.conf
Created January 11, 2015 05:07
Chinese fonts configuration file for Ubuntu
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="pattern">
<test qual="any" name="family">
<string>serif</string>
</test>
<edit name="family" mode="prepend" binding="strong">
<string>DejaVu Serif</string>
@reyesyang
reyesyang / gem_path.rb
Created June 27, 2015 04:08
Get installed gem path from Gem
Gem.loaded_specs['gem_name'].full_gem_path
@reyesyang
reyesyang / rails_template.rb
Last active August 29, 2015 14:24
Rails project template
# rails new . -d mysql --skip-test-unit
# rails new . --skip-active-record --skip-test-unit
# Edit Gemfile
if yes?('Replace gem source "https://rubygems.org/" with Taobao mirror "https://ruby.taobao.org/"?(y/n)')
gsub_file 'Gemfile', 'rubygems.org', 'ruby.taobao.org'
end
use_mongodb = yes?('Use MongoDB?(y/n)')
gem 'jquery-turbolinks'
@reyesyang
reyesyang / grape-i18n-zh-CN.yml
Last active March 7, 2024 14:52
Grape I18n translation in zh-CN language
# Usage:
# 1. Put this file in config/locales/grape/zh-CN.yml
# 2. Set load_path in config/application.rb as below:
# config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
zh-CN:
grape:
errors:
format: ! '%{attributes} %{message}'
messages:
@reyesyang
reyesyang / genrsa.sh
Created July 16, 2015 11:12
Generate SSL Key, CSR and Self Signed Certificate
# Generate Private Key:
openssl genrsa -out server.key 1024
# Generate a Certificate Signing Request (CSR)
openssl req -new -key server.key -out server.csr
# Generate a Self-Signed SSL Certificate
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
@reyesyang
reyesyang / kaminari-i18n-zh-CN.yml
Last active August 29, 2015 14:25
Kaminari I18n translation in zh-CN language
# Usage:
# 1. Put this file in config/locales/kaminari/zh-CN.yml
# 2. Set load_path in config/application.rb as below:
# config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
zh-CN:
views:
pagination:
first: "&laquo; 首页"
last: "末页 &raquo;"