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 / redis.php
Created January 13, 2017 11:33
php-redis-on-windows
<?php
$host = 'test.kvstore.aliyuncs.com';
$port = 6379;
$user = 'username';
$pwd = 'password1234';
$key = 'the_stored_key';
$redis = new Redis();
if ($redis->connect($host, $port) == false) {
die($redis->getLastError());
@wuliupo
wuliupo / ellipsis.htm
Last active November 18, 2016 03:16
CSS ellipsis
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS ellipsis</title>
</head>
<style>
div {
margin: 20px auto;
border: 1px solid #CCC;
@wuliupo
wuliupo / property-extend.js
Created November 11, 2016 09:09
property extended from parent
var parentObj = {a:2};
var sunObj = Object.create( parentObj );
parentObj.a; // 2
sunObj.a; // 2
parentObj.hasOwnProperty( "a" ); // true
sunObj.hasOwnProperty( "a" ); // false
sunObj.a++; // block mode
parentObj.a; // 2
sunObj.a; // 3
sunObj.hasOwnProperty("a"); // true ???
@wuliupo
wuliupo / closure-var.js
Created November 9, 2016 07:30
let-var
for(var i = 1; i <= 5; i++){
setTimeout(function(){
console.log(i);
}, 10);
}
// 5, 5, 5, 5, 5
for(let i = 1; i <= 5; i++){
setTimeout(function(){
@wuliupo
wuliupo / module-define.js
Created November 9, 2016 07:29
JavaScript modern module definition
var MyModules = (function() {
var modules = {};
return {
defineModule(name, deps, impl) {
for (var i = 0; i < deps.length; i++) {
deps[i] = modules[deps[i]];
}
modules[name] = impl.apply(impl, deps);
}, getModule(name) {
return modules[name];
@wuliupo
wuliupo / rank-star.htm
Last active November 9, 2016 03:18
Rank Star via Angular 1
<!doctype html>
<html lang="en" ng-app="demoApp">
<head>
<meta charset="UTF-8">
<title>Rank Star</title>
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style>
.glyphicon-star.orange{margin-right:3px;padding:2px;border-radius:3px;text-align:center;font-size:10px;color:#FFF;background-color:#f63;}
.glyphicon-star.gray{margin-right:3px;padding:2px;border-radius:3px;text-align:center;font-size:10px;background-color:#CCC;color:#FFF;}
.big .glyphicon-star{font-size:18px;margin:-2px 8px 0 0;}
@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){
@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 / 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 / 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(),