Skip to content

Instantly share code, notes, and snippets.

@aNd1coder
aNd1coder / mongodb_export_import_data.sh
Last active December 29, 2015 09:43
Mongodb export & import data
#export
mongoexport -d <database> -c <collection> --type=json -f <field1>,<field2> -o </path/to/collection.json>
#import
mongoimport -d <database> -c <collection> --type=json -u <username> -p <password> --headerline --file </path/to/collection.json>
@aNd1coder
aNd1coder / git_commit_sample.txt
Last active December 9, 2015 10:40
Git commit sample,don't write commit mesage in one line.
Capitalized, short (50 chars or less) summary
More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of an email and the rest of the text as the body. The blank
line separating the summary from the body is critical (unless you omit
the body entirely); tools like rebase can get confused if you run the
two together.
Write your commit message in the imperative: "Fix bug" and not "Fixed bug"
@aNd1coder
aNd1coder / ssh_key_config.sh
Created December 3, 2015 14:51
配置ssh密钥快速登录远程服务器
# 1.生成密钥
ssh-keygen -t rsa
# 2.拷贝公钥id_rsa.pub到远程服务器的用户.ssh目录下(这里远程服务器是Mac OSX)
scp ~/.ssh/id_rsa.pub {remote_username}@{remote_ip}:~/{remote_username}/.ssh/
# 3.重命名远程服务器上的id_rsa.pub为authorized_keys
mv id_rsa.pub authorized_keys
# 4.编辑本地配置文件
@aNd1coder
aNd1coder / css_expression_optimize.css
Last active December 5, 2015 05:47
css expression性能优化
/*http://www.cnblogs.com/kaiye/archive/2012/06/06/3039041.html*/
.select2{max-width:200px;*width: expression(function(el){el.style.width = el.offsetWidth > 200 ? '200px' : el.offsetWidth + 'px';counter('2');}(this));}
@aNd1coder
aNd1coder / uninstall_node_npm.sh
Last active December 28, 2017 04:05
Uninstall Node.js completely (Mac OS X)
sudo rm -rf /usr/local/bin/node
sudo rm -rf /usr/local/bin/npm
sudo rm -rf ~/.npm
sudo rm -rf ~/.node-gyp
sudo rm -rf /usr/local/share/man/man1/node.1
sudo rm -rf /usr/local/share/systemtap/tapset/node.stp
sudo rm -rf /usr/local/lib/node
@aNd1coder
aNd1coder / gist:e272a40018f934bed3c2
Created November 24, 2015 02:50 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# First:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
#go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@aNd1coder
aNd1coder / util.js
Last active August 29, 2015 14:04
javascript utility function
// Add commas to numbers
function addCommas(n) {
return String(n).replace(/(\d)(?=(\d{3})+$)/g, '$1,')
}
//check the browser environment
function isWeiXinEnv(){
var ua = window.navigator.userAgent.toLowerCase();
return ua.match(/MicroMessenger/i) == 'micromessenger';
}
@aNd1coder
aNd1coder / _mixins.scss
Last active December 31, 2015 11:59
common sass mixins
@mixin clear {
*zoom: 1;
&:after {
content: '\20';
display: block;
clear: both;
height: 0;
}
}
@aNd1coder
aNd1coder / radio.scss
Created December 2, 2013 11:07
radio custom style for webkit
input[type='radio'] {
-webkit-appearance: none;
-webkit-user-select: none;
border-radius: 100%;
border: 1px solid #BABABA;
display: inline-block;
height: 16px;
position: relative;
top: 3px;
width: 16px;
@aNd1coder
aNd1coder / _font.scss
Last active December 27, 2015 17:59
@font-face for iconfont
@charset "UTF-8";
$font_name:'iconfont';
$font_url: 'http://path/to/font/#{$font_name}';
@font-face {
font-family: $font_name;
src: url('#{$font_url}.eot');
src: url('#{$font_url}.eot?#iefix') format('embedded-opentype'),
url('#{$font_url}.svg##{$font_name}regular') format('svg'),