Skip to content

Instantly share code, notes, and snippets.

@fiture
fiture / Dockerfile
Last active July 8, 2018 00:14
Development docker file config
FROM node:8-alpine as node
FROM dperson/samba
LABEL maintainer Fiture Wu <fiture.cn@gmail.com>
RUN apk --update add less git openssh vim zsh && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/apk/*
# git config
COPY .gitconfig /root/

--
-- 表的结构 `area`
--
DROP TABLE IF EXISTS `area`;
CREATE TABLE IF NOT EXISTS `area` (
`id` int(11) NOT NULL auto_increment,
`areaID` int(11) NOT NULL,
`area` varchar(20) character set gbk NOT NULL,
@fiture
fiture / react-context.md
Last active August 1, 2016 07:42
react context

React笔记-聊聊 React 中的 Context

React(A JAVASCRIPT LIBRARY FOR BUILDING USER INTERFACES) React本质上就是一个UI框架,核心就是View,通过View内部的state的变化,去改变当前的视图的展现。

React Context

通常我们是通过组件的props属性去实现,父组件到子组件的一个参数传递, 如果遇到很多层级比较深的嵌套的组件传递参数时,如果还通过props的层层传递的话,那这就是一个噩梦,react context 就可以很好的解决这个问题,比如我们常用的React router 就采用了该特性。

@fiture
fiture / paramsToObject.js
Last active June 20, 2016 08:03
url 参数 转换为对象
/**
* 将url查询参数解析为字典。
* @param {any} param 应为window.location对象或者url字符串,否则报错。
*/
function query2Dict(param) {
var pattern = /([^?&=]+)=([^&#]*)/g;
var dict = {};
var search = null;
if (typeof param === "object" && param instanceof Location) {
search = param.search;
@fiture
fiture / jade
Created May 26, 2016 03:02
html-webpack-inline
doctype html
html
head
meta(http-equiv="Content-type" content="text/html; charset=utf-8")
title #{htmlWebpackPlugin.options.title}
body
each cssFile in htmlWebpackPlugin.files.css
style !{compilation.assets[cssFile.substr(htmlWebpackPlugin.files.publicPath.length)].source()}
each jsFile in htmlWebpackPlugin.files.js
script(type="text/javascript") !{compilation.assets[jsFile.substr(htmlWebpackPlugin.files.publicPath.length)].source()}
@fiture
fiture / fuck-xiaomi.js
Last active August 29, 2015 14:04
刷小米金蛋
;(function() {
var j = 1,
interval = 3000,
$pre = $('<pre/>'),
//从小米官网JS取出来
userInfo = {
platform: miniLogin.userInfo.platform,
uid: miniLogin.userInfo.uid,
nickname: miniLogin.userInfo.nickname,
avatar: miniLogin.userInfo.avatar,
@fiture
fiture / toUnicode.js
Last active August 29, 2015 14:03
JS将字符串转换为Unicode编码
function toUnicode(str) {
var temp,
i = 0,
r = '',
len = str.length;
for (; i < len; i++) {
temp = str.charCodeAt(i).toString(16);
while ( temp.length < 4 )
@fiture
fiture / speedTest.js
Created May 18, 2014 03:28
一个测速的JS
var isMobile = !!navigator.userAgent.match(/AppleWebKit.*Mobile.*/);// || !!navigator.userAgent.match(/AppleWebKit/);
function log(s) {
try {
window.console && console.log(s);
} catch (ignore) { }
}
@fiture
fiture / jquery.placeholder.js
Created October 27, 2013 14:39
placeholder
//Has placeholder
$.fn.hasPlaceholder = function () {
$.support.placeholder || this.each(function () {
var b = $(this),
f = b.attr("placeholder");
b.focus(function () {
b.val() == f && b.val("");
b.removeClass("has-placeholder")
}).blur(function () {
b.val() == "" && b.val(f).addClass("has-placeholder")