Skip to content

Instantly share code, notes, and snippets.

@monkindey
monkindey / C.sublime-build
Created November 18, 2014 04:31
Sulime Text C 环境构建配置文件
/**
* @author others|monkindey
* @date 2014-11-18
* @reference http://sublime-text.readthedocs.org/en/latest/reference/build_systems.html
*/
{
// 命令执行
"cmd": ["gcc", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
@monkindey
monkindey / index.js
Last active April 11, 2018 15:47
Service worker get config from outside
if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register('./sw.js')
.then(function(registration) {
const interval = setInterval(() => {
try {
registration.installing.postMessage({
'api.github.com/users/monkindey': {}
});
} catch (err) {
import React from 'react';
import ReactDOM from 'react-dom';
class Issue3926 extends React.Component {
constructor() {
super();
this.handleChange = this.handleChange.bind(this);
this.handleComposition = this.handleComposition.bind(this);
this.onComposition = false;
this.state = {
@monkindey
monkindey / alert.md
Last active October 14, 2017 09:10
category type title
Components
Feedback
Alert

Alert component for feedback.

When To Use

class Slider extends Component{
renderPlugins(){
let { children } = this.props;
let dataModel = {...this.props,...this.state};
return do{
if(typeof children=='function'){;
children(dataModel)
}else{
children;
}
@monkindey
monkindey / saga.js
Created September 18, 2017 03:16
redux saga example
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { createStore, applyMiddleware } from 'redux';
import { connect, Provider } from 'react-redux';
import createSagaMiddleware, { delay } from 'redux-saga';
import { put, takeEvery, all } from 'redux-saga/effects';
function* incrementAsync() {
yield delay(1000);
yield put({ type: 'INCREMENT' });
@monkindey
monkindey / Readme.md
Last active September 1, 2017 15:19
webpack tapable with log

How

Why

It will be clear to understand the flow of webpack.

@monkindey
monkindey / Readme.md
Last active August 19, 2017 03:21
html resolve js file

How HTML resolve JavaScript file

The folder like it

|____public
| |____index.html
| |____index.js
|____server.js
@monkindey
monkindey / Readme.md
Last active August 17, 2017 14:10
csrf

CSRF

Configuration

在你自己的hosts文件里加上映射, 然后再改下config.js里面的host, 跟你在hosts映射名字统一。

Running

  • node ./injured.js
const http = require('http');
const config = require('./config');
const port = config.port.injured;
const host = config.host;
http
.createServer((req, res) => {
console.log(req.headers.cookie);
res.writeHead(200, {
'Set-Cookie': host