Skip to content

Instantly share code, notes, and snippets.

View houtianze's full-sized avatar
🎯
Focusing

Hou Tianze houtianze

🎯
Focusing
View GitHub Profile
I just finally had my mind snap into place with understanding of the Y Combinator.
Most explanations I read, even the ones using JS, didn't make much sense and were
overly long so here follows my own, much simpler explanation. I will be using JS.
We have fibonacci to start with, very simple recursive function.
It's fixed points are 0 and 1, fib(0) = 0, and fib(1) = 1
That's all a fix point means, when the f(x) == x
They are important because they are the only values at which recursion can cease.
// Source: http://wiki.ecmascript.org/doku.php?id=strawman:maximally_minimal_classes
class Monster {
// A method named "constructor" defines the class’s constructor function.
constructor(name, health) {
// public name object
this.name = name;
// private name object
this[pHealth] = health;
}
@houtianze
houtianze / fork.18m.wsvt.user.js
Last active August 7, 2017 06:15
GreaseMonkey IBM WSVT Forking Script
// ==UserScript==
// @name Fork 18m WSVT
// @namespace 18m
// @description Just fork it
// @updateURL https://gist.github.com/houtianze/ee2cf2f4d022911566a09e77bcfc9233/raw
// @version 0.1.1
// @grant none
// @include http*://*.ibm.com/WSVTASEAN/*IsamDetails.action
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js
// ==/UserScript==
@houtianze
houtianze / getch_getche.py
Last active January 7, 2018 12:06
getch() / getche() for Python
# https://stackoverflow.com/a/48136131/404271
if sys.platform == 'win32':
import msvcrt
getch = msvcrt.getch
getche = msvcrt.getche
else:
import sys
import termios
def __gen_ch_getter(echo):
@houtianze
houtianze / shrink.docker.qcow2.md
Created March 4, 2018 07:38
Shrink docker.qcow2 (which can get verylarge) on macOS

docker/for-mac#371 (comment)

If you can remove all images/containers then:

Stop Docker.

docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
docker volume rm $(docker volume ls |awk '{print $2}')
rm -rf ~/Library/Containers/com.docker.docker/Data/*
@houtianze
houtianze / powermode.user.js
Last active August 1, 2018 22:49
Power Mode TamperMonkey Script
// ==UserScript==
// @name Power Mode!
// @namespace http://houtianze.github.io/
// @updateURL https://gist.githubusercontent.com/houtianze/f6b0eb1c5825d1c214d61a3bf286922d/raw
// @version 0.1.1
// @description Turn on Power Mode!
// @author ibic
// @match *://*/*
// @exclude *://developer.chrome.com/*
// @grant none
@houtianze
houtianze / homebridge
Last active April 23, 2019 13:59 — forked from johannrichard/homebridge
Systemd Service for homebridge (http://github.com/nfarina/homebridge)
# Defaults / Configuration options for homebridge
# The following settings tells homebridge where to find the config.json file and where to persist the data (i.e. pairing and others)
HOMEBRIDGE_OPTS=-U /var/lib/homebridge
# If you uncomment the following line, homebridge will log more
# You can display this via systemd's journalctl: journalctl -f -u homebridge
# DEBUG=*
{
"basics": {
"name": "Hou Tianze",
"label": "Full Stack Developer",
"picture": "https://houtianze.github.io/image/HouTianze_400x400.jpg",
"email": "houtianze@yahoo.com",
"website": "https://houtianze.github.io",
"summary": "I enjoy creating things, solving problems and learning new skills. Software development makes those achievable at one's fingertips, that's why I like it.",
"location": {
"city": "Singapore",
@houtianze
houtianze / build.xclip.on.centos.sh
Last active April 16, 2020 07:32
Build xclip on CentOS
#!/bin/sh
set -e
# ================================================================
# << Update >>
# Running the following is enough, no need to build yourself
# sudo yum install epel-release.noarch
# sudo yum install xclip
# ================================================================
@houtianze
houtianze / build.xsel.on.centos.sh
Last active August 29, 2020 22:18
Build xsel on CentOS
#!/bin/sh
set -e
# ================================================================
# << Update >>
# Running the following is enough, no need to build yourself
# sudo yum install epel-release.noarch
# sudo yum install xsel
# ================================================================