Skip to content

Instantly share code, notes, and snippets.

View leohxj's full-sized avatar
💯
Focusing

Leo Hui leohxj

💯
Focusing
View GitHub Profile
@leohxj
leohxj / rdr.bash
Created June 22, 2018 02:15
转换 8080 -> 80 端口 #bash
echo "
rdr pass inet proto tcp from any to any port {80,8080} -> 127.0.0.1 port 8080
" | sudo pfctl -ef -
@leohxj
leohxj / interface.ts
Created March 29, 2018 14:35
typescript duck typing
interface IItem
{
id: number,
title: string
};
function print(item: IItem)
{
console.log(item.id + " > " + item.title);
}
var i : IItem = {
@leohxj
leohxj / settings.json
Created March 28, 2018 14:57
vscode flow workspace settings
{
"flow.useNPMPackagedFlow": true,
"javascript.validate.enable": false
}
@leohxj
leohxj / .eslintrc.js
Created February 10, 2018 09:27
with airbnb, prettier
module.exports = {
parser: "babel-eslint",
extends: [
"airbnb-base",
"airbnb-base/rules/strict",
"airbnb/rules/react",
"prettier",
"prettier/react"
],
plugins: ["react", "prettier", "import"],
@leohxj
leohxj / events.js
Created January 31, 2018 03:18
Events
class MyEvents {
constructor () {
this.events = {} //存储事件监听函数
this.maxListeners = 10 //一种函数类型,最大监听函数数量
}
setMaxListeners (maxNum) {
this.maxListeners = maxNum
}
@leohxj
leohxj / capitalizeFirstLetter.js
Created January 29, 2018 07:42
Make the first letter of a string uppercase in JavaScript
const capitalizeFirstLetter = s => {
const type = typeof s;
if (type !== 'string') {
throw new Error(`Expected string, instead received ${type}`);
}
const [firstChar, ...remainingChars] = s;
return [firstChar.toUpperCase(), ...remainingChars].join('');
};
@leohxj
leohxj / .gitignore
Created January 7, 2018 07:20
frontend best gitignore
# General
.DS_Store
.AppleDouble
.LSOverride
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
@leohxj
leohxj / default.yaml
Last active November 18, 2017 16:20
RIME-config
# Rime default settings
# encoding: utf-8
config_version: "0.36"
schema_list:
- schema: luna_pinyin
- schema: cangjie5
- schema: luna_pinyin_fluency
- schema: luna_pinyin_simp
{
"config": {
"commitizen": {
"path": "node_modules/cz-emoji"
},
"cz-emoji": {
"types": [
{
"emoji": "🔩",
"code": "chore :nut_and_bolt:",
@leohxj
leohxj / iterm2-profiles.json
Created August 16, 2017 15:44
iterm2-profiles.json
{
"Working Directory" : "\/Users\/leohxj",
"Prompt Before Closing 2" : 0,
"Selected Text Color" : {
"Green Component" : 0,
"Blue Component" : 0,
"Red Component" : 0
},
"Rows" : 30,
"Ansi 11 Color" : {