Skip to content

Instantly share code, notes, and snippets.

View libo1106's full-sized avatar

libo libo1106

View GitHub Profile
@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 / 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 / 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 / casper.js
Last active November 9, 2015 15:14
casperjs SEO优化
var casper = require('casper').create();
casper.start('http://wj.qq.com/survey.html?type=survey&id=124133&hash=257b');
casper.waitForResource('/image/end.png', function(){
this.echo(this.getHTML());
});
casper.run();
@libo1106
libo1106 / imgAllLoadCall.js
Last active October 27, 2015 11:32
当页面中全部img都onload后执行
/**
* 页面中全部img都onload后执行
* @param callback
* @param opts.timeout 超时执行
*/
function imgAllLoadCall(callback, opts) {
var imagesCount = 0; // 待加载img计数
var successCount = 0; // 已加载img计数
var images = document.images; // document中所有img的数组集合
http://hi.baidu.com/zhmsong/blog/item/7cb17eeaddca8adad539c977.html
:s/XXX/YYY/g
其中XXX是需要替换的字符串,YYY是替换后的字符串
以上这句只对当前行进行替换,如果需要进行全局替换,则要:
%s/XXX/YYY/g
如果需要对指定部分进行替换,可以用V进入visual模式,再进行
:s/XXX/YYY/g
或者可以指定行数对指定范围进行替换:
@libo1106
libo1106 / ajaxUploadFile.js
Last active August 29, 2015 14:17
Ajax 上传文件
/**
* XHR2特性,使得ajax可以上传文件
**/
post_image: function(file, success){
if(!file){
return false;
}
var url = server + 'post_image';
@libo1106
libo1106 / pushNotification.js
Last active August 29, 2015 14:15
pushNotification插件的AMD封装
/**
* Created by libo on 15/2/12.
* 依赖: framework7 和 PushPlugin
*/
/*global define, console*/
define(function (require, exports, modules) {
'use strict';
require('lib/PushNotification');
var Framework7 = require('framework7');
@libo1106
libo1106 / jQuery.tt.js
Last active August 29, 2015 14:09
jQuery Transform & Transition Shortcuts
/**
* jQuery Transform & Transition Shortcuts
*
* 从Framework7中的DOM7剥离重构一些有用的片段
*/
;(function(){
// 变换
$.fn.transform = function(transform){
@libo1106
libo1106 / defalut.conf
Last active August 29, 2015 14:07
ThinkPHP Nginx Rewrite
location / {
if (!-e $request_filename){
rewrite ^(.*) /index.php?s=$1 last;
break;
}
}