Skip to content

Instantly share code, notes, and snippets.

section .text
global _start
_start:
push 1
push 2
call add2 ; rax = add2(1, 2)
push 3
push 4
@HouzuoGuo
HouzuoGuo / gist:a5326b49cb17b7db2c46900f387dfaf5
Created January 14, 2020 09:03
Cross-compile and build OpenSSL for 32-bit ARM (hard-float) on an Intel/AMD computer
# Edit APT sources list file and uncomment/enable deb-src sources, then:
sudo dpkg --add-architecture armhf
sudo apt-get update
sudo apt-get install crossbuild-essential-armhf
sudo apt-get build-dep -a armhf openssl
apt-get source openssl
cd openssl-1.1.1
debuild -- clean
env DEB_HOST_MULTIARCH=armhf DEB_BUILD_OPTIONS=nocheck debuild -uc -us -aarmhf
@HouzuoGuo
HouzuoGuo / gist:098fb7c5398e1941bbb194eae5171999
Last active January 15, 2020 12:23
Cross-compile and build OpenSSL for 32-bit ARM (with hardware floating point) on an Intel/AMD Ubuntu 18.04 computer
# Run the commands in a docker container: docker run -it --rm ubuntu:18.04
cat > /etc/apt/sources.list <<EOF
deb http://archive.ubuntu.com/ubuntu/ bionic main restricted
deb-src http://archive.ubuntu.com/ubuntu/ bionic main restricted
deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb-src http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb http://archive.ubuntu.com/ubuntu/ bionic universe
deb-src http://archive.ubuntu.com/ubuntu/ bionic universe
deb http://archive.ubuntu.com/ubuntu/ bionic-updates universe
deb-src http://archive.ubuntu.com/ubuntu/ bionic-updates universe
@HouzuoGuo
HouzuoGuo / gist:83eaab9a46a8ab3c7473323b34f9ea62
Last active March 22, 2020 11:43
Use PostgreSQL to convert CSV into JSON

Start the server

docker run -it --rm -e POSTGRES_PASSWORD=demo -e POSTGRES_HOST_AUTH_METHOD=trust postgres:10

Prepare DB client

cat <<EOF >test.csv
title,url
"NHS facing Italian-style coronavirus crisis if we don't stay at home, says Boris Johnson",https://www.telegraph.co.uk/politics/2020/03/21/nhs-facing-italian-style-crisis-dont-stay-home-says-boris-johnson/

Italy: PM warns of worst crisis since WW2 as coronavirus deaths leap by almost 800,https://www.theguardian.com/world/2020/mar/22/italian-pm-warns-of-worst-crisis-since-ww2-as-coronavirus-deaths-leap-by-almost-800

@HouzuoGuo
HouzuoGuo / gist:dbffed31a26359f610f6d9595fb37ef2
Last active April 29, 2020 09:44
Useful system packages (Ubuntu 20.04 LTS)
apt install -y ansible apache2-utils apt-transport-https autoconf automake bash binutils busybox bzip2 caca-utils ca-certificates cgroup-tools cloc cscope ctags curl dateutils dbus diffutils dnsutils dos2unix expat findutils finger gdb gnupg gnutls-bin hostname htop iftop iotop iputils-ping iputils-tracepath lftp lm-sensors locales locales-all lrzsz lsof mailutils make minicom miscfiles moreutils mosh netcat net-tools nicstat nmap nmon openssl p7zip patchutils pciutils procps psmisc rsync screen shellcheck silversearcher-ag snmp socat software-properties-common strace sudo tcpdump tcptraceroute telnet tmux traceroute tree tshark unar uniutils unzip usbutils util-linux util-linux-locales vim wbritish wget whois wiggle yamllint zip zlib1g
@HouzuoGuo
HouzuoGuo / gist:31e640d4f61229f3e76853bfa4537b05
Created July 6, 2020 05:40
Fix all sorts of timer and sleep issues for Ubuntu 20.04 running in WSL
Solution is taken from: https://github.com/microsoft/WSL/issues/4898#issuecomment-646790723
cat <<'EOF' > nanosleep.c
#include <time.h>
#include <unistd.h>
int nanosleep(const struct timespec *req, struct timespec *rem)
{
return clock_nanosleep(CLOCK_MONOTONIC, 0, req, rem);
}
int usleep(useconds_t usec)