Skip to content

Instantly share code, notes, and snippets.

View 52cik's full-sized avatar

楼教主 52cik

View GitHub Profile
@52cik
52cik / countDown.js
Created June 6, 2017 06:29
倒计时处理方法 (精确时间处理)
/**
* 倒计时处理方法 (精确时间处理)
*
* @param {Number} seconds 剩余秒数/时间戳
* @param {Function} callback 回调函数
* @param {Boolean} timeStamp 是否时间戳
*
* 使用例子
*
* // 情况1:后台给的是倒计时 秒
@52cik
52cik / wxbg.js
Created December 26, 2016 05:51
微信背景音乐自动播放
// <audio src="bg.mp3" id="media" autoplay loop preload="auto"></audio>
var player = document.getElementById('media');
player.play();
// iphone 下要监听 WeixinJSBridgeReady 事件
document.addEventListener('WeixinJSBridgeReady', function () {
player.play();
}, false);
@52cik
52cik / post-receive.sh
Created January 13, 2017 06:39 — forked from icyleaf/post-receive.sh
git autodeploy script when it matches the string "[deploy]"
#!/bin/sh
#
# git autodeploy script when it matches the string "[deploy]"
#
# @author icyleaf <icyleaf.cn@gmail.com>
# @link http://icyleaf.com
# @version 0.1
#
# Usage:
# 1. put this into the post-receive hook file itself below
@52cik
52cik / formatDate.js
Created March 13, 2016 11:20
js 日期格式化
function formatDate(date, formater) {
date = new Date(date);
var week = '日一二三四五六';
var data = {
'y': date.getFullYear(), // 年
'M': date.getMonth() + 1, // 月
'd': date.getDate(), // 日
'E': week.charAt(date.getDay()),
'h': date.getHours(), // 小时
@52cik
52cik / server_date.js
Created March 31, 2016 03:40
ajax 获取服务器日期
$.ajax('?', {type:'head'}).done(function(data, status, xhr) {
var dt = new Date(xhr.getResponseHeader('Date')); // 字符串转日期对象
console.log(dt.toLocaleString());
});
@52cik
52cik / opener.js
Created November 11, 2016 05:41
修改连接跳转页面地址
var opener = parent.window.opener;
opener && (opener.location='http://www.baidu.com/');
@52cik
52cik / crockford-style.js
Created September 26, 2016 12:15 — forked from nolanlawson/crockford-style.js
Updated IIFE benchmark
var s = performance.now();
/**
* Copyright (c) 2014-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
(function () { 'use strict';var SLICE$0 = Array.prototype.slice;
@52cik
52cik / ls.js
Created September 1, 2016 12:19
简易 localStorage/sessionStorage 封装
(function(window, undefined) {
// 编码
function encode(str) {
return encodeURIComponent(JSON.stringify(str));
}
// 解码
function decode(str) {
if (undefined == str) {
@52cik
52cik / .gitattributes
Created August 12, 2016 10:27
忽略 github 归档文件
# Ignore all test and documentation for archive
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/tests export-ignore
/docs export-ignore
@52cik
52cik / 1px-gif.html
Created May 21, 2016 13:20
1x1px 透明 gif 的 base64 代码
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=">