Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Can't Wait, Keep Refresh

Kiho · Cham monkindey

💭
Can't Wait, Keep Refresh
View GitHub Profile
@monkindey
monkindey / index.js
Last active Apr 11, 2018
Service worker get config from outside
View index.js
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) {
View issue3926.js
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 = {
View alert.md
category type title
Components
Feedback
Alert

Alert component for feedback.

When To Use

View Slider.js
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 Sep 18, 2017
redux saga example
View saga.js
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 Sep 1, 2017
webpack tapable with log
View Readme.md

How

Why

It will be clear to understand the flow of webpack.

@monkindey
monkindey / Readme.md
Last active Aug 19, 2017
html resolve js file
View Readme.md

How HTML resolve JavaScript file

The folder like it

|____public
| |____index.html
| |____index.js
|____server.js
View Readme.md

CSRF

Configuration

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

Running

  • node ./injured.js
View 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
@monkindey
monkindey / getter.js
Created Aug 16, 2017
getter just like vue computed property
View getter.js
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
class Getter extends Component {
firstAndLastName() {
return `${this.props.firstName} ${this.props.lastName}`;
}
get fullName() {
return `${this.props.firstName} ${this.props.lastName}`;
You can’t perform that action at this time.