Skip to content

Instantly share code, notes, and snippets.

View aprilandjan's full-sized avatar
👻
wandering

May aprilandjan

👻
wandering
View GitHub Profile
@aprilandjan
aprilandjan / 1) Install
Created September 10, 2016 19:44 — forked from nghuuphuoc/1) Install
Install Redis on Centos 6
// --- Compiling ---
$ wget http://download.redis.io/releases/redis-2.8.3.tar.gz
$ tar xzvf redis-2.8.3.tar.gz
$ cd redis-2.8.3
$ make
$ make install
// --- or using yum ---
$ rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
@aprilandjan
aprilandjan / nginxproxy.md
Created September 12, 2016 04:12 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

function parseQuery () {
var search = window.location.search
if (search) {
search = search.substr(1)
let args = search.split('&')
let query = {}
args.forEach(pair => {
let arr = pair.split('=')
let key = arr.shift()
let value = arr.join('=')
@aprilandjan
aprilandjan / rem.js
Last active November 30, 2016 15:22
// 带有一个px作为单位
var rem = {
px: 1
};
var _timeoutId = 0
var _timeout = 0
var _resizeCallbacks = []
var _maxPx
/**
* Created by Merlin on 16/11/30.
*/
const map = new Map()
function getElement (el) {
if (typeof el === 'string') {
el = document.querySelector(el)
}
@aprilandjan
aprilandjan / autoplay-audio-ios.html
Created December 20, 2016 09:08 — forked from ufologist/autoplay-audio-ios.html
在 iOS 微信浏览器中自动播放 HTML5 audio(音乐) 的正确方式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title>Auto play html audio in iOS WeChat InAppBrowser the right way</title>
</head>
<body>
<h1>在 iOS 微信浏览器中自动播放 HTML5 audio(音乐) 的正确方式</h1>
<p>核心原理: 在微信的JS-API 中 play 一下 audio 即可达到自动播放的目的(应该是微信自己做了处理)</p>
@aprilandjan
aprilandjan / grid.scss
Created March 8, 2017 03:28
simple flex grid system
.row {
display: flex;
flex-wrap: nowrap;
flex-shrink: 0;
flex-grow: 0;
align-items: flex-start;
.col-auto {
flex: 1;
}
@aprilandjan
aprilandjan / maths.js
Created April 1, 2017 13:01
bunch of utility methods about Math
/**
* ȡ������֮��������
* @param a
* @param b
* @returns {*}
*/
export function randomNum (a, b) {
return Math.random() * (b - a) + a
}
@aprilandjan
aprilandjan / slugify.js
Last active April 14, 2017 06:54 — forked from mathewbyrne/slugify.js
Javascript Slugify
function slugify(text)
{
return text.toString().trim().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
// .replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/[^a-zA-Z0-9_\u3400-\u9FBF\s-]/g,'') // remove all non-word & non-chinese chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
}
var userAgent = window.navigator.userAgent.toLowerCase()
var ua = {
isIOS: userAgent.match(/iphone|ipad|ipod/i),
isAndroid: userAgent.match(/android/i),
isWechat: userAgent.match(/micromessenger/i),
isWeibo: userAgent.match(/weibo/i),
isQQ: userAgent.match(/qq/i),
isMobile: userAgent.match(/iphone|ipad|ipod|android/i)
}