Skip to content

Instantly share code, notes, and snippets.

@x-projs
x-projs / ubuntu-init.sh
Last active December 9, 2020 15:35
ubuntu-init.sh
# Create swap file
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' >> /etc/fstab
sudo apt update
sudo apt dist-upgrade -y
sudo apt install -y docker.io
@x-projs
x-projs / mkexeloadable.c
Last active June 3, 2023 13:57
Make the executable file can be loaded by dlopen() after glibc>=2.30.
/*
There is a behavior change in glibc>=2.30. dlopen() will fail if the file is
position independent executable. This code will clean up the PIE flag in the
file to bypass the dlopen() check.
MIT License (c) 2020 Yubo Xie, xyb@xyb.name
*/
#include <stdio.h>
#include <string.h>
@x-projs
x-projs / mdbook-blockdiag.py
Created December 30, 2019 10:26
Preprocessor for mdbook to generate blockdiag.
# Preprocessor for mdbook to generate blockdiag.
# By xyb@xyb.name, MIT License
#
# Convert the following code in .md to svg:
#
# ```
# seqdiag {
# A --> B
# B --> C
# }
@x-projs
x-projs / mdBook-add-contributors.py
Created December 18, 2019 16:37
mdBook preprocessor for adding contributors (git committer) to each chapter.
import json;
import os;
import re;
import sys;
def processBookItem(src_path, item):
if 'Chapter' in item:
processChapter(src_path, item['Chapter'])
def processChapter(src_path, ch):
@x-projs
x-projs / Useful.Git.Commands.sh
Last active September 10, 2019 14:11
Useful Git Commands
# Delete all remote tags.
git tag -l | xargs -n 1 git push --delete origin
# Delete all remote branches except master.
git branch -r | grep -v master | sed 's/origin\///' | xargs -n 1 git push --delete origin
# Delete all merged branches.
git branch -r --merged | grep -v master | sed 's/origin\///' | xargs -n 1 git push --delete origin