Skip to content

Instantly share code, notes, and snippets.

View suhaotian's full-sized avatar
🎯
Focusing

su suhaotian

🎯
Focusing
View GitHub Profile
import React, { Component, PropTypes } from 'react'
export default class Field extends Component {
constructor(props, context) {
super(props, context)
const {
name, type, value, checked
} = props
const unit = {
// @todo
}
function SmartNumber(n) {
if (typeof n === 'number') {
if (n<1e3) {
return n
} else if(n<1e4) {
return [n/1e3, '千']
} else if(n<1e6) {
const markdownIt = require('markdown-it')
const frontMatter = require('front-matter')
const Prism = require('prismjs')
const aliases = {
'js': 'jsx',
'html': 'markup'
}
const highlight = (str, lang) => {
@suhaotian
suhaotian / createAsyncPage.jsx
Created April 11, 2016 06:47 — forked from gaearon/createAsyncPage.jsx
Webpack's async code splitting with React Router
'use strict';
var React = require('react');
function createAsyncHandler(getHandlerAsync, displayName) {
var Handler = null;
return React.createClass({
displayName: displayName,
(function(d) {
d.addEventListener('touchstart', handler)
d.addEventListener('touchmove', handler)
function handler(e) {
e.preventDefault()
}
})(document.body)
@suhaotian
suhaotian / 3g.163.com.js
Last active September 5, 2015 17:39
移动端网页布局探索(1)
(function (doc, win) {
var docEl = doc.documentElement,
isIOS = navigator.userAgent.match(/iphone|ipod|ipad/gi),
dpr = isIOS? Math.min(win.devicePixelRatio, 3) : 1,
dpr = window.top === window.self? dpr : 1, //被iframe引用时,禁止缩放
dpr = 1, // 首页引用IFRAME,强制为1
scale = 1 / dpr,
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize';
docEl.dataset.dpr = win.devicePixelRatio;
var result = [];
var phoneTypes = [];
var filters = ['微博', 'Android'];
var baseUrl = 'http://m.weibo.cn/single/rcList?format=cards&id=3877877018124939&type=comment&hot=1&page=';
var userUrl = 'http://weibo.com/u/'
var React = require('react');
var EventListener = require('react/lib/EventListener');
var partition = require('linear-partitioning');
var TileLayout = React.createClass({
getDefaultProps: function() {
return {
gutter: 0,
photos: []
}
<style id="jsbin-css">
.tabs {
position: relative;
width: 25em;
list-style: none;
padding: 0;
}
.tabs li {
float: left;
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
snipfile=sys.argv[1]
content=''
for line in open(snipfile).readlines():
if line[0] != '#' and line[0:7] != 'snippet':
line='\t'+line
content=content+line