git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
git reset --hard HEAD # Revert (rolling back) to your current head point
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = getParam('url'); | |
$encode = getParam('encode'); | |
$file = 'cache/'.md5($url); | |
$exist = file_exists($file); | |
if($exist && (time() - filemtime($file) < 3600)){ // use cache during 10 minutes | |
echo file_get_contents($file); | |
exit(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en" ng-app="demoApp"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Angular demo - show-more</title> | |
<style> | |
li{list-style:none;} | |
li .item{display:block;width:200px;margin-bottom:10px;padding:2px 4px;border:1px solid #888;} | |
li:nth-child(even) .item{background-color:#DDD;} | |
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>JS Copy</title> | |
</head> | |
<body> | |
<h1>Pure JavaScript Copy</h1> | |
<button id="copyBtn">Copy Content</button> | |
<button id="randomBtn">Change Content</button> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the functional programming version | |
const find2 = (f => f(f))(f => | |
(next => (x, y, i = 0) => | |
(i >= x.length) ? null : | |
(x[i] === y) ? i : | |
next(x, y, i+1))((...args) => | |
(f(f))(...args))); | |
let arr = [0, 1, 2, 3]; | |
console.log(find2(arr, 2)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Curry(咖喱) 的概念很简单:只传递给函数一部分参数来调用它,让它返回一个函数去处理剩下的参数。 | |
- 柯里化: http://baike.baidu.com/view/2804134.htm | |
- Currying: https://en.wikipedia.org/wiki/Currying | |
- Lodash: https://lodash.com/docs#curry | |
- Lodash-FP:https://github.com/lodash-archive/lodash-fp | |
- Ramda:http://ramdajs.com/ | |
*/ | |
function match(what) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var utils = window.utils = { | |
random: function (min, max) { | |
min = min || 0; | |
max = max || 10000; | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
}, | |
uuid: function (identifyNumber, options) { | |
var time = new Date().getTime(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>CSS margin percentage</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> | |
<style> | |
.container{margin:20px auto;padding:20px;width:600px;height:200px;border:1px solid #CCC;} | |
.inner{height:50%;background-color:#F90;margin-top:10%;padding:10%;margin-left:10%;} | |
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<h1>Test http call (<?php echo mt_rand(10,100)?>)</h1> | |
</head> | |
<body> | |
<h1>Test http call</h1> | |
<ul> | |
<li><a href="call.php">Test</a></li> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var iframe = document.createElement("iframe"); | |
document.body.appendChild(iframe); | |
var originWindow=iframe.contentWindow, | |
currentWindow=window | |
var origin =Object.keys(originWindow), | |
current =Object.keys(currentWindow), | |
extendAttr={}; | |
current.forEach((key)=>{ | |
if(originWindow[key]===undefined){ |