Skip to content

Instantly share code, notes, and snippets.

@StuPig
StuPig / google.md
Created December 12, 2013 14:59
1. 解决google搜索结果页二次跳转的问题 2. 解决google被墙的问题
  1. 使用AdBlock去广告扩展的人,增加一条规则,变成多功能扩展,屏蔽香港域名跳转加入以下自订规则: ||google.com.hk$script,这样点搜索结果时就不会自动在url里加入google的链接了。注意根据你的搜索引擎是否是hk来去掉规则里面的hk
  2. 打开Chrome,在地址栏键入chrome://net-internals/,在HSTS选项卡下的Domain中输入你想要实现这个强制跳转的域名,例如你Chrome的默认搜索引擎是www.google.com,就在add domain里填写www.google.com,记得在下面的include subdomains打对勾,确保google的二级域名也是加密的,这样跳转结果页也是加密的,然后就可以打开结果页面了
  3. 将搜索引擎改为googlestable.com
@StuPig
StuPig / water_ripple_canvas.js
Created February 8, 2014 02:27
Use JavaScript and canvas to create water ripple effect
/*
* Water Canvas by Almer Thie (http://code.almeros.com).
* Description: A realtime water ripple effect on an HTML5 canvas.
* Copyright 2010 Almer Thie. All rights reserved.
*
* Example: http://code.almeros.com/code-examples/water-effect-canvas/
* Tutorial: http://code.almeros.com/water-ripple-canvas-and-javascript
*/
@StuPig
StuPig / truck_v2.js
Created February 16, 2014 07:40
转换为标准路径
/**
* 路径转换为标准路径
* @param path
* @return {String|XML}
*/
getRealPath: function (path) {
var DOT_RE = /\/\.\//g,
DOUBLE_DOT_RE = /\/[^\/]+\/\.\.\//;
// /a/b/./c/./d ==> /a/b/c/d
@StuPig
StuPig / shuffle.js
Created March 6, 2014 02:41
shufle js洗牌算法
// more on: http://jsperf.com/js-shuffle-test/2
/**
* 数组洗牌算法
* @param arr
*/
function shuffle(arr) {
var s = [];
while (arr.length) s.push(arr.splice(Math.random() * arr.length, 1)[0]);
arr = arr.concat(s);
input {
border: none;
border-bottom: 1px solid #01a34b;
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fff), to(#01a34b), color-stop(80%, #fff), color-stop(81%, #01a34b), color-stop(100%, #01a34b)),-webkit-gradient(linear, 0 0, 0 100%, from(#fff), to(#01a34b), color-stop(80%, #fff), color-stop(81%, #01a34b), color-stop(100%, #01a34b));
background-size: 1px 100%;
background-position: 0 0, 100% 0;
background-repeat: no-repeat;
}
input:focus,
*{margin:0;padding:0;}
.grid {
padding: 600px 0;
background-repeat: repeat-y;
background-size: 1px auto;
}
@media screen and (max-width:480px) {
.grid {
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ccc), to(#ccc)), -webkit-gradient(linear, 0 0, 0 100%, from(#ccc), to(#ccc));
background-position:33% 0,66% 0;
@StuPig
StuPig / parseURI.js
Created June 19, 2014 13:49
parse URI to URI object like location object。URI转换,secheme转换
function parseURI (uri) {
"use strict";
if (!uri) return;
var regexMaybe = function (str) {
return '(?:' + str + ')?';
},
reg = new RegExp('^' + regexMaybe('(([^:]+):)?') + '\\/\\/([^:/]+)/*' + regexMaybe(':(\\d+)\\/*') + regexMaybe('([^?#]+)') + regexMaybe('\\?([^#]+)') + regexMaybe('#(\\w+)')),
match = uri.match(reg),
protocol = match[1] || '',
@StuPig
StuPig / clean_branch.sh
Created November 7, 2014 08:35
git分支清理脚本 script to clean git remote branches
#!/bin/bash
echo '***********************************';
echo '*';
echo -e '*\t分支清理';
echo '*';
echo '***********************************';
echo '';
# 切到主干分支develop,更新远程分支
@StuPig
StuPig / pre-push
Created December 9, 2014 12:18
禁止直接向master和develop分之提交代码的钩子,放在.git/hooks/pre-push
#!/bin/bash
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ "$current_branch" = "master" ] || [ "$current_branch" = "develop" ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo ""
echo "禁止直接向master或develop分支提交代码!"
echo ""
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit 1
@StuPig
StuPig / color.sh
Created December 10, 2014 07:47
shell echo 输出颜色
#!/bin/bash
RCol='\033[0m' # Text Reset
# Regular Bold Underline High Intensity BoldHigh Intens Background High Intensity Backgrounds
Bla='\033[0;30m'; BBla='\033[1;30m'; UBla='\033[4;30m'; IBla='\033[0;90m'; BIBla='\033[1;90m'; On_Bla='\033[40m'; On_IBla='\033[0;100m';
Red='\033[0;31m'; BRed='\033[1;31m'; URed='\033[4;31m'; IRed='\033[0;91m'; BIRed='\033[1;91m'; On_Red='\033[41m'; On_IRed='\033[0;101m';
Gre='\033[0;32m'; BGre='\033[1;32m'; UGre='\033[4;32m'; IGre='\033[0;92m'; BIGre='\033[1;92m'; On_Gre='\033[42m'; On_IGre='\033[0;102m';
Yel='\033[0;33m'; BYel='\033[1;33m'; UYel='\033[4;33m'; IYel='\033[0;93m'; BIYel='\033[1;93m'; On_Yel='\033[43m'; On_IYel='\033[0;103m';
Blu='\033[0;34m'; BBlu='\033[1;34m'; UBlu='\033[4;34m'; IBlu='\033[0;94m'; BIBlu='\033[1;94m'; On_Blu='\033[44m'; On_IBlu='\033[0;104m';