Skip to content

Instantly share code, notes, and snippets.

View 19317362's full-sized avatar

david.wang 19317362

View GitHub Profile
@19317362
19317362 / gb2312-utf8-convert.js
Created January 12, 2016 06:20 — forked from fwolf/gb2312-utf8-convert.js
Convert between gb2312 and utf8 using javascript
http://freecode-freecode.blogspot.com/2008/11/how-to-gbkgb2312-and-utf-8-encoding.html
GB2312UTF8 = {
Dig2Dec : function(s){
var retV = 0;
if(s.length == 4){
for(var i = 0; i < 4; i ++){
retV += eval(s.charAt(i)) * Math.pow(2, 3 - i);
}
return retV;
@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

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;
@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 / Makefile
Created April 22, 2019 10:36 — forked from sehe/Makefile
Boost shared memory lockfree circular buffer queue
all:consumer producer
CPPFLAGS+=-std=c++03 -Wall -pedantic
CPPFLAGS+=-g -O0
CPPFLAGS+=-isystem ~/custom/boost/
LDFLAGS+=-L ~/custom/boost/stage/lib/ -Wl,-rpath,/home/sehe/custom/boost/stage/lib
LDFLAGS+=-lboost_system -lrt -lpthread
%:%.cpp
@19317362
19317362 / andro_info.sh
Created July 30, 2019 21:45 — forked from konfou/andro_info.sh
Android Device Specifications
#! /bin/bash
if ! type adb; then
echo "adb not found"
echo "check PATH"
else
echo "============================"
echo "Android Device Specificatios"
echo "============================"
adb wait-\for-device
echo "> Manufacturer"
@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"
OVERVIEW: LLVM 'Clang' Compiler: http://clang.llvm.org
USAGE: clang -cc1 [options] <inputs>
OPTIONS:
-### Print the commands to run for this compilation
--analyze Run the static analyzer
--migrate Run the migrator
--relocatable-pch Build a relocatable precompiled header
--serialize-diagnostics <value>

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
@19317362
19317362 / installantoncentos.sh
Last active October 14, 2022 18:24 — forked from parzonka/installantoncentos.sh
How to install ant on centos
# download and install
antversion=1.10.3
wget http://archive.apache.org/dist/ant/binaries/apache-ant-${antversion}-bin.tar.gz
sudo tar xvfvz apache-ant-${antversion}-bin.tar.gz -C /opt
sudo ln -sfn /opt/apache-ant-${antversion} /opt/ant
sudo sh -c 'echo ANT_HOME=/opt/ant >> /etc/environment'
sudo ln -sfn /opt/ant/bin/ant /usr/bin/ant
# check installation
ant -version