Skip to content

Instantly share code, notes, and snippets.

View xsbchen's full-sized avatar
🏃‍♂️
running

xsbchen

🏃‍♂️
running
View GitHub Profile
@xsbchen
xsbchen / readme.md
Last active April 4, 2025 04:26
How to build openwrt in macOS

Tested in Macbook Pro M3 Pro with macOS Sonoma(14.4.1)

1. prepare disk

hdiutil create -size 30g -fs 'Case-sensitive HFS+' -type SPARSEBUNDLE -nospotlight -volname OpenWRTBuilder ~/OpenWRTBuilder
hdiutil attach -notremovable -nobrowse -mountpoint ~/OpenWRTBuilder ~/OpenWRTBuilder.sparsebundle

2. install dependencies

@xsbchen
xsbchen / args.gn
Created December 21, 2020 07:51 — forked from paulirish/args.gn
How to build Chromium to hack on DevTools
# Build arguments for the gn build
# You can set these with `gn args out/Default`
# ( and they're stored in src/out/Default/args.gn )
# See "gn args out/Default --list" for available build arguments
# component build, because people love it
is_component_build = true
# release build, because its faster
is_debug = false
@xsbchen
xsbchen / install-node--benchmark-requirements.sh
Last active May 4, 2018 09:52
install node benchmark requirements on Ubuntu
#!/bin/bash
# install required packages
sudo apt update
sudo apt install -y git g++ make binutils autoconf automake autotools-dev libtool pkg-config \
zlib1g-dev libcunit1-dev libssl-dev libxml2-dev libev-dev libevent-dev libjansson-dev \
libc-ares-dev libjemalloc-dev libsystemd-dev \
cython python3-dev python-setuptools
# install wrk
@xsbchen
xsbchen / what-forces-layout.md
Created May 19, 2017 01:45 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@xsbchen
xsbchen / update_gfwlist.sh
Created August 2, 2016 07:37 — forked from VincentSit/update_gfwlist.sh
Automatically update the PAC for ShadowsocksX. Only tested on OS X.
#!/bin/bash
# update_gfwlist.sh
# Author : VincentSit
# Copyright (c) http://xuexuefeng.com
#
# Example usage
#
# ./whatever-you-name-this.sh
#
# Task Scheduling (Optional)
// Usage: $(element).scrollToTop([position])
;(function($){
// only allow one scroll to top operation to be in progress at a time,
// which is probably what you want
var scrollToTopInProgress = false
$.fn.scrollToTop = function(position){
var $this = this,
targetY = position || 0,
import Fiddler;
class Handlers {
static var injectJs = "<script>alert('I see you enjoy YouTube.')</script>";
static var hostList = new HostList("*.youtube.com");
static function OnBeforeResponse(oSession : Session) {
// Filter to only HTML documents and on the domains we want
if (hostList.ContainsHost(oSession.hostname) && oSession.oResponse.headers.ExistsAndContains("Content-Type", "text/html")) {
oSession.utilDecodeResponse();
@xsbchen
xsbchen / thottle.js
Last active December 16, 2015 07:59
函数节流
function highThottle(fn, content, mustTime, time) {
var start = new Date();
mustTime = mustTime || 5000;
return function() {
var args = arguments;
clearTimeout(fn.timer);
var end = new Date();
if(end - start > mustTime) {
start = new Date();
clearTimeout(fn.timer);