Skip to content

Instantly share code, notes, and snippets.

View itomg's full-sized avatar

Jimmy Zhao itomg

View GitHub Profile
@itomg
itomg / datetime-format.html
Created October 14, 2014 06:35
Datetime Format in php and knockout js and angular js
## Oct 08, 2014
## php
<?=date_format(date_create($review->created_at), 'M d, Y');?>
## knockout js
?
## angular js
{{ review.created_at | date : 'MMM d, y' : 'UTC' }}
@itomg
itomg / linux-rm-files-days-ago.sh
Created September 9, 2014 06:43
Remove files days ago in linux
## -ctime / -mtime
## -print / -ls
## -delete
find ./ -iname '*.com*' -type f -mtime +30 -print
find ./ -iname '*.com*' -type f -mtime +30 -ls
find ./ -iname '*.com*' -type f -mtime +30 -delete
@itomg
itomg / export_import_pg.psql
Created September 3, 2014 03:55
PostgreSQL 导出导入表中指定查询数据
psql:
1.创建临时表
create table test_view as select * from test where date(to_timestamp(endtime))>='2012-09-02';
2.导出临时表数据为文本
copy test_view to '/home/postgres/test_view.txt' with delimiter as '|';
3.导入文件数据到数据库中指定表
delete from test;
copy test from '/home/postgres/test_view.txt' with delimiter as '|';
@itomg
itomg / ps-grep-kill.sh
Last active March 1, 2020 20:14
ps grep awk xargs kill
ps aux|grep cron-14|awk '{print $2}'|xargs echo
ps aux|grep cron-14|awk '{print $2}'|xargs kill
ps aux|grep cron-14|awk '{print $2}'|xargs kill -9
@itomg
itomg / display-certain-lines.sh
Created August 1, 2014 01:31
How to display certain lines from a huge file in Linux?
sed -n '10000000,10000020p' filename
# You might be able to speed that up a little like this:
sed -n '10000000,10000020p; 10000021q' filename
# ref http://serverfault.com/questions/133692/how-to-display-certain-lines-from-a-text-file-in-linux
@itomg
itomg / lvm2.sh
Created July 30, 2014 02:36
LVM2 PV VG LV
$ ls /dev/xv*
$ df -h
$ service solr stop
$ mv /var/solr /var/solr-bak
$ ls -l /var/solr*
$ pvcreate /dev/xvdc
$ pvdisplay
$ vgcreate vg0 /dev/xvdc
$ vgdisplay
$ man lvcreate

Plugins & Shortcuts 常用插件及快捷键

NOTICE: cmd & alt

Mac os x: cmd
Linux: alt
Winows: alt

Shortcuts

@itomg
itomg / untitled
Created June 20, 2014 06:37
How do I update npm
npm update npm -g
@itomg
itomg / checkMysqlEngineType.sql
Last active August 29, 2015 13:56
How can I check MySQL engine type for a specific database?
SELECT `ENGINE` FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA`='your_database_name' AND `TABLE_NAME`='your_table_name';
@itomg
itomg / mysqlAddSuperUser.sql
Created December 20, 2013 07:00
How to add a mysql super user
# login to mysql client as root
GRANT ALL PRIVILEGES ON *.* TO '[user name]'@'localhost' IDENTIFIED BY '[password]' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO '[user name]'@'%' IDENTIFIED BY '[password]' WITH GRANT OPTION;