Skip to content

Instantly share code, notes, and snippets.

View libo1106's full-sized avatar

libo libo1106

View GitHub Profile
@libo1106
libo1106 / button_onclick
Created July 5, 2012 15:06
button.onclick事件汇总
<html>
<input onclick="document.all.WebBrowser.ExecWB(1,1)" type="button" value="打开" name="Button1">
<input onclick="document.all.WebBrowser.ExecWB(4,1)" type="button" value="另存为" name="Button2">
<input onclick="document.all.WebBrowser.ExecWB(10,1)" type="button" value="属性" name="Button3">
<input onclick="document.all.WebBrowser.ExecWB(6,1)" type="button" value="打印" name="Button">
<input onclick="document.all.WebBrowser.ExecWB(8,1)" type="button" value="页面设置" name="Button4">
@libo1106
libo1106 / express_spider.js
Last active December 16, 2019 09:27
PhantomJS spider.js
// ExpressJS调用方式
var express = require('express');
var app = express();
// 引入NodeJS的子进程模块
var child_process = require('child_process');
app.get('/', function(req, res){
// 完整URL
@libo1106
libo1106 / getCalendar.js
Created August 30, 2018 12:07
获取指定月份的日历
/**
* 计算目标月份的日历,返回按星期组合的二维数组
* @param year
* @param month
* @returns {Array|*}
*/
function getDays(year, month) {
// 目标月份第一天
let firstDay = moment(`${year}-${month}`, 'YYYY-MM').startOf('month');
@libo1106
libo1106 / gist:9777985
Last active September 22, 2016 06:51
flex未知高度垂直居中写法
<!DOCTYPE html>
<html lang="zh-CN" class="fullscreen">
<head>
<title>flex未知高度垂直居中写法</title>
<style>
html,body{
width: 100%;
height: 100%;
overflow: hidden;
@libo1106
libo1106 / media.css
Created February 23, 2016 03:29
Media Query For FullPage Moible Web
// iPhone4 WeChat WebView
@media screen and (max-height:416px){
}
// iPhone5 WeChat WebView
@media screen
and (min-height: 417px)
and (max-height: 504px){
@libo1106
libo1106 / gist:7868463
Created December 9, 2013 07:12
通过给参数赋值undefined,可以让$.ajax不传该参数
$.ajax( 'api.demo.com/api' ,{
type: 'POST',
data: {
dateType: hasDateType ? DateType : undefined
},
dataType: 'json',
success: function(resp){
}
})
@libo1106
libo1106 / gist:7748731
Created December 2, 2013 12:23
统计上周、上个月的工作日
<?php
function _countWorkDate(){
$arrayDays = []; // 计算周期内总工作日
$holiday = array(
'2013-01-01','2013-01-02','2013-01-03',
'2013-02-09','2013-02-10','2013-02-11','2013-02-12','2013-02-13','2013-02-14','2013-02-15',
'2013-04-04','2013-04-05','2013-04-06',
'2013-04-29','2013-04-30','2013-05-01',
'2013-06-10','2013-06-11','2013-06-12',
'2013-09-19','2013-09-20','2013-09-21',
@libo1106
libo1106 / UserAgentMatch.php
Last active December 29, 2015 08:29
UserAgent 匹配Android和iOS,并获得对于的版本号
<?php
/*
* UserAgent 匹配Android和iOS,并获得对于的版本号
*/
function match($ua){
if( strpos($ua, 'Android')){// 匹配 Android
preg_match('/(Android)[\/ ]([\d._]+)/', $ua, $match);
}else if( strpos($ua, 'Mobile')){// 匹配 iOS
preg_match('/(OS) ([\d._]+)/', $ua, $match);
}else{
@libo1106
libo1106 / gist:7427779
Created November 12, 2013 09:02
JavaScript数组简单去重
Array.prototype.unique = function(){
var results=this.sort();/*排序*/
for ( var i = 1; i < results.length; i++ ) {
if ( results[i] === results[ i - 1 ] ) {
results.splice( i--, 1 );/*删除相邻相同元素*/
}
}
return results;
};
@libo1106
libo1106 / loadScript
Created October 14, 2013 15:15
loadScript 给页面添加外部script
function loadScript (doc, type, src, callback) {
var script = doc.createElement('script');
script.type = type ? type : 'application/javascript';
script.onload = callback;
script.src = src;
doc.head.appendChild(script);
}