Skip to content

Instantly share code, notes, and snippets.

@aNd1coder
aNd1coder / configuration-redis-password.sh
Created June 2, 2016 13:11
Configuration redis password
$ sudo vim /etc/redis/redis.conf
$ requirepass <password>
$ sudo service redis restart
$ redis-cli -h 127.0.0.1 -p 6379 -a <password>
@aNd1coder
aNd1coder / vagrant-homestead-php7-redis.sh
Last active September 19, 2019 12:57
Installing PHP REDIS PHP7 Branch On Fresh Install Homestead PHP7 Branch
vagrant@homestead:~$ sudo apt-get update
vagrant@homestead:~$ git clone -b php7 https://github.com/phpredis/phpredis.git
vagrant@homestead:~$ sudo mv phpredis/ /etc/
vagrant@homestead:~$ cd /etc/phpredis
vagrant@homestead:/etc/phpredis$ phpize
vagrant@homestead:/etc/phpredis$ ./configure
vagrant@homestead:/etc/phpredis$ make && make install
# Note This is an Extension You Need to Enable to Make it Work in Php 7
# This First Command Will Allow You To Call PHPREDIS Facade in Browser
@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')
@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 / 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 / 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 / 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 / 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/
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
// 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 '';
}