Skip to content

Instantly share code, notes, and snippets.

@StuPig
StuPig / handlebar_partials.html
Created December 16, 2012 07:15
handlebars partials demo
<!DOCTYPE html>
<html>
<head>
<title>Handlebars Partials Example</title>
</head>
<body>
<h1>Handlebars Partials Example!</h1>
<div id="list">
</div>
@StuPig
StuPig / gist-slide
Last active December 10, 2015 17:08
!SLIDE
# 前端组2012Q4工作总结 - 巩守强
!SLIDE
##
[Picture Show ためしてみたお( ^ω^) ](http://d.hatena.ne.jp/xuwei/20110903/1315044919)
@StuPig
StuPig / detectLocalStorage.js
Created July 19, 2013 07:25
detect and use localStorage
// Feature detect + local reference
var storage,
fail,
uid;
try {
uid = new Date;
(storage = window.localStorage).setItem(uid, uid);
fail = storage.getItem(uid) != uid;
storage.removeItem(uid);
fail && (storage = false);
@StuPig
StuPig / require.cache.js
Last active December 20, 2015 01:59
use ajax to load script
define(['module'], function (module) {
'use strict';
var storage = (function(){
var uid = new Date,
result;
try {
localStorage.setItem(uid, uid);
result = localStorage.getItem(uid) == uid;
localStorage.removeItem(uid);
@StuPig
StuPig / throttle.js
Created August 28, 2013 02:42
js方法执行频次限制(时间)
function throttle( fn, time ) {
var t = 0;
return function() {
var args = arguments, ctx = this;
clearTimeout(t);
t = setTimeout( function() {
fn.apply( ctx, args );
}, time );
};
@StuPig
StuPig / parrallax_library_bookmark.markdown
Created September 3, 2013 03:03
视差动画库收集 A collection of parallax scrolling library bookmarks
@StuPig
StuPig / dataStorage.js
Created October 12, 2013 12:21
localSorage封装,api借鉴了store.js,加入过期机制,和安全插入
/*jslint debug: true,
undef: false */
;(function(win, doc){
var localStorageName = 'localStorage';
var _util = {
isLocalStorageNameSupported: function() {
// 加try{}catch(){}的为了防止Firefox浏览器改配置dom.Storage = false时crash掉
try { return (localStorageName in win && win[localStorageName]) }
catch(err) { return false }
},
@StuPig
StuPig / changeAlinks4iOS.html
Last active December 26, 2015 20:28
Prevent links in standalone web apps opening Mobile Safari. Reference: https://gist.github.com/kylebarrow/1042026#comment-37145 https://gist.github.com/irae/1042167
// add this inlined to <head> and before all <links>
<script>
(function(document,navigator,standalone) {
// prevents links from apps from oppening in mobile safari
// this javascript must be the first script in your <head>
if ((standalone in navigator) && navigator[standalone]) {
var curnode, location=document.location, stop=/^(a|html)$/i;
document.addEventListener('click', function(e) {
curnode=e.target;
while (!(stop).test(curnode.nodeName)) {
@StuPig
StuPig / shell_scripts.sh
Last active December 28, 2015 17:48
shell 小脚本
# 查找当前文件夹及其子文件夹下包含某个字符串的某类型文件
# From http://www.ai7.org/wp/html/653.html
find . -name "*.js"|xargs grep require
@StuPig
StuPig / cache.js
Last active December 28, 2015 23:18
require localStorage plugin
/**
* USAGE:
* 外部定义全局变量 RSINFO = { 'path': 'version' }
*/
(function (win) {
var rslist,
RSLIST_KEY = 'rslist',
RSINFO = win.RSINFO || {},
isLocalStorageSupported = (function() {