Skip to content

Instantly share code, notes, and snippets.

View hbin's full-sized avatar

Huang Bin hbin

  • China, Beijing
View GitHub Profile
@hbin
hbin / nsmb.conf
Created May 5, 2023 16:12 — forked from jbfriedrich/nsmb.conf
macOS 11.2 NSMB configuration
# /etc/nsmb.conf - macOS 11.3 - 2021-04-29
#------------------------------------------------------------------------------
# SMB configuration for macOS 11.3 <-> Synology
#------------------------------------------------------------------------------
# Additional information:
# -----------------------
# https://support.apple.com/de-de/HT211927
# https://support.apple.com/en-us/HT208209
# https://apple.stackexchange.com/questions/309016/smb-share-deadlocks-since-high-sierra
# https://photographylife.com/afp-vs-nfs-vs-smb-performance
@hbin
hbin / README.md
Last active August 6, 2024 21:48
Docker OpenWrt no internet access

Problem to Solve:

Host want to use OpenWrt as gateway to pass wall.

  • My router IP: 192.168.31.1
  • My host IP: 192.168.31.2
  • OpenWrt container IP: 192.168.31.3
@hbin
hbin / ASS.md
Created April 11, 2019 07:23 — forked from anonymous/ASS.md
Acronyms Seriously Suck - Elon Musk

From time to time, Musk will send out an e-mail to the entire company to enforce a new policy or let them know about something that's bothering him. One of the more famous e-mails arrived in May 2010 with the subject line: Acronyms Seriously Suck:

There is a creeping tendency to use made up acronyms at SpaceX. Excessive use of made up acronyms is a significant impediment to communication and keeping communication good as we grow is incredibly important. Individually, a few acronyms here and there may not seem so bad, but if a thousand people are making these up, over time the result will be a huge glossary that we have to issue to new employees. No one can actually remember all these acronyms and people don't want to seem dumb in a meeting, so they just sit there in ignorance. This is particularly tough on new employees.

That needs to stop immediately or I will take drastic action - I have given enough warning over the years. Unless an acronym is approved by me, it should not enter the SpaceX glossary.

@hbin
hbin / _service.md
Created October 26, 2017 02:34 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@hbin
hbin / backoff.rb
Last active October 19, 2017 05:46
Randomness to the exponential backoff of max_retries
# Original uncapped, exponential backoff
EXPONENTIAL_BACKOFF = lambda { |c| Kernel.sleep(2 ** c.retries * c.config.retry_base_delay) }
# Exponential backoff capped to :max_delay
CAPPED_BACKOFF = lambda { |c| Kernel.sleep([c.config.retry_max_delay, (2 ** c.retries * c.config.retry_base_delay)].min) }
# Retain at least half of the capped backoff, + random the other half.
EQUAL_JITTER_BACKOFF = lambda { |c| delay = ([c.config.retry_max_delay, (2 ** c.retries * c.config.retry_base_delay)].min)/2.0 ; Kernel.sleep((delay + Kernel.rand(0..delay))) }
# Full Jitter, random between no delay and the capped exponential backoff
@hbin
hbin / docker-pry-rails.md
Created March 10, 2017 18:07 — forked from briankung/docker-pry-rails.md
Using pry-rails with Docker
Redis Memcached
Data types Complex Key-Value
Memory Allocation malloc Slab allocation
Multi-threaded No Yes
Cluster mode Yes No
High Availability(Replication) Yes No
Persitence Yes No
Backup/Restore capability Yes No
Pipeline Yes Yes
@hbin
hbin / bijective.rb
Created November 21, 2016 06:40 — forked from zumbojo/bijective.rb
Simple bijective function (base(n) encode/decode)
# Simple bijective function
# Basically encodes any integer into a base(n) string,
# where n is ALPHABET.length.
# Based on pseudocode from http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener/742047#742047
ALPHABET =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split(//)
# make your own alphabet using:
# (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle.join
@hbin
hbin / emotions.json
Created August 25, 2016 16:48
新浪默认表情 JSON 文件
[
{"phrase":"[微笑]","type":"face","url":"http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/5c/huanglianwx_org.gif","hot":false,"common":true,"category":"","icon":"http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/5c/huanglianwx_thumb.gif","value":"[微笑]","picid":""},
{"phrase":"[嘻嘻]","type":"face","url":"http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/0b/tootha_org.gif","hot":false,"common":true,"category":"","icon":"http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/0b/tootha_thumb.gif","value":"[嘻嘻]","picid":""},
{"phrase":"[哈哈]","type":"face","url":"http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/6a/laugh.gif","hot":false,"common":true,"category":"","icon":"http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/6a/laugh.gif","value":"[哈哈]","picid":""},
{"phrase":"[可爱]","type":"face","url":"http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/14/tza_org.gif","hot":false,"common":true,"category":"","icon":"http://img.t.sinajs.cn/t4/appstyle/expression/ext/nor
@hbin
hbin / ngrok-selfhosting-setup.md
Created August 11, 2016 14:49 — forked from lyoshenka/ngrok-selfhosting-setup.md
How to setup Ngrok with a self-signed SSL cert

Intro

The plan is to create a pair of executables (ngrok and ngrokd) that are connected with a self-signed SSL cert. Since the client and server executables are paired, you won't be able to use any other ngrok to connect to this ngrokd, and vice versa.

DNS

Add two DNS records: one for the base domain and one for the wildcard domain. For example, if your base domain is domain.com, you'll need a record for that and for *.domain.com.

Different Operating Systems