Skip to content

Instantly share code, notes, and snippets.

@tiancheng91
tiancheng91 / linux_tips.md
Created February 2, 2023 10:06 — forked from folliehiyuki/linux_tips.md
Notes for my Linux installation

Configurations

Kernel modules

# /etc/modprobe.d/blacklist.conf
blacklist radeon # nvidia, i915, depends on hardware specs
blacklist iTCO_wdt # who wants watchdog on desktop tbh? (except shutdown might not work properly xD)
blacklist iTCO_vendor_support # watchdog
@tiancheng91
tiancheng91 / README.md
Created November 30, 2021 12:06 — forked from ascendbruce/README.md
Use mac style keyboard shortcuts on Windows with AutoHotkey (ahk) script

Use (most) macOS style keyboard shortcuts on Windows

Make Windows PC's shortcut act like macOS (Mac OS X)

With this AutoHotKey script, you can use most macOS style shortcuts (eg, cmd+c, cmd+v, ...) on Windows with a standard PC keyboard.

Note that:

  1. you shouldn't change the modifier keys mapping with keyboard DIP. This script assumes you use a standard PC keyboard layout, and wish to use shortcuts as if it was a mac keyboard layout.
  2. To use cmd + shift + ↑ / ↓ / ← / → (select text between cursor and top / bottom / beginning of line / end of line), You should disable the Between input languages shotcut from Control Panel\Clock, Language, and Region\Language\Advanced settings > Change lanugage bar hot keys due to conflicting.
@tiancheng91
tiancheng91 / max_queue_size_pool.py
Created July 11, 2019 10:56 — forked from noxdafox/max_queue_size_pool.py
This code snippet shows how to wrap a concurrent.futures.Executor class to provide a limited queue size.
from threading import BoundedSemaphore
from concurrent.futures import ProcessPoolExecutor
class MaxQueuePool:
"""This Class wraps a concurrent.futures.Executor
limiting the size of its task queue.
If `max_queue_size` tasks are submitted, the next call to submit will block
until a previously submitted one is completed.
@tiancheng91
tiancheng91 / add_wsl_exclusions.ps1
Created May 5, 2019 03:04 — forked from ian-p-cooke/add_wsl_exclusions.ps1
powershell script to add WSL exclusions
$win_user = "ipc"
$linux_user = "ipc"
$package = "CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc"
$base_path = "C:\Users\" + $win_user + "\AppData\Local\Packages\" + $package + "\LocalState\rootfs"
$dirs = @("\bin", "\sbin", "\usr\bin", "\usr\sbin", "\home\" + $linux_user + "\.cargo\bin")
$dirs | ForEach { Add-MpPreference -ExclusionProcess ($base_path + $_ + "\*") }
Add-MpPreference -ExclusionPath $base_path
@tiancheng91
tiancheng91 / chai.json
Created January 23, 2019 02:27 — forked from ksco/chai.json
中文左右拆字字库
{"卧":"臣卜","项":"工页","功":"工力","攻":"工攵","荆":"茾刂","邪":"牙阝","雅":"牙隹","期":"其月","欺":"其欠","斯":"其斤","鞭":"革便","勒":"革力","划":"戈刂","敬":"苟攵","鹳":"雚鸟","欧":"区欠","切":"七刀","鞋":"革圭","鄞":"堇阝","勤":"堇力","陌":"阝百","陈":"阝东","隐":"阝急","降":"阝夅","队":"阝人","防":"阝方","院":"阝完","阳":"阝日","际":"阝示","阴":"阝月","除":"阝余","险":"阝佥","隔":"阝鬲","障":"阝章","阶":"阝介","陀":"阝它","阵":"阝车","阿":"阝可","隘":"阝益","陵":"阝夌","陷":"阝臽","陶":"阝匋","陪":"阝咅","陕":"阝夹","陆":"阝击","阻":"阝且","孙":"子小","孔":"子乚","孩":"子亥","孤":"子瓜","职":"耳只","聩":"耳贵","聘":"耳甹","取":"耳又","聊":"耳卯","聪":"耳总","耻":"耳止","联":"耳关","聆":"耳令","耿":"耳火","耽":"耳冘","预":"予页","豫":"予象","双":"又又","对":"又寸","戏":"又戈","欢":"又欠","观":"又见","难":"又隹","鸡":"又鸟","艰":"又艮","驻":"马主","骚":"马蚤","驯":"马川","骆":"马各","骑":"马奇","驱":"马区","驰":"马也","骇":"马亥","驶":"马史","验":"马佥","骏":"马夋","骄":"马乔","驴":"马户","骤":"马聚","驳":"马爻","胡":"古月","故":"古攵","鸪":"古鸟","郁":"有阝","耐":"而寸","肆":"镸聿","雄":"厷隹","励":"厉力","耗":"耒毛","艳":"丰色","耕":"耒井","确":"石角","破":"石皮","础":"石出","碑":"石卑","研":"石开","碎":"石卒","碾":"石展","硕":"石页","磁":"石兹","碟":"石枼","砸":"石匝","碌":"石录","砖":"石专","碗":"石宛","砰":"石平","磕":"石盍","硬":"石
@tiancheng91
tiancheng91 / 1.google-analytics-proxy-nginx.conf
Created January 7, 2019 18:47 — forked from paivaric/1.google-analytics-proxy-nginx.conf
Google Analytics Proxy using Nginx to bypass Adblock and other blockers
server {
listen 80;
server_name your.domain.com;
location = /analytics.js {
# you have to compile nginx with http://nginx.org/en/docs/http/ngx_http_sub_module.html (this is not default)
# and http://nginx.org/en/docs/http/ngx_http_proxy_module.html (it's a default module)
proxy_set_header Accept-Encoding "";
@tiancheng91
tiancheng91 / nginx-tuning.md
Created June 8, 2018 18:04 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@tiancheng91
tiancheng91 / sysctl.conf
Created May 29, 2018 18:16 — forked from voluntas/sysctl.conf
Sysctl configuration for high performance
### KERNEL TUNING ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
@tiancheng91
tiancheng91 / chromium
Created April 16, 2018 13:20 — forked from fujimakishouten/chromium
Chromium
#!/bin/sh
export GOOGLE_API_KEY="AIzaSyCkfPOPZXDKNn8hhgu3JrA62wIgC93d44k"
export GOOGLE_DEFAULT_CLIENT_ID="811574891467.apps.googleusercontent.com"
export GOOGLE_DEFAULT_CLIENT_SECRET="kdloedMFGdGla2P1zacGjAQh"
/usr/bin/chromium
@tiancheng91
tiancheng91 / base62.py
Created August 18, 2017 02:04 — forked from adyliu/base62.py
Base62 encode/decode tools (convert number to string)
#!/usr/bin/env python
#-*- coding:utf-8 -*-
# Base62 tools (convert number <=> string)
# v1.0/20130109
# python 2.x/3.x supported
#
#author: Ady Liu([email protected])
#github: github.com/adyliu
import sys