This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"env": { | |
"browser": true, | |
"node": true, | |
"es6": true | |
}, | |
"plugins": ["react"], | |
"ecmaFeatures": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { combineReducers, createStore } from 'redux' | |
var objectAssign = require('object-assign'); | |
// Action | |
const ADD_CART = 'ADD_CART'; | |
const SET_GOODS_COLLECT = 'SET_GOODS_COLLECT'; | |
function addToCart(goods) { | |
return { | |
type: ADD_CART, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Load Zepto as module */ | |
module.exports = { | |
entry: "./app.js", | |
output: { | |
path: __dirname, | |
filename: "bundle.js" | |
}, | |
module: { | |
loaders: [ | |
{ test: /zepto(\.min)?\.js$/, loader: "exports?Zepto; delete window.$; delete window.Zepto;" }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//console.log(window.scrollY) // 文档在垂直方向已滚动的像素值。 | |
//console.log(window.innerHeight) // 浏览器窗口的视口(viewport)高度(以像素为单位) | |
//console.log(document.body.scrollHeight) | |
//console.log(window.scrollY) | |
_.debounce(function() { | |
var props = this.props; | |
if (typeof window !== 'undefined') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $body = $('body'); | |
document.title = ‘title’ | |
// hack在微信等webview中无法修改document.title的情况 | |
var $iframe = $('<iframe src="/favicon.ico"></iframe>').on('load', function() { | |
setTimeout(function() { | |
$iframe.off('load').remove() | |
}, 0) | |
}).appendTo($body) | |
// https://www.zhihu.com/question/26228251 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# _*_ coding: utf-8 _*_ | |
"""类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算""" | |
#-- 寻求帮助: | |
dir(obj) # 简单的列出对象obj所包含的方法名称,返回一个字符串列表 | |
help(obj.func) # 查询obj.func的具体介绍和用法 | |
#-- 测试类型的三种方法,推荐第三种 | |
if type(L) == type([]): print("L is list") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.filter('bytes', function() { | |
return function(bytes, precision) { | |
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-'; | |
if (typeof precision === 'undefined') precision = 1; | |
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'], | |
number = Math.floor(Math.log(bytes) / Math.log(1024)); | |
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number]; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# create self-signed server certificate: | |
read -p "Enter your domain [www.example.com]: " DOMAIN | |
echo "Create server key..." | |
openssl genrsa -des3 -out $DOMAIN.key 1024 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener('scroll', _.throttle(eventHandler, 200), false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// method 1: | |
// using a middleware function to "inject" into the RequestContext a user value that is a | |
// struct containing application-level services (e.g orm/db). | |
package main | |
import "os" | |
import "fmt" | |
import "flag" | |
import "github.com/jinzhu/gorm" | |
import "github.com/kataras/iris" |
OlderNewer