Skip to content

Instantly share code, notes, and snippets.

@alphamarket
alphamarket / crio.md
Created December 5, 2023 15:39
How to put a proxy in front of Kubernetes to download images behind a proxy when launching using CRI-O
# nano /etc/default/crio

HTTP_PROXY=http://127.0.0.1:8118
ALL_PROXY=http://127.0.0.1:8118
HTTPS_PROXY=http://127.0.0.1:8118
NO_PROXY=localhost,10.96.0.0/12,192.168.0.0/16,172.16.0.0/12,127.0.0.0/8,<SERVER'S IP> # append any other IPs/domains to not go through the proxy
@alphamarket
alphamarket / 12proxy.sh
Created September 28, 2023 11:13
Download APT through a proxy
# /etc/apt/apt.conf.d/12proxy
Acquire::http::proxy "socks5h://127.0.0.1:9999";
Acquire::https::proxy "socks5h://127.0.0.1:9999";
@alphamarket
alphamarket / bash.sh
Created September 25, 2023 14:31
How to change the Xubuntu's terminal shortcuts
nano ~/.config/xfce4/terminal/accels.scm
@alphamarket
alphamarket / main.cpp
Last active January 3, 2022 11:44
Multi-Host & Multi-Certificate OpenSSL-based Server
#include <stdio.h>
#include <sstream>
#include <unistd.h>
#include <string.h>
#include <iostream>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <unordered_map>
#include <openssl/ssl.h>
#include <openssl/err.h>
@alphamarket
alphamarket / .bashrc
Created August 8, 2021 20:17
Install and use ElasticSearch with limited resources using docker
# follow `https://www.elastic.co/guide/en/kibana/current/docker.html#run-kibana-on-docker-for-dev` instructions for
# installing ES using docker
function run-docker-es() {
# remove any already running es instance
docker ps -af "name=elasticsearch" -q 2>/dev/null | xargs docker rm &>/dev/null
# launch the ES with 1GB memory limit and 3 core
docker run --name elasticsearch \
--net elastic \
-p 9200:9200 \
@alphamarket
alphamarket / http-proxy.conf.md
Last active March 24, 2024 07:22
How to make docker pull using a socks5 proxy

Create the config file:

mkdir -p /etc/systemd/system/docker.service.d && \
vi /etc/systemd/system/docker.service.d/http-proxy.conf

Put up the configs:

@alphamarket
alphamarket / mysql-connector-cpp-installer.sh
Created June 23, 2021 13:37
Painlessly Install MySQL Connector for C++
apt-get install -y wget && \
wget 'https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-client-plugins_8.0.25-1ubuntu20.04_amd64.deb' && \
wget 'https://dev.mysql.com/get/Downloads/Connector-C++/libmysqlcppconn9_8.0.25-1ubuntu20.04_amd64.deb' && \
wget 'https://dev.mysql.com/get/Downloads/Connector-C++/libmysqlcppconn8-2_8.0.25-1ubuntu20.04_amd64.deb' && \
wget 'https://dev.mysql.com/get/Downloads/Connector-C++/libmysqlcppconn-dev_8.0.25-1ubuntu20.04_amd64.deb' && \
dpkg -i mysql-community-client-plugins_8.0.25-1ubuntu20.04_amd64.deb && \
dpkg -i libmysqlcppconn9_8.0.25-1ubuntu20.04_amd64.deb && \
dpkg -i libmysqlcppconn8-2_8.0.25-1ubuntu20.04_amd64.deb && \
dpkg -i libmysqlcppconn-dev_8.0.25-1ubuntu20.04_amd64.deb && \
apt-get install -y libmysqlcppconn-dev
@alphamarket
alphamarket / ip2long.cpp
Last active March 8, 2020 06:05
Converts IPv4 and IPv6 to decimal (long value) in C++
#include <iostream>
#include <boost/asio/ip/address.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using big_int = boost::multiprecision::cpp_int;
big_int ip2long(const std::string&);
int main(int, char**) {
const auto
fals = "xxx.xxx.x.x",
@alphamarket
alphamarket / spider.rb
Created January 2, 2020 05:35
spider script for testing site's broken links
#!/usr/bin/env ruby
ENV['TZ'] = 'UTC'
require 'rubygems'
require 'active_support/core_ext/object/blank'
require 'nokogiri'
require 'net/http'
require 'byebug'
require 'logger'
require 'uri'
@alphamarket
alphamarket / commit-fix.bash
Created December 9, 2019 06:42
How to add a changed file to an older (not last) commit in Git
# To "fix" an old commit with a small change, without changing the commit message
# of the old commit, where OLDCOMMIT is something like 091b73a:
# Copied from `https://stackoverflow.com/a/27721031/1198291`
git add <my fixed files>
git commit --fixup=OLDCOMMIT
git rebase --interactive --autosquash OLDCOMMIT^ # at here do noting and exit from editor, it will do the job