Skip to content

Instantly share code, notes, and snippets.

View leopku's full-sized avatar

Song Liu leopku

View GitHub Profile
@leopku
leopku / chinaunicorn.go
Last active February 25, 2018 04:59
某通流量
// http://shifei.me/index.php/archives/10/
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
module.exports = {
*beforeSendResponse(req, res) {
let { response } = res;
const { body } = response;
let document = body.toString();
response.body = new Buffer(document);
return { response };
}
@leopku
leopku / is-private-mode.js
Created December 20, 2017 12:08 — forked from jherax/is-private-mode.js
Detect if a browser is in Private Browsing mode
/**
* Detect if the browser is running in Private Browsing mode
*
* @export
* @returns {Promise}
*/
export default function isPrivateMode() {
return new Promise((resolve) => {
const on = () => resolve(true); // is in private mode
const off = () => resolve(false); // not private mode
@leopku
leopku / getNested.js
Created December 18, 2017 12:37
get a value in deep path from an object
<script id="jsbin-javascript">
let r = document.getElementsByTagName('script')[0];
// console.log(r);
function getNested (theObject, path, defaultValue) {
try {
separator = '.';
return path.
replace('[', separator).replace(']','').
split(separator).
@leopku
leopku / aria2.conf
Created July 16, 2017 12:34 — forked from zfz/aria2.conf
aria2c scripts
#用户名
#rpc-user=user
#密码
#rpc-passwd=passwd
#上面的认证方式不建议使用,建议使用下面的token方式
#设置加密的密钥
#rpc-secret=token
#允许rpc
enable-rpc=true
#允许所有来源, web界面跨域权限需要
@leopku
leopku / .gitlab-ci-golang-glide.yml
Created June 7, 2017 10:47 — forked from tsdtsdtsd/.gitlab-ci-golang-glide.yml
Config for building a golang 1.8 application with glide vendoring on gitlab-ci
image: golang:1.8-alpine # The alpine builds are much smaller but lack tools we need, we'll add them later
stages:
- build
- test
before_script:
- apk --update --upgrade add git curl-dev openssh curl ca-certificates # This is how we add system dependencies.
# You may need less or more packages for your app.
- curl -sS https://glide.sh/get | sh
- mkdir -p /go/src/gitlab.com/
export PATH="$HOME/.rbenv/bin:$HOME/.ndenv/bin:$HOME/.jenv/bin:$HOME/.pyenv/bin:$PATH"
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
export SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/
export PHANTOMJS_CDNURL=https://npm.taobao.org/dist/phantomjs
export ANDROID_HOME=/usr/local/Cellar/android-sdk
eval "$(rbenv init -)"
eval "$(ndenv init -)"
eval "$(jenv init -)"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<mirrors>
<mirror>
<id>aliyun</id>
<mirrorOf>*,!sonar</mirrorOf>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
</settings>
@leopku
leopku / scdaemon_reload.py
Created November 2, 2016 05:21 — forked from bigeagle/scdaemon_reload.py
Along with udevedu, reload gpg scdaemon on yubikey insert
#!/usr/bin/env python2
# -*- coding:utf-8 -*-
from __future__ import print_function, division, unicode_literals
from udevedu.utils import invoke
def init():
print("Monitor Yubikey NEO")
@leopku
leopku / ansible.coffiee
Created October 15, 2016 05:22 — forked from shirou/ansible.coffiee
ansible + hubot + slack integration
settings = {
'test': {
'path': '/home/shirou/ansible/test/',
'inventory': 'inventory'
}
}
module.exports = (robot) ->