Skip to content

Instantly share code, notes, and snippets.

View 19317362's full-sized avatar

david.wang 19317362

View GitHub Profile
@19317362
19317362 / create-hotspot.md
Created February 23, 2023 09:53 — forked from narate/create-hotspot.md
Create Wi-Fi Hotspot on Linux using nmcli

Create a Wi-Fi hotspot on Linux using nmcli

Original post : https://unix.stackexchange.com/a/310699

nmcli con add type wifi ifname wlan0 con-name Hostspot autoconnect yes ssid Hostspot
nmcli con modify Hostspot 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared
nmcli con modify Hostspot wifi-sec.key-mgmt wpa-psk
nmcli con modify Hostspot wifi-sec.psk "veryveryhardpassword1234"

Use Proxy for Git/GitHub

Generally, the Git proxy configuration depends on the Git Server Protocal you use. And there're two common protocals: 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 protocal. You need to configurate your SSH client to use a proxy. Add the following to your SSH config file, say ~/.ssh/config:

ProxyCommand ncat --proxy 127.0.0.1:1080 --proxy-type socks5 %h %p
#include <mutex>
#include <condition_variable>
using namespace std;
class semaphore
{
public:
semaphore(int count_ = 0) : count{count_}
{}
@19317362
19317362 / ARMonQEMUforDebianUbuntu.md
Created April 26, 2022 02:09 — forked from luk6xff/ARMonQEMUforDebianUbuntu.md
Emulating ARM with QEMU on Debian/Ubuntu

You might want to read this to get an introduction to armel vs armhf.

If the below is too much, you can try Ubuntu-ARMv7-Qemu but note it contains non-free blobs.

Running ARM programs under linux (without starting QEMU VM!)

First, cross-compile user programs with GCC-ARM toolchain. Then install qemu-arm-static so that you can run ARM executables directly on linux

If there's no qemu-arm-static in the package list, install qemu-user-static instead

@19317362
19317362 / writable-avd.md
Last active November 27, 2021 09:22 — forked from interference-security/writable-avd.md
How to make AVD system and file-system writable?
#!/bin/bash
set -e
set -x
# Set directory
SCRIPTPATH=`realpath .`
export ANDROID_NDK_HOME=$SCRIPTPATH/android-ndk-r20
OPENSSL_DIR=$SCRIPTPATH/openssl-1.1.1c
# Find the toolchain for your build machine
@19317362
19317362 / subprocess-bufsize-test.py
Created October 6, 2021 02:53 — forked from 510908220/subprocess-bufsize-test.py
使用subprocess。避免在子程序大量输出时因buffer size满,导致父进程hang住。
#!/usr/bin/python
# -*- coding: utf-8 -*-
import subprocess
from StringIO import StringIO
out = StringIO()
sp = subprocess.Popen(["python", "test_output.py"],
stdout=subprocess.PIPE,
@19317362
19317362 / setup.md
Created July 3, 2021 04:38 — forked from foxlet/setup.md
macOS Installation Media Guide (Windows)

Download macOS

  1. Get FetchMacOS and place it in a known folder.

  2. Open Command Prompt and use cd to go to the known folder.

  3. Run fetch-macos.exe -p PRODUCTID -o SharedSupport where PRODUCTID is the macOS package you want to download.

Edit Downloaded Files

  1. Rename InstallESDDmg.pkg inside the SharedSupport folder to InstallESD.dmg
@19317362
19317362 / android-shared-lib-dependencies.sh
Created March 22, 2021 10:09 — forked from cawka/android-shared-lib-dependencies.sh
Recursively calculate shared library dependencies and generate System.load(); statements
# Set correct path to readelf binary in Android NDK
READELF=/opt/crystax-ndk-10.3.1/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-readelf
# List libraries that exist in /system/lib
STANDARD_LIBS=(c dl m stdc++ log z)
has() {
local p=$1
shift
local x

ELF

ELF Header

The first portion of any ELF file is the ELF header. This generally provides offsets to other headers (program headers and section headers) within an ELF.

typedef struct {
  unsigned char e_ident[EI_NIDENT];
 uint16_t e_type;