Skip to content

Instantly share code, notes, and snippets.

@qiu8310
qiu8310 / php_whitespace_regexp.php
Last active December 14, 2015 02:07
php whitespace regexp warning
<?php
/*
http://php.net/manual/en/regexp.reference.escape.php
The "whitespace" characters are HT (9), LF (10), FF (12), CR (13), and space (32).
However, if locale-specific matching is happening, characters with code points in
the range 128-255 may also be considered as whitespace characters,
for instance, NBSP (A0).
@qiu8310
qiu8310 / bling.js
Last active August 29, 2015 14:23 — forked from paulirish/bling.js
/* bling.js */
window.$ = document.querySelectorAll.bind(document)
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn)
}
NodeList.prototype.__proto__ = Array.prototype
@qiu8310
qiu8310 / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@qiu8310
qiu8310 / SassMeister-input-HTML.html
Created September 16, 2014 06:17
Generated by SassMeister.com.
<div class="root en">
<ul class="links">
<li class="link">
<a class="link-home"><i class="icon">tag</i>HOME</a>
</li>
<li class="link">
<a class="link-about"><i class="icon">tag</i>ABOUT</a>
</li>
</ul>
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
function git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "("${ref#refs/heads/}") ";
}
function git_since_last_commit {
now=`date +%s`;
last_commit=$(git log --pretty=format:%at -1 2> /dev/null) || return;
seconds_since_last_commit=$((now-last_commit));
minutes_since_last_commit=$((seconds_since_last_commit/60));
@qiu8310
qiu8310 / example.html
Created December 27, 2013 15:13 — forked from kylebarrow/example.html
example: mobile-safari-standalone-mode
<!DOCTYPE html>
<head>
<title>Stay Standalone</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<script src="stay_standalone.js" type="text/javascript"></script>
</head>
<body>
<ul>
<li><a href="http://google.com/">Remote Link (Google)</a></li>
@qiu8310
qiu8310 / hideaddrbar.js
Created December 27, 2013 14:14 — forked from scottjehl/hideaddrbar.js
snippet: js-hide-address-bar
/*
* Normalized hide address bar for iOS & Android
* (c) Scott Jehl, scottjehl.com
* MIT License
*/
(function( win ){
var doc = win.document;
// If there's a hash, or addEventListener is undefined, stop here
if( !location.hash && win.addEventListener ){
@qiu8310
qiu8310 / jQueryArt_jQuery.Deferred.then.js
Last active December 29, 2015 05:49
example: jquery-deferred-then
/* 三个步骤串连起来了 */
$.Deferred(function (dfd) {
setTimeout(function () {dfd.resolve('step 1');}, 1000);
}).promise()
.then( // then 返回的是个新的 promise 对象
function (arg) {
console.log('finish ' + arg);
return $.Deferred(function (dfd) {
setTimeout(function (){newDfd.resolve('step 2');}, 1000);
}).promise();
@qiu8310
qiu8310 / animation_event.html
Last active December 28, 2015 20:29
example: js&css-animation-event
<!doctype html>
<html>
<head>
<title>CSS animations: Animation events</title>
<style type="text/css">
.slidein {
-moz-animation-duration: 3s;
-webkit-animation-duration: 3s;
-moz-animation-name: slidein;
-webkit-animation-name: slidein;