Skip to content

Instantly share code, notes, and snippets.

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

Edward xu xuhen

💭
I may be slow to respond.
View GitHub Profile
@xuhen
xuhen / connect.js
Created October 8, 2019 07:27 — forked from nadrane/connect.js
Create your own react-redux connect
import React, { Component } from "react";
import { render } from "react-dom";
import Hello from "./Hello";
import { createStore } from "redux";
const shallowEqual = require("shallow-equal/objects");
const store = createStore((oldState={}, action) => {
return Object.assign(oldState, { storeValue: action.storeValue })
});
@xuhen
xuhen / README.md
Created August 19, 2019 13:46 — forked from joyrexus/README.md
curl tutorial

An introduction to curl using GitHub's API.

Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin

Includes HTTP-Header information in the output

@xuhen
xuhen / mac-setup-redis.md
Created August 16, 2019 09:05 — forked from tomysmile/mac-setup-redis.md
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
@xuhen
xuhen / updateForkedRepo.md
Last active August 9, 2019 03:22 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@xuhen
xuhen / README.md
Created October 12, 2018 11:43 — forked from hofmannsven/README.md
My simply MySQL Command Line Cheatsheet
@xuhen
xuhen / dom-helper.js
Created October 2, 2018 05:41 — forked from SitePointEditors/dom-helper.js
Mini jQuery, sort of.
/**
* A collection of helper prototype for everyday DOM traversal, manipulation,
* and event binding. Sort of a minimalist jQuery, mainly for demonstration
* purposes. MIT @ m3g4p0p
*/
window.$ = (function (undefined) {
/**
* Duration constants
* @type {Object}
@xuhen
xuhen / user.js
Created January 11, 2018 09:44 — forked from EtienneR/user.js
XMLHttpRequest RESTful (GET, POST, PUT, DELETE)
// Get all users
var url = "http://localhost:8080/api/v1/users";
var xhr = new XMLHttpRequest()
xhr.open('GET', url, true)
xhr.onload = function () {
var users = JSON.parse(xhr.responseText);
if (xhr.readyState == 4 && xhr.status == "200") {
console.table(users);
} else {
console.error(users);