Skip to content

Instantly share code, notes, and snippets.

@zdway10
zdway10 / gist:0fab4181e65048674c4cc3975b5560fe
Created March 17, 2020 22:57 — forked from xiaolai/gist:3783233
disable dashboard of os x
defaults write com.apple.dashboard mcx-disabled -boolean YES
kill all dock
@zdway10
zdway10 / nvmrc
Created March 17, 2020 22:56 — forked from xiaolai/nvmrc
bash function for load .nvmrc automatically
# for nvm
export NVM_DIR="$HOME/.nvm"
. "$(brew --prefix nvm)/nvm.sh"
load-nvmrc() {
if [[ -f .nvmrc && -r .nvmrc ]]; then
nvm use
elif [[ $(nvm version) != $(nvm version default) ]]; then
echo "Reverting to nvm default version"
nvm use default
@zdway10
zdway10 / markdown-here-css.css
Created March 17, 2020 22:55 — forked from xiaolai/markdown-here-css.css
chrome extension css
.markdown-here-wrapper {
font-family: STheiti, 'Open Sans';
padding: 1em;
}
hr {
border: 3px dotted #009688;
}
em, i, a {
@zdway10
zdway10 / markdownhere.css
Created March 17, 2020 22:55 — forked from xiaolai/markdownhere.css
markdown-here-css
.markdown-here-wrapper {
font-size: 16px;
line-height: 1.8em;
letter-spacing: 0.1em;
}
pre, code {
font-size: 14px;
font-family: Roboto, 'Courier New', Consolas, Inconsolata, Courier, monospace;
@zdway10
zdway10 / gist:bd4a1c844bcdcdfd98d9cd2ecbafe062
Created March 17, 2020 22:55 — forked from xiaolai/gist:447d8961954dfd28047a797e4f82addd
SublimeText: Tab to move cursor out of parentheses, quotes, brackets
// Original by C0D312
// I added the single quote and curly brace to the regex.
// http://www.sublimetext.com/forum/viewtopic.php?f=3&t=5174
//
// Add the following to your user keybindings:
[
{ "keys": ["tab"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "following_text", "operator": "regex_contains", "operand": "^[)}'\"\\]]", "match_all": true },
{
"cmd": ["make", "clean"],
"cmd": ["make", "html"],
"working_dir": "${project_path:${folder}}",
"selector": "text.restructuredtext"
}
@zdway10
zdway10 / futures_pi.py
Created March 17, 2020 22:54 — forked from xiaolai/futures_pi.py
Calculating PI with Python
import functools
import random
import math
from concurrent import futures
def map_d(c):
return math.hypot(random.random(), random.random())
@zdway10
zdway10 / pi_generator.py
Created March 17, 2020 22:54 — forked from xiaolai/pi_generator.py
calculate pi using python generator.
#!/usr/bin/env python
def pi():
# Wallis' product
numerator = 2.0
denominator = 1.0
while True:
yield numerator/denominator
if numerator < denominator:
numerator += 2
@zdway10
zdway10 / pi_mp.py
Created March 17, 2020 22:53 — forked from xiaolai/pi_mp.py
Parallel Pi Calculation using Python's multiprocessing module
''' listing 6: pi_mp.py
Multiprocessing based code to estimate the value of PI
using monte carlo sampling
Ref: http://math.fullerton.edu/mathews/n2003/montecarlopimod.html
Uses workers:
http://docs.python.org/library/multiprocessing.html#module-multiprocessing.pool
'''
import random
@zdway10
zdway10 / brew.md
Created March 17, 2020 22:52 — forked from xiaolai/brew.md
homebrew upstream repo for China
# 替换brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

# 替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git

# 替换homebrew-bottles: