Skip to content

Instantly share code, notes, and snippets.

@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 / 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>
// http://taobaofed.org/blog/2015/10/28/jstracker-how-to-collect-data/
var is360 = function(){
try {
if(/UBrowser/i.test(navigator.userAgent)){
return '';
}
if (typeof window.scrollMaxX !== 'undefined') {
return '';
}
weixin://dl/stickers
weixin://dl/games
weixin://dl/moments
weixin://dl/add
weixin://dl/shopping
weixin://dl/groupchat
weixin://dl/scan
weixin://dl/profile
weixin://dl/settings
weixin://dl/general
@aNd1coder
aNd1coder / angular-application-directory-structure.txt
Created January 10, 2016 13:33
Angular application directory structure.
app/
----- shared/ // acts as reusable components or partials of our site
---------- sidebar/
--------------- sidebarDirective.js
--------------- sidebarView.html
---------- article/
--------------- articleDirective.js
--------------- articleView.html
----- components/ // each component is treated as a mini Angular app
---------- home/
@aNd1coder
aNd1coder / simple_javascript_inheritance.js
Created January 21, 2016 14:09
Simple JavaScript Inheritance
/* Simple JavaScript Inheritance
* By John Resig http://ejohn.org/
* MIT Licensed.
*/
// Inspired by base2 and Prototype
(function(){
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
// The base Class implementation (does nothing)
this.Class = function(){};
@aNd1coder
aNd1coder / log.js
Created March 19, 2016 05:44
用全局变量接收创建的Image对象,防止临时变量被回收而导致统计数据丢失
// http://oldj.net/article/one-thing-to-notice-about-new-image/
var img = new Image();
var rnd_id = "_img_" + Math.random();
window[rnd_id] = img; // 全局变量引用
img.onload = img.onerror = function () {
window[rnd_id] = null; // 删除全局变量引用
}
@aNd1coder
aNd1coder / parseurl.js
Created April 14, 2016 07:32
A useful javascript url parse function
function parseURL(url) {
var parser = document.createElement('a'),
searchObject = {},
queries, split, i;
// Let the browser do the work
parser.href = url;
// Convert query string to object
queries = parser.search.replace(/^\?/, '').split('&');
for( i = 0; i < queries.length; i++ ) {
split = queries[i].split('=');
@aNd1coder
aNd1coder / osx_mysql_ownership_fix
Created May 24, 2016 12:54 — forked from mogetutu/osx_mysql_ownership_fix
'warning the user/local/mysql/data directory is not owned by the mysql user', you have to:
sudo chown -RL root:mysql /usr/local/mysql
sudo chown -RL mysql:mysql /usr/local/mysql/data
sudo /usr/local/mysql/support-files/mysql.server start
@aNd1coder
aNd1coder / mongodb_create_database_and_user.sh
Last active October 18, 2016 02:30
Mongodb create database and user
> use admin
> db.createUser({user: 'root',pwd: '123456',roles: ['root']})
> db.auth('root','123456')
> use page_factory
> db.createUser({user: 'user',pwd: '123456',roles: [{role: 'readWrite', db: 'dbName'}]})
> db.auth('user','123456')