Skip to content

Instantly share code, notes, and snippets.

@b1ghawk
b1ghawk / globalSearch.js
Created December 19, 2023 07:06 — forked from svrnm/globalSearch.js
Global Search on the window object
function globalSearch(value, max = 100000) {
var stack = (function () {
iframe = document.createElement('iframe');
document.body.appendChild(iframe);
var results = Object.getOwnPropertyNames(window).filter(p => !iframe.contentWindow.hasOwnProperty(p)).map(p => {return {type: typeof window[p], name: p, value: window[p]}}).reduce((c,p) => {
c.push([p.value, 'window.' + p.name]);
return c;
}, []);
document.body.removeChild(iframe);
@b1ghawk
b1ghawk / macOS-input-method-killer.sh
Created August 23, 2023 02:32 — forked from qzydustin/macOS-input-method-killer.sh
Resolving macOS Chinese Input Lag Issue
#!/bin/sh
# This script aims to address the problem of input lag that can occur when using the Chinese input method on macOS.
# It provides a simple and effective solution by terminating the SCIM process, which is often the cause of the lag.
# To use the script, follow these steps:
# 1. Open the Terminal application (located in "Applications/Utilities/Terminal").
# 2. Copy and paste the script into the Terminal window.
# 3. Press Enter to execute the script.
@b1ghawk
b1ghawk / v2ray-unblock-netflix.md
Created April 12, 2023 09:27 — forked from phlinhng/v2ray-unblock-netflix.md
利用 v2ray-core / xray-core 的任意門協議解鎖流媒體

V2Ray 白話文教學介紹了如何利用 V2Ray 的路由功能將特定網站(例如 Netflix)的流量經過 Shadowsocks 轉到另一台機器上,達成解鎖流媒體的方法。 事實上,可以利用 V2Ray 的任意門協議直接將流量轉發到落地機上,進一步減少使用代理協議產生的開銷,以下為做法。

假設不能看奈飛的機器為 VPS A,可以看奈飛的機器為 VPS B。

基本配置

  • VPS A: 開兩個 freedom outbound,一個給 80 端口,一個給 443 端口,並配置對應的路由規則
  • VPS B: 開兩個 dokodemo-door inbound,一個給 80 端口,一個給 443 端口,兩個 inbound 都要設置 sniffing,並配置對應的路由規則

VPS A 設置

{
  "outbounds": [

为什么关心 AS

因特网上的一个 IP 必定属于某个 AS,也就是一个自治系统。一般一个 AS 里的 IP 具有共性,比如网络质量较高或者较差,欺诈风险较高或者较低。 在使用 mtr 或者 traceroute 查看路由时,通过确认中间路由节点 IP 的 AS,可以确认路由质量。 举例说明,对于常见的 CN2 线路,通过 mtr 看到有经过 59.43.138.70,使用 whois 命令查看 IP 信息如下

~$ whois 59.43.138.70
route:          59.43.0.0/16
descr:          Chinatelecom Next Carrying Network backbone
origin:         AS4809
mnt-by: MAINT-CHINANET
@b1ghawk
b1ghawk / MonadExs.hs
Created December 14, 2022 07:39 — forked from ygrenzinger/MonadExs.hs
Functor -> Applicative -> Monad typeclasses
-- Two datatypes
data Optional a = Some a | Empty deriving (Eq, Show)
data Or a b = A a | B b deriving (Eq, Show)
-- functor instances
instance Functor Optional where
fmap f (Some a) = Some (f a)
fmap _ Empty = Empty
instance Functor (Or a) where
@b1ghawk
b1ghawk / README.md
Created December 3, 2021 08:49 — forked from maboloshi/README.md
[Mac下配置Aria2] #macOS #aria2

Mac下配置Aria2

安装和设置 Aria2

# 使用 Homebrew 安装 aria2
brew install aria2

# 创建配置文件aria2.conf和空对话文件aria2.session
mkdir ~/.aria2 && cd ~/.aria2
touch aria2.conf
@b1ghawk
b1ghawk / readme.md
Created September 24, 2020 09:19 — forked from troyfontaine/readme.md
Resize root partition (or how to remove the default /home partition) on CentOS 7 online

Resize root partition (or how to remove the default /home partition) on CentOS 7 online

This requires you to be able to ssh into the instance using the root user account and that no services be running as users out of /home on the target machine.

The examples are from a default installation with no customation-you NEED to know what you're working with for volumes/partitions to not horribly break things.

By default, CentOS 7 uses XFS for the file system and Logical Volume Manager (LVM), creating 3 partitions: /,/home and

Step 1 - Copy /home Contents

To backup the contents of /home, do the following:

@b1ghawk
b1ghawk / ast vs rpn.js
Created August 27, 2020 02:09 — forked from koorchik/ast vs rpn.js
Compare AST and RPN evaluation performance
/*
There is an AST (Abstract syntax tree) in JSON format.
AST represents Excel spreadsheet formula.
Is it possible in JavaScript to make RPN (Reverse Polish Notation) faster than AST?
AST evaluation is recusive and RPN evaluation is iterative.
But in any case, AST evaluation is faster despite recursion.
I guess that the main problem is in using dynamic js arrays to emulate stack.
Would RPN win if it was written in C/C++?
@b1ghawk
b1ghawk / POIUtil.java
Last active August 20, 2020 02:44
Apache POI patch : a more precise autoColumnWidth (with support for auto-wrap text)
import lombok.Data;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.SheetUtil;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.helpers.ColumnHelper;
import java.awt.font.FontRenderContext;
import java.awt.font.TextAttribute;
import java.awt.font.TextLayout;
@b1ghawk
b1ghawk / free-memory.rb
Created July 9, 2020 06:39 — forked from vigo/free-memory.rb
"free" command for osx. Shows available memory
#!/usr/bin/env ruby
# encoding: utf-8
# By Uğur Özyılmazel, @vigobronx | @ugurozyilmazel
# http://vigodome.com | http://ugur.ozyilmazel.com | http://github.com/vigo
def get_paged_memory_usage(match_string, paging=4096)
mvar = 3
if match_string.split(/[^\w]/).length > 1
mvar = 4