Instantly share code, notes, and snippets.

View 16.04.sh
#!/bin/bash
set -e
if [ -z "$1" ]; then
echo 'Please run this script with argument <salt-master address>'
exit 1
fi
SALT_MASTER=$1
View README.md

Remove / Uninstall packages marked ‘rc’ on Debian / Ubuntu.

While checking the status of packages using dpkg, it is possible to see a ‘rc’ state for some unused packages, this corresponds to:

  • r: the package was marked for removal
  • c: the configuration files are currently present in the system

In other words: the package is not completely removed (config files are still present), but not installed anymore (and obviously not used).

To see a list of packages marked as ‘rc’:

View README.md

Ubuntu

echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/50-group-sudo-nopasswd
View optional.cpp
#include <iostream>
#include <string>
#include <optional>
int main()
{
std::cout << "sizeof bool is " << sizeof(bool) << '\n';
std::cout << "sizeof std::optional<bool> is " << sizeof(std::optional<bool>) << "\n\n";
std::cout << "sizeof short is " << sizeof(short) << '\n';
View README.md

Environment

  • Intel i7-4790 @ 3.60GHz
  • Ubuntu 14.04.5 LTS (Windows Subsystem Linux)
  • GCC 6.2.0
  • Clang 3.9.1
  • CXXFLAGS -std=c++14 -O2

Output

View README.md
tar czfv NEW_NAME.tar.gz OLD_NAME --transform s/OLD_NAME/NEW_NAME/

Note: this only works with GNU Tar.

Example

we want to tar /opt/zlib/1.2.11 into zlib-1.2.11.tar.gz, and we want the top-level folder inside that tar.gz file to be zlib-1.2.11, not 1.2.11:

View shadowsocks-docker-ubuntu.md

Install and run Shadowsocks Docker container in Ubuntu Server 16.04

# Configurations for shadowsocks
export SSPORT=[your shadowsocks port]
export SSPASSWORD=[your shadowsocks password]

# Install docker prerequisites
sudo apt update
sudo apt install apt-transport-https ca-certificates
View git-repo-init.sh
git lfs clone --recursive [repo].git
git submodule foreach git lfs pull
View bashrc.bat
@echo off
set HOME=%HOMEDRIVE%%HOMEPATH%
@rem Utilites
set PATH=%PATH%;C:\Program Files\WinRAR
set PATH=%PATH%;C:\Program Files (x86)\Microsoft VS Code\bin
set PATH=%PATH%;%HOME%\apps\cmake\3.6.0-win64-x64\bin
set PATH=%PATH%;%HOME%\apps\bin
View ec2-ping-test.sh
#!/bin/bash
#
# Usage:
#
# 1. Set SECURITY_GROUP and KEY_NAME to your value
# 2. source ec2-ping-test.sh
# 3. launch_all_instances
# 4. terminate_all_instances
#