Skip to content

Instantly share code, notes, and snippets.

View xiaolai's full-sized avatar
🎯
Focusing

xiaolai xiaolai

🎯
Focusing
View GitHub Profile
@xiaolai
xiaolai / iterm2 changing font-size
Created June 3, 2016 13:49
iTerm2 changing font-size between 18-24
cd ~/Library/Preferences/
open com.googlecode.iterm2.plist
// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@xiaolai
xiaolai / nvmrc
Created June 28, 2016 08:42
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
@xiaolai
xiaolai / markdown-here-css.css
Created July 1, 2016 02:13
chrome extension css
.markdown-here-wrapper {
font-family: STheiti, 'Open Sans';
padding: 1em;
}
hr {
border: 3px dotted #009688;
}
em, i, a {
@xiaolai
xiaolai / markdownhere.css
Created July 2, 2016 12:12
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;
@xiaolai
xiaolai / gist:447d8961954dfd28047a797e4f82addd
Created September 22, 2017 16:59 — forked from craiggists/gist:2268146
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 },
@xiaolai
xiaolai / Sphinx.sublime-build
Created October 10, 2017 16:32
Sphinx build
{
"cmd": ["make", "clean"],
"cmd": ["make", "html"],
"working_dir": "${project_path:${folder}}",
"selector": "text.restructuredtext"
}
@xiaolai
xiaolai / futures_pi.py
Created October 19, 2017 01:48 — forked from armonge/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())
@xiaolai
xiaolai / pi_generator.py
Created October 19, 2017 01:48 — forked from ikautak/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
@xiaolai
xiaolai / pi_mp.py
Created October 19, 2017 01:48 — forked from amitsaha/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