Skip to content

Instantly share code, notes, and snippets.


Michael Mahemoff mahemoff

View GitHub Profile
mahemoff / unique_domains.rb
Created Jul 27, 2022
Unique domains list from ICANN zones files
View unique_domains.rb
#!/usr/bin/env ruby
# Based on - extended it to read from gzipped file, support any domain extension, and output to separate file
require 'hashie'
require 'zlib'
class Parser < Hashie::Dash
property :extension, required: 'true' # e.g. "com" for dotcom database
mahemoff /
Last active May 23, 2022
Tuning MySQL and Apache

A few general tips to deal with slow performance and hanging. Target system is Ubunty 20.04 and MySQL 8.0, but applicable to other configurations.

Relies on some functions in

Slow log

MySQL can log slow queries. Enable it in /etc/mysql/mysql.conf.d/mysqld.cnf.

slow_query_log = 1
mahemoff / certbot
Last active Aug 21, 2022
Certbot for Apache one-liner
View certbot
# Certbot can be a bit tedious, but it's easy to automate a one-liner non-interactive. Substitute your own domain and email below.
sudo service apache2 stop && sudo certbot --apache -d -m --non-interactive --agree-tos && sudo service apache2 start
mahemoff /
Last active Nov 17, 2020
Persistent Connection Services - Pricing

Here I'm interested in a use case of subscribers keeping a permanent connection open (24/7), but with negligible amount of messages. So I'm only concerned about price per connection, not price per message.

AWS API Gateway

$0.25 per million connection minutes

That's $1 per 4 million connection minutes.

mahemoff /
Last active Sep 21, 2022
Vim Terminal Mode - A short introduction

Vim has a Terminal Mode!

Since v8.1 (May 2018), Vim has shipped with a built-in terminal. See or type :help terminal for more info.

Why use this? Mainly because it saves you jumping to a separate terminal window. You can also use Vim commands to manipulate a shell session and easily transfer clipboard content between the terminal and files you're working on.

Key Bindings

mahemoff /
Last active Aug 28, 2020
Generate a strong password in bash

A wrapper for pwgen. Put this in your ~/.bashrc to generate a long & strong password. You can append an optional message to remind yourself of the purpose if you can't immediately transfer it to a credentials repository.

Example usage:

$ hardpass
$ hardpass
$ hardpass new twitter password
### new twitter password
mahemoff /
Last active Aug 26, 2020
Split mbox file into N parts
View gist:df3fa3c6cb9a5de610942ed1ad08ae3a
### Keybase proof
I hereby claim:
* I am mahemoff on github.
* I am mahemoff ( on keybase.
* I have a public key ASAG4tJDQ2HpifE_ViR49cBZWw75E2MeiYX5PpTpxoJADgo
To claim this, I am signing this object:
"body": {
"key": {
mahemoff /
Last active Feb 5, 2020
WikiData Sample JSON dump