Skip to content

Instantly share code, notes, and snippets.

View hkongm's full-sized avatar
🎯
Focusing

Chris Cai hkongm

🎯
Focusing
View GitHub Profile
// log.js
// https://github.com/bgrins/devtools-snippets
// Adds a `log` function to window object.
// http://www.briangrinstead.com/blog/console-log-helper-function
(function() {
window.log = Function.prototype.bind.call(console.log, console);
})();
// jquerify.js
// https://github.com/bgrins/devtools-snippets
// Add jQuery to any page that does not have it already.
(function () {
if ( !window.jQuery ) {
var s = document.createElement('script');
s.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js');
document.body.appendChild(s);
@keyframes "stickerShake" {
from {
-webkit-transform:rotate(0deg);
-moz-transform:rotate(0deg);
-o-transform:rotate(0deg);
-ms-transform:rotate(0deg);
transform:rotate(0deg)
}
25% {
-webkit-transform:rotate(-8deg);
function QueryStringToJSON() {
var pairs = location.search.slice(1).split('&');
var result = {};
pairs.forEach(function(pair) {
pair = pair.split('=');
result[pair[0]] = decodeURIComponent(pair[1] || '');
});
return JSON.parse(JSON.stringify(result));
@hkongm
hkongm / 360度无限旋转
Created August 29, 2013 08:44
CSS3效果
#pullBar .fi-loop {
display:inline-block;
-moz-animation:rotate 2s linear infinite;
-webkit-animation:rotate 2s linear infinite;
animation:rotate 2s linear infinite;
}
@-moz-keyframes rotate {
0% {
-moz-transform:rotate(0deg);
if ("geolocation" in navigator) {
navigator.geolocation.getCurrentPosition(function(position) {
var jingdu = position.coords.longitude, // 经度
weidu = position.coords.latitude; // 纬度
});
} else {
alert('您的浏览器不支持地理位置查询!');
}
@hkongm
hkongm / push合并数组
Created August 28, 2013 01:37
Array原生方法重要应用
var mergeTo = [4,5,6];
var mergeFrom = [7,8,9];
Array.prototype.push.apply(mergeTo, mergeFrom);
mergeTo; // is: [4, 5, 6, 7, 8, 9]