Skip to content

Instantly share code, notes, and snippets.

View xiaolai's full-sized avatar
🎯
Focusing

xiaolai xiaolai

🎯
Focusing
View GitHub Profile
@xiaolai
xiaolai / brew.md
Created March 16, 2020 17:23
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:
@xiaolai
xiaolai / Personal Library.md
Last active June 6, 2022 14:01
My own library
  1. Download and pin books at https://read.amazon.com, and use epubor KCR converter to convert them into epubs.
  2. Download audio books at https://audible.com, with aax format.
  3. Obtain your activation bytes with the instruction of this post.
  4. Install ffmpeg with brew.
  5. Install audible-converter with npm. (File name will be extended automatically)
audible-converter "*.aax" -a <your-activation-bytes>
  1. Install atomicparsley with brew. (to add artwork to converted m4a files) Bash script to add artworks to m4a files:
@xiaolai
xiaolai / gist:2ffe003b05eb3a2f7ba933858d353d7d
Created February 6, 2020 12:00
search and replace all mal-rendered emphasized text in github markdown
search regex:
~*(?:^|[^~])(~~(\\w+(\\s\\w+)*)~~)
# replace with (attention: there's a white space at the end)
**$1**
@xiaolai
xiaolai / Style.css
Created April 13, 2019 07:56
vscode markdown github preview custom style
.vscode-body .markdown-body {
font-family: "PingFang SC"
}
.vscode-body strong {color:#6392BF;}
.vscode-body em {color: #A9312A; font-style: normal !important;}
.vscode-body table {font-size: 95% !important;}
.vscode-body .CodeMirror, .vscode-body pre {font-size: 90%;}
.vscode-body pre {
@xiaolai
xiaolai / jupyter-as-a-desktop-app.md
Last active September 15, 2023 08:37
Run Jupterlab as an desktop app

How to run Jupyterlab as a desktop app on Mac OSX

In Sep, 2021, Jupyterlab Desktop App (electron) was released by Mehmet Bektas (github repo).

brew install --cask jupyterlab

jupyterlab-app-first-opened

@xiaolai
xiaolai / gist:cef9c92caa9c252fe6aaa3f43cecb102
Created February 2, 2019 04:04
Run Jupterlab as an desktop app
# install anaconda
jupyter-lab --generate-config
edit ~/.jupyter/jupyter_notebook_config.py, add lines:
c.NotebookApp.token = '' #you can set password here.
#https://github.com/jiahaog/nativefier
npm install nativefier -g
nativefier "http://localhost:8888"
@xiaolai
xiaolai / letters-to-100.py
Created October 21, 2017 06:22 — forked from peterjmag/letters-to-100.py
Find English words whose letter values add up to 100
#!/usr/bin/env python
# encoding: utf-8
"""
letters-to-100.py
"""
import string
letter_values = dict((l, i) for i, l in enumerate(string.lowercase, start=1))
english_dict = open('/usr/share/dict/words', 'rU')
@xiaolai
xiaolai / mc-pi.rb
Created October 19, 2017 01:48 — forked from shitsyndrome/mc-pi.rb
compute pi by Monte-Carlo method.
=begin
Find pi by the Monte-Carlo method.
area of a circle = pi r^2
area of a square = (2r)^2 = 4 r^2
Perform random uniform sampling between -1 and 1.
The proportion of points in the unit circle is:
p = (pi r^2) / (4r^2)
@xiaolai
xiaolai / mpipypi.py
Created October 19, 2017 01:48 — forked from jcchurch/mpipypi.py
Compute Pi using Python and MPI4PY
"""
This code computes pi. It's not the first python
pi computation tool that I've written. This program
is a good test of the mpi4py library, which is
essentially a python wrapper to the C MPI library.
To execute this code:
mpiexec -np NUMBER_OF_PROCESSES -f NODES_FILE python mpipypi.py
@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