Skip to content

Instantly share code, notes, and snippets.

View nuysoft's full-sized avatar
💭
I may be slow to respond.

高云 墨智 nuysoft

💭
I may be slow to respond.
View GitHub Profile
import store from './store'
export function render (container: any) {
if (!container) {
container = document.createElement('div')
container.id = ENGINE_CONTAINER
document.body.appendChild(container)
}
ReactDOM.render(
@nuysoft
nuysoft / gist:e825b358103e6c984ebd
Created April 14, 2015 07:45
函数表达式的上下文变为 window
var hooks = {
foo: function() {
console.log(this)
},
_default: function() {
console.log(this)
}
}
owner.foo() // hooks
@nuysoft
nuysoft / gist:16c4d3f36a38e98b6e4e
Created January 15, 2015 16:49
解析倍增数
function parse(result) {
var cursor = 1,
arr = []
while (cursor <= result) {
if (result & cursor) arr.push(cursor)
cursor *= 2
}
console.log(arr)
}
@nuysoft
nuysoft / 修改前的语法树.json
Last active December 31, 2015 22:49
Hyde.js 的双向绑定绑定过程
{
"type": "program",
"statements": [
{
"type": "mustache",
"strip": {
"left": false,
"right": false
},
"escaped": true,
@nuysoft
nuysoft / expose.js
Last active December 31, 2015 10:39
模块化 Modular
"use strict";
/* global window */
/* global define */
/* global KISSY */
/*
https://gist.github.com/nuysoft/7974409
*/
;
(function() {
$.extend({
unparam: function(param) {
if (param[0] === '?') param = param.slice(1)
var re = {}
for (var i = 0, arr = param.split('&'), kv; kv = arr[i]; i++) {
kv = kv.split('=')
re[kv[0]] = kv[1]
}
@nuysoft
nuysoft / btn.css
Created September 4, 2013 03:05
button from c9.io
.not-ie .btn-big-red{background-color:#C63702;background-image:linear-gradient(167deg, rgba(255,255,255,0.1) 50%, transparent 55%),linear-gradient(top, rgba(255,255,255,0.15), transparent);border-radius:6px;box-shadow:0 0 0 1px #c63702 inset,0 0 0 2px rgba(255,255,255,0.15) inset,0 8px 0 0 #ad3002,0 8px 0 1px rgba(0,0,0,0.4),0 8px 8px 1px rgba(0,0,0,0.5);color:white;display:block;font-family:"Lucida Grande", Arial, sans-serif;font-size:22px;font-weight:bold;height:61px;letter-spacing:-1px;line-height:61px;margin:28px 0 10px;position:relative;text-align:center;text-shadow:0 1px 1px rgba(0,0,0,0.5);text-decoration:none !important;transition:all .2s linear;width:186px}
.not-ie .btn-big-red:hover{background-color:#d13902;box-shadow:0 0 0 1px #c63702 inset,0 0 0 2px rgba(255,255,255,0.15) inset,0 10px 0 0 #ad3002,0 10px 0 1px rgba(0,0,0,0.4),0 10px 8px 1px rgba(0,0,0,0.6);margin-top:26px;margin-bottom:12px}
.not-ie .btn-big-red:active{box-shadow:0 0 0 1px #ad3002 inset,0 0px 0 2px rgba(255,255,255,0.15) inset,0 0
@nuysoft
nuysoft / State.java
Last active December 22, 2015 06:38
package com.nuysoft.util;
public enum State {
// 环境
RUN, // 生产环境
DEBUG, // 测试环境
// 状态
NEW, // 新建
READY, // 初始化
@nuysoft
nuysoft / ux-watch
Created September 3, 2013 07:52
监听开发目录下文件的变化,自动更新文件到部署目录。可以解决发开过程中: 1) Window 下 build、deploy、debug 繁琐的步骤, 2) Mac 下 JBoss 不支持软链接(ln -s)。
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
dev: {
files: ['../dev/zuanshi-site-web/src/main/webapp/**/**'],
tasks: ['copy']
}
},
copy: {
(function(){
try{
return 1
} finally {
return 2
}
})()
// => 2