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 / test.py
Created July 12, 2019 08:07
python_numpy
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
from numpy import linalg as LA
class Activation:
def f(self, x, **args):
raise NotImplementedError("Should have implemented this")
@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 / store.js
Created June 15, 2018 17:29
webtorrent
var idb = require('idb-chunk-store')
var WebTorrent = require('webtorrent')
var client = new WebTorrent()
//Sintel MagnetURI taken from https://webtorrent.io/
var sintel = "magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F"
function addTorrent(info){
var torrent = client.add(info, {"store": idb})
@tiancheng91
tiancheng91 / set.sh
Created June 14, 2018 17:45
ipv6 tunnel
modprobe ipv6
ip tunnel add he-ipv6 mode sit remote 216.66.84.42 local 178.172.151.170 ttl 255
ip link set he-ipv6 up
ip addr add 2001:470:b841::1/48 dev he-ipv6
ip route add ::/0 dev he-ipv6
ip -f inet6 addr
for i in {100..200}; do
ip addr add "2001:470:b841:$i::1/48" dev he-ipv6
done
@tiancheng91
tiancheng91 / proxy
Created June 13, 2018 01:07
apache 转发
RewriteEngine On
RewriteRule ^$ http://127.0.0.1:XXXXX/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:XXXXX/$1 [P,L]
- P: 代理
- L: 匹配到结束