Skip to content

Instantly share code, notes, and snippets.

View singularitti's full-sized avatar
:octocat:
WFH

Qi Zhang singularitti

:octocat:
WFH
View GitHub Profile
@singularitti
singularitti / extensions.json
Last active May 9, 2024 07:33
VSCode Settings
[
{
"identifier": {
"id": "vscode.bat"
},
"pinned": false,
"preRelease": false,
"version": "1.0.0"
},
{
@singularitti
singularitti / startup.jl
Last active May 7, 2024 20:15
Julia startup config #Julia #startup #config
#=-------------------------------------------------------------------------------------+
| _____ __ __ _ __ |
| / ___// /_____ ______/ /___ ______ (_) / |
| \__ \/ __/ __ `/ ___/ __/ / / / __ \ / / / |
| ___/ / /_/ /_/ / / / /_/ /_/ / /_/ / / / / |
| /____/\__/\__,_/_/ \__/\__,_/ .___(_)_/ /_/ |
| /_/ /___/ |
+-------------------------------------------------------------------------------------=#
#=======================================================================================
@singularitti
singularitti / pagecolor.tex
Last active April 30, 2024 09:32
LaTeX PDF document with custom Tan background #LaTeX #PDF
\usepackage{xcolor}
\definecolor{tancolor}{RGB}{251, 240, 217}
\pagecolor{tancolor} % Set the background to Tan
@singularitti
singularitti / Remedy.json
Last active April 25, 2024 06:20
Remedy iTerm profile
{
"Ambiguous Double Width": false,
"Ansi 0 Color": {
"Alpha Component": 1,
"Blue Component": 0.27058824896812439,
"Color Space": "sRGB",
"Green Component": 0.24705882370471954,
"Red Component": 0.23529411852359772
},
"Ansi 1 Color": {
@singularitti
singularitti / .brew.jl
Last active April 22, 2024 04:53
Homebrew snippets
using IOCapture
export livecheck, bump_cask_pr
function livecheck(cask)
try
c = IOCapture.capture() do
run(`brew livecheck --cask $cask`)
end
str = c.output
@singularitti
singularitti / cn_en.py
Created March 15, 2024 20:19
If I want to match spaces between Chinese characters and English characters (in either order), as well as spaces between Chinese characters themselves, what regex should I use? #regex
import re
def remove_spaces(text):
pattern = re.compile(r'(?<=\p{Script=Han})\s+(?=\p{Script=Han}|\p{Script=Latin})|(?<=\p{Script=Latin})\s+(?=\p{Script=Han})')
return pattern.sub('', text)
@singularitti
singularitti / nyc.md
Last active March 12, 2024 07:13
NYC 景点

NYC

以下排名不分先后。

博物馆

  1. 自然历史博物馆,不用多说,《博物馆奇妙夜》的拍摄地点
  2. 大都会博物馆,不用多说
  3. 下东城廉租公寓博物馆,个人很喜欢的小众博物馆,博物馆的两座历史悠久的廉租公寓建筑在1863年至2011年期间,曾有来自20多个国家的约15000人居住。该建筑可以作为一种时间胶囊,反映19世纪和20世纪初的生活条件以及什么是可接受的住房不断变化的概念。
  4. https://www.metmuseum.org/visit/plan-your-visit/met-cloisters 修道院博物馆是大都会美术馆的分馆,开始修建于1930年代,其外观模仿中世纪欧洲的大修道院,因此得名。
@singularitti
singularitti / check.jl
Created February 4, 2024 01:35
Checking for digits in an integer in Julia #Julia #numbers #algorithm
# See https://youtu.be/ZYzlhp-W0a8
function digitsin(digits::Integer, number)
# Decimal representation of `digits` has N digits
base = 10
while (digits ÷ base > 0)
# `digits ÷ base` is same as `floor(Int, digits/base)`
base *= 10
end
# `base` is now the first integer power of 10 above `digits`, used to pick last N digits from `number`
while number > 0
@singularitti
singularitti / plotGrid.wl
Last active January 26, 2024 19:28
Grid plotting #Mathematica #plotting
Options[plotGrid] = {ImagePadding -> 40};
plotGrid[l_List, w_, h_, opts : OptionsPattern[]] :=
Module[{nx, ny, sidePadding = OptionValue[plotGrid, ImagePadding],
topPadding = 0, widths, heights, dimensions, positions, frameOptions
= FilterRules[{opts}, FilterRules[Options[Graphics], Except[{ImagePadding,
Frame, FrameTicks}]]]},
{ny, nx} = Dimensions[l];
widths = (w - 2 sidePadding) / nx Table[1, {nx}];
widths[[1]] = widths[[1]] + sidePadding;
@singularitti
singularitti / merge.sh
Created January 12, 2024 01:48
Merge Git repos #Git
set -eux
rm -rf rubygems bundler
git clone https://github.com/rubygems/rubygems
git clone https://github.com/rubygems/bundler
(cd bundler
time git filter-repo --to-subdirectory-filter bundler # --tag-rename :bundler-
)
(cd rubygems
git co f553da065 # switch to the commit before the merge
git remote add bundler ../bundler