Skip to content

Instantly share code, notes, and snippets.

@coin8086
coin8086 / using-proxy-for-git-or-github.md
Last active January 24, 2025 07:47
Use Proxy for Git/GitHub

Use Proxy for Git/GitHub

Generally, the Git proxy configuration depends on the Git Server Protocol you use. And there're two common protocols: SSH and HTTP/HTTPS. Both require a proxy setup already. In the following, I assume a SOCKS5 proxy set up on localhost:1080. But it can also be a HTTP proxy. I'll talk about how to set up a SOCKS5 proxy later.

SSH Protocol

When you do git clone ssh://[user@]server/project.git or git clone [user@]server:project.git, you're using the SSH protocol. You need to configurate your SSH client to use a proxy. Add the following to your SSH config file, say ~/.ssh/config:

ProxyCommand nc -x localhost:1080 %h %p
// from https://stackoverflow.com/questions/10798357/want-to-compile-native-android-binary-i-can-run-in-terminal-on-the-phone
/*
# create tool-chain - one line
# New method in ndk 12.
$NDK/build/tools/make_standalone_toolchain.py --arch arm --install-dir=/tmp/my-android-toolchain
# Old method.
#$NDK/build/tools/make-standalone-toolchain.sh --platform=android-3 --install-dir=/tmp/my-android-toolchain
# add to terminal PATH variable
export PATH=/tmp/my-android-toolchain/bin:$PATH
@merryhime
merryhime / text.md
Last active April 11, 2025 01:16
Playing with segment registers fs and gs on x64

GSBASE and FSBASE

When you're running out of registers while writing a JIT, you might resort to more unconventional methods for memory access. You might choose to resort to segment registers if you need a fixed register for memory offsets.

Instructions such as:

lea    rax,gs:[rcx+rdx*8]
mov    rax,gs:[rcx+rdx*8]

would then be available for your use.

@bingo347
bingo347 / send_fd__to_node.go
Created January 10, 2017 17:14
send file descriptor from golang to nodejs
package main
import (
"net"
"fmt"
"syscall"
)
func main() {
addr, err := net.ResolveTCPAddr("tcp", "localhost:8090")
@Akagi201
Akagi201 / browser.md
Last active September 8, 2016 02:54

兼容性测试

浏览器内核/渲染引擎/排版引擎/解释引擎/Rendering Engine

  • 渲染引擎主要是负责HTML, CSS以及其他一些东西的渲染.
  • 有时, 浏览器内核, 除了渲染引擎, 也悄悄包含了javascript引擎. 如: WebKit, 它由渲染引擎WebCore和Javascript引擎JSCore组成.
  • IE: Trident
  • Safari: WebKit(KHTML分支) -> WebKit2
  • Chrome/Chromium: Chromium引擎(WebKit分支) -> Blink引擎(基于WebKit2)
  • Opera: Elektra -> Presto -> Chromium引擎 -> Blink引擎
@lunny
lunny / diskinfo.go
Created March 28, 2014 08:59
Disk Info for Golang
package main
import (
"fmt"
"syscall"
)
type DiskStatus struct {
All uint64 `json:"all"`
Used uint64 `json:"used"`
@yanatan16
yanatan16 / pebble-discs.c
Last active August 29, 2015 13:56
Pebble Discs Walkthrough
#include <pebble.h>
#include <time.h>
static const int FACE_DISC_RADIUS = 70;
static const int CENTER_DISC_RADIUS = 20;
static const int HOUR_DISC_RADIUS = 10;
static const int MINUTE_DISC_RADIUS = 5;
static const int HOUR_ROT_RADIUS = 40;
static const int MINUTE_ROT_RADIUS = 60;
@branneman
branneman / better-nodejs-require-paths.md
Last active April 11, 2025 10:39
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@hgfischer
hgfischer / benchmark+go+nginx.md
Last active January 6, 2025 09:05
Benchmarking Nginx with Go

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
import os
import sys
import re
import hashlib
import csv
import time
import locale
import getopt