Skip to content

Instantly share code, notes, and snippets.

View bingdian's full-sized avatar
🎯
Focusing

bingdian bingdian

🎯
Focusing
View GitHub Profile
@bingdian
bingdian / _service.md
Created October 2, 2021 07:08 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@bingdian
bingdian / nginx-location
Created March 27, 2018 06:24 — forked from luxixing/nginx-location
nginx location 匹配规则
1 普通匹配,遵循最长匹配规则,假设一个请求匹配到了两个普通规则,则选择匹配长度大的那个
例如:
location /{
[matches]
}
location /test{
[matches]
}
2 精确匹配
location = /{
@bingdian
bingdian / vhost.sh
Created January 21, 2018 10:15
debina vhost
#!/bin/bash
### Set Language
TEXTDOMAIN=virtualhost
### Set default parameters
action=$1
domain=$2
port=$3
rootDir=$4
owner=$(who am i | awk '{print $1}')
@bingdian
bingdian / vhost.sh
Last active January 21, 2018 09:28
nginx host
#!/bin/bash
### Set Language
TEXTDOMAIN=virtualhost
### Set default parameters
action=$1
domain=$2
port=$3
rootDir=$4
owner=$(who am i | awk '{print $1}')
@bingdian
bingdian / pp2t_vpn.sh
Created April 23, 2017 13:23 — forked from HenryYang/pp2t_vpn.sh
Easy Install PP2P VPN
#!/bin/bash
apt-get update
apt-get install -y pptpd
echo "localip 192.168.0.1" >> /etc/pptpd.conf
echo "remoteip 192.168.0.128-255" >> /etc/pptpd.conf
echo "ms-dns 8.8.8.8" >> /etc/ppp/pptpd-options
@bingdian
bingdian / 1. Example Spec.js
Created December 8, 2016 10:46 — forked from Integralist/1. Example Spec.js
Mocking a Window object for unit-testing purposes
var mocks = {
resizeCalled: false,
createFakeWindow: function(width, height) {
var module = this;
return {
document: {
documentElement: {
clientWidth: width,
@bingdian
bingdian / generator.js
Last active July 31, 2016 09:31
Generator random string
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function generatorRandomString() {
return Math.random().toString(36).substr(2,6);
}
function generatorEmailSuffix() {
var domains = ['.com', '.net', '.org', '.cc', '.edu', '.cn'],
@bingdian
bingdian / README.md
Created May 9, 2016 11:52 — forked from steve-jansen/README.md
Stop and start Symantec Endpoint Protection on OS X

This script enables you stop and start Symantec Endpoint Protection on OS X

Installation

sudo curl https://gist.github.com/steve-jansen/61a189b6ab961a517f68/raw/sep -o /usr/local/bin/sep
sudo chmod 755 /usr/local/bin/sep
sudo chown root:staff /usr/local/bin/sep
@bingdian
bingdian / ngjson.js
Created March 7, 2016 03:02 — forked from tshaddix/ngjson.js
Very basic modification of Express JS res.json(). Adds the safety prefix for Angular JS to the body of all json responses. Extends the response object with one method: ngJSON. Simply require file somewhere in application (normally app.js) before executing ngJSON responses.
var http = require('http');
var NG_PREFIX = ")]}',\n";
http.ServerResponse.prototype.ngJSON = function(obj){
// allow status / body
if (2 == arguments.length) {
// res.json(body, status) backwards compat
if ('number' == typeof arguments[1]) {
this.statusCode = arguments[1];
@bingdian
bingdian / gist:ca67d7e18d09b76b29ec
Created December 11, 2015 03:45 — forked from xbx/gist:1533842
My pre-commit hook for git, check non-ascii-files, jshint, csshint
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1