Skip to content

Instantly share code, notes, and snippets.

View xhinking's full-sized avatar

Wang xhinking

  • HangZhou
  • 00:52 (UTC +08:00)
View GitHub Profile
// MWWebSnapshot
//
// Created by Jim McGowan on 08/09/2010.
// Copyright 2010 Jim McGowan. All rights reserved.
//
// This code is made available under the BSD license.
// Please see the accompanying license.txt file
// or view the license online at http://www.malkinware.com/developer/License.txt
//
//
@xhinking
xhinking / index.js
Created December 26, 2014 06:21
Determine if the given hex color is light or dark. Helpful to determining foreground color against a background color.
// https://github.com/scottcorgan/contrast
var hexToRgb = require('hex-to-rgb');
module.exports = function contrast (hex) {
var rgb = hexToRgb(hex);
var o = Math.round(((parseInt(rgb[0]) * 299) + (parseInt(rgb[1]) * 587) + (parseInt(rgb[2]) * 114)) /1000);
return (o <= 180) ? 'dark' : 'light';
};
@xhinking
xhinking / umeng-style.css
Last active September 6, 2015 08:26
Umeng New Style
body {
height: auto;
min-height: 100%;
margin: 0;
padding: 0;
font-family: 'Helvetica Neue', "Hiragino Sans GB","Microsoft YaHei",sans-serif;
font-size: 14px;
-webkit-font-smoothing: antialiased;
}
@xhinking
xhinking / slide.js
Created June 9, 2011 14:28
Github Tree Slide
$('#slider a').click(function() {
history.pushState({ path: this.path }, '', this.href)
$.get(this.href, function(data) {
$('#slider').slideTo(data)
})
return false
})
@xhinking
xhinking / unslide.js
Created June 10, 2011 01:50
Github Tree Slide2
$(window).bind('popstate', function() {
$('#slider').slideTo(location.pathname)
})
@xhinking
xhinking / detect.py
Created July 2, 2011 13:26
Google Language Detect Ajax Web Service
From -> http://www.cnblogs.com/zhengyun_ustc/archive/2010/10/26/1860897.html
#############
import urllib
import httplib2
try:
from base import easyjson
except:
pass
<!doctype html>
<html>
<head>
<title>知乎阅读</title>
<meta charset="utf-8">
<meta name="MobileOptimized" content="1024">
<meta name="HandheldFriendly" content="True">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="http://static.zhihu.com/static/img/reader/ipad-icon.png?ver=3" />
<link rel="apple-touch-startup-image" href="http://static.zhihu.com/static/img/reader/ipad-splash-landscape.png" media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape)" />
<link rel="apple-touch-startup-image" href="http://static.zhihu.com/static/img/reader/ipad-splash-portrait.png" media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait)" />
<link rel="stylesheet" href="http://static.zhihu.com/static/css/reader/main.css?v=1.8" type="text/css" media="screen" />
<script type="text/javascript" src="http://static.evernote.com/noteit.js"></script>
<script type="text/javascript" src="http://static.zhihu.com/static/img/reader/scrollability.min.js"></script>
</head>
<script type="text/javascript">
function addEventSimple(obj,evt,fn){
if(obj.addEventListener){
obj.addEventListener(evt,fn,false);
}else if(obj.attachEvent){
obj.attachEvent('on'+evt,fn);
}
}
addEventSimple(window,'load',init);
function init(){
@xhinking
xhinking / timelien.php
Created July 25, 2012 04:01
PHP timeline function
<?php
function tranTime($time) {
$rtime = date("m-d H:i",$time);
$htime = date("H:i",$time);
$time = time() - $time;
if ($time < 60) {
$str = '刚刚';
}