Skip to content

Instantly share code, notes, and snippets.

#
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additonal system variables
# See sysctl.conf (5) for information.
#
#kernel.domainname = example.com
# Uncomment the following to stop low-level messages on console
#kernel.printk = 3 4 1 3
@haishanh
haishanh / arrow.js
Last active February 20, 2016 15:44
understand javascript arrow function and this
/*!
* understand `arrow function` and `this`
* see also https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
*/
var id = 'global';
var o = {
id: 'o',
@haishanh
haishanh / arch-install.md
Created August 2, 2016 05:15
archlinux install

Install archlinux

Set the keybord layout

Connect to the internet

Update the system clock

{
"enable_highlight": true,
"enable_pygments": true,
"guess_language": true,
"css": "path/to/style-for-sublimetext-markdown-preview.css",
"strip_yaml_front_matter": true,
"image_path_conversion": "relative",
"enabled_extensions": ["extra", "github", "toc", "codehilite(guess_lang=True,pygments_style=friendly,linenums=False)","headerid", "meta", "sane_lists", "smarty", "wikilinks", "admonition"],
}
@haishanh
haishanh / cx.js
Created August 15, 2016 06:02
Simple classNames
'use strict';
function cx() {
var classNames = [];
var args = Array.prototype.slice.call(arguments);
args.forEach(function (arg) {
if (Array.isArray(arg)) {
classNames = classNames.concat(arg);
} else if (typeof arg === 'object') {
@haishanh
haishanh / jekyll-and-liquid.md
Created August 1, 2017 14:57 — forked from magicznyleszek/jekyll-and-liquid.md
Jekyll & Liquid Cheatsheet

Jekyll & Liquid Cheatsheet

A list of the most common functionalities in Jekyll (Liquid). You can use Jekyll with GitHub Pages, just make sure you are using the proper version.

Running

Running a local server for testing purposes:

@haishanh
haishanh / class.js
Created February 21, 2018 12:16 — forked from gxcsoccer/class.js
各种类构造和继承性能比较
'use strict';
const Benchmark = require('benchmark');
const benchmarks = require('beautify-benchmark');
const suite = new Benchmark.Suite();
const util = require('util');
const assert = require('assert');
class A {
import React from "react";
import { Link } from "react-router-dom";
export function createResource(getPromise) {
let cache = {};
let inflight = {};
let errors = {};
function load(key) {
inflight[key] = getPromise(key)
@haishanh
haishanh / use-bunyan-logger-factory.js
Last active February 12, 2020 09:55
use bunyan-logger-factory
"use strict";
/**
* on Mac you can use system builtin app Console to view syslog
* but logProto has to be 'sys'
* Note, Console only shows logs with level >= warn by default
*
*
* fatal 60
* error 50
@haishanh
haishanh / configureStore.js
Created March 14, 2020 04:07
redux-with-hooks
import { createStore, applyMiddleware, compose } from 'redux';
import thunkMiddleware from 'redux-thunk';
import rootReducer from '../ducks';
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
function configureStore() {
const store = createStore(
rootReducer,
composeEnhancers(applyMiddleware(thunkMiddleware))