Skip to content

Instantly share code, notes, and snippets.

View simonqian's full-sized avatar

simonqian simonqian

View GitHub Profile
1. 备份数据库并压缩
mysqldump -h -u -p database | gzip > backupfile.sql.gz
2. 解压并还原数据库
gunzip < backupfile.sql.gz | mysql -uroot -ppassw database
真实例子(带参数)
mysqldump --complete-insert --no-create-info --skip-triggers --ignore-table=cellar.schema_migrations --ignore-table=cellar.regions -uroot -p cellar | gzip > backupfile.sql.gz
gunzip < backupfile.sql.gz | mysql -ucellar -p cellar
$('#content').select()
document.execCommand('copy')
# payment_orders join orders
PaymentOrder.joins(:orders)
# payment_orders join orders, payment_orders join gift_packs
PaymentOrder.joins(:orders).joins(:gift_pack)
# payment_orders join orders, orders join products
PaymentOrder.joins(orders: :products)
# payment_orders join orders, orders join products, products join product_items
1. create config
vi ~/.ssh/config
2. add content
Host dpy
User dpy
HostName xxx.xxx.xx.xxx
3. install ssh-copy-id(in mac ox)
brew install ssh-copy-id
4. add id to remote server
ssh-copy-id -i ~/.ssh/id_rsa.pub dpy
/**
* 对Date的扩展,将 Date 转化为指定格式的String
* 月(M)、日(d)、12小时(h)、24小时(H)、分(m)、秒(s)、周(E)、季度(q) 可以用 1-2 个占位符
* 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
* eg:
* (new Date()).pattern("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
* (new Date()).pattern("yyyy-MM-dd E HH:mm:ss") ==> 2009-03-10 二 20:09:04
* (new Date()).pattern("yyyy-MM-dd EE hh:mm:ss") ==> 2009-03-10 周二 08:09:04
* (new Date()).pattern("yyyy-MM-dd EEE hh:mm:ss") ==> 2009-03-10 星期二 08:09:04
* (new Date()).pattern("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
# Add the remote, call it "upstream":
git remote add upstream https://github.com/whoever/whatever.git
# Fetch all the branches of that remote into remote-tracking branches,
# such as upstream/master:
git fetch upstream
# Make sure that you're on your master branch:
enable (git) plugin.
g git
gst git status
gl git pull
gup git fetch && git rebase
gp git push
gc git commit -v
gca git commit -v -a
gco git checkout
# 1. value-is-date
update ad_bids set bid_end_time = to_date('2016/10/31 16:00:00', 'yyyy/mm/dd hh24:mi:ss') where id = 10200;
# 2. string-include-&
# update url = http://a.10086.cn/pams2/linkUrl.jsp?j=d&p=72&c=9536&r=28785646&src=5210297653
update default_ad_cate set url='http://a.10086.cn/pams2/linkUrl.jsp?j=d&'||'p=72&'||'c=9536&'||'r=28785646&'||'src=5210297653' where ad_schedule_id=10482;
# reference: https://www.digitalocean.com/community/tutorials/how-to-install-hadoop-on-ubuntu-13-10
wget https://mirrors.tuna.tsinghua.edu.cn/apache/hadoop/common/hadoop-2.7.3/hadoop-2.7.3.tar.gz
tar xfz hadoop-2.7.3.tar.gz
mv hadoop-2.7.3 /usr/local/hadoop
# Editing ~/.bashrc
使用git add添加要提交的文件的时候,如果文件名是中文,会显示形如274\232\350\256\256\346\200\273\347\273\223.png的乱码。
解决方案:
在bash提示符下输入:
git config –global core.quotepath false
core.quotepath设为false的话,就不会对0×80以上的字符进行quote。中文显示正常。