Skip to content

Instantly share code, notes, and snippets.

View wuliupo's full-sized avatar
🎯
Focusing: Jenkins, Vue, React

Pauli wuliupo

🎯
Focusing: Jenkins, Vue, React
View GitHub Profile
@wuliupo
wuliupo / get.php
Created June 14, 2016 05:13
PHP get remote file, anti anti spam
<?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();
}
@wuliupo
wuliupo / show-more.htm
Created October 12, 2016 06:08
Angular demo - show-more
<!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>
@wuliupo
wuliupo / copy.htm
Created October 13, 2016 02:57
Pure JavaScript Copy
<!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>
@wuliupo
wuliupo / git-util.md
Last active June 12, 2017 10:21 — forked from stuart11n/gist:9628955
rename git branch locally and remotely

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
@wuliupo
wuliupo / functional.js
Last active June 12, 2017 10:17
Functional programming
// 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));
@wuliupo
wuliupo / curry.js
Last active June 12, 2017 10:19
Currying-柯里化
/*
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) {
@wuliupo
wuliupo / utils.js
Created October 24, 2016 08:35
Utilities
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(),
@wuliupo
wuliupo / percentage.htm
Created November 3, 2016 02:18
CSS percentage of margin & padding
<!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>
@wuliupo
wuliupo / call.php
Last active November 4, 2016 07:05
Test http call
<!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>
@wuliupo
wuliupo / extend-attr.js
Created November 8, 2016 10:09
Check extended attributes from original window
(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){