Skip to content

Instantly share code, notes, and snippets.

View 19317362's full-sized avatar

david.wang 19317362

View GitHub Profile
@19317362
19317362 / PostUpload.c
Created August 7, 2020 17:58 — forked from jay/PostUpload.c
Use libcurl to upload POST data.
/* Use libcurl to upload POST data.
Usage: PostUpload <post_data_filename> <url>
Used this as a speed test in Win7 x64, see
https://github.com/curl/curl/issues/708
First test the speed in a web browser:
Go to https://testmy.net/mirror and choose the geographically closest mirror.
After the mirror is set click on 'Upload Test'.
@19317362
19317362 / PostJSON.c
Created August 7, 2020 18:05 — forked from jay/PostJSON.c
Use libcurl to POST JSON data.
/* Use libcurl to POST JSON data.
Usage: PostJSON <name> <value>
curl-library mailing list thread:
'how do i post json to a https ?'
http://curl.haxx.se/mail/lib-2015-01/0049.html
Copyright (C) 2015 Jay Satiro <[email protected]>
http://curl.haxx.se/docs/copyright.html
@19317362
19317362 / CountingFileRequestBody.java
Created August 11, 2020 16:06 — forked from eduardb/CountingFileRequestBody.java
Uploading a file with a progress displayed using OkHttp
public class CountingFileRequestBody extends RequestBody {
private static final int SEGMENT_SIZE = 2048; // okio.Segment.SIZE
private final File file;
private final ProgressListener listener;
private final String contentType;
public CountingFileRequestBody(File file, String contentType, ProgressListener listener) {
this.file = file;
@19317362
19317362 / shadowsocks_privoxy_tsocks.md
Created December 16, 2020 06:58 — forked from Jimmy-Xu/shadowsocks_privoxy_tsocks.md
shadowsocks+privoxy/tsocks

shadowsocks + privoxy/tsocks

  • shadowsocks: service, socks proxy
  • privoxy: service, convert socks proxy to http proxy
  • tsocks: tool, use socks proxy for any command line

Usage

tested under ubuntu14.04

@19317362
19317362 / git-cloneall
Created January 5, 2021 22:14 — forked from tstone2077/git-cloneall
Clones as usual but creates local tracking branches for all remote branches.
#!/bin/bash
# Clones as usual but creates local tracking branches for all remote branches.
# To use, copy this file into the same directory your git binaries are (git, git-flow, git-subtree, etc)
clone_output=$((git clone "$@" ) 2>&1)
retval=$?
echo $clone_output
if [[ $retval != 0 ]] ; then
exit 1

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 / 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
@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 / 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,
#!/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