Skip to content

Instantly share code, notes, and snippets.


Mahmoud Abdelkader mahmoudimus

Block or report user

Report or block mahmoudimus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
mahmoudimus / attributes.rb
Created Apr 21, 2019 — forked from lizthegrey/attributes.rb
Hardening SSH with 2fa
View attributes.rb
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
mahmoudimus /
Last active Mar 31, 2019
fix up mac reinstall

I purchased a new Macbook and I restored my files from another mac via migration assistant.

As I was using Brew, I saw a lot of errors such as:

Upgrading railwaycat/emacsmacport/emacs-mac --with-natural-title-bar
Error: An exception occurred within a child process:
  RuntimeError: /usr/local/opt/libevent not present or broken
Please reinstall libevent. Sorry :(
mahmoudimus /
Created Mar 30, 2019 — forked from valyala/
Optimizing postgresql table for more than 100K inserts per second

Optimizing postgresql table for more than 100K inserts per second

  • Create UNLOGGED table. This reduces the amount of data written to persistent storage by up to 2x.
  • Set WITH (autovacuum_enabled=false) on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we never DELETE or UPDATE the table).
  • Insert rows with COPY FROM STDIN. This is the fastest possible approach to insert rows into table.
  • Minimize the number of indexes in the table, since they slow down inserts. Usually an index on time timestamp with time zone is enough.
  • Add synchronous_commit = off to postgresql.conf.
  • Use table inheritance for fast removal of old data:
View growth_accounting_and_ltv.sql
dau as (
-- This part of the query can be pretty much anything.
-- The only requirement is that it have three columns:
-- dt, user_id, inc_amt
-- Where dt is a date and user_id is some unique identifier for a user.
-- Each dt-user_id pair should be unique in this table.
-- inc_amt represents the amount of value that this user created on dt.
-- The most common case is
-- inc_amt = incremental revenue from the user on dt

Kotlin Annoyances

These are things that I found annoying writing a complex library in Kotlin. While I am also a Scala developer, these should not necessarily be juxtaposed w/ Scala (even if I reference Scala) as some of my annoyances are with features that Scala doesn't even have. This is also not trying to be opinionated on whether Kotlin is good/bad (for the record, I think it's good). I have numbered them for easy reference. I can give examples for anything I am talking about below upon request. I'm sure there are good reasons for all of them.

  1. Arrays in data classes break equals/hashCode and ask you to overload it. If you are going to need to overload it and arrays have no overridability, why not make the least-often use case (the identity-comparison equals) the exception?
mahmoudimus /
Created Jan 29, 2019 — forked from kvnsmth/
A real world usage for git subtrees.

Let's say you have an iOS project, and you want to use some external library, like AFNetworking. How do you integrate it?

With submodules

Add the project to your repo:

git submodule add Vendor/AFNetworking

or something to that effect.

mahmoudimus /
Created Jan 29, 2019 — forked from LeZuse/
WSGI script with virtualenv activation with Flask
import os
import sys
# Install venv by `virtualenv --distribute venv`
# Then install depedencies: `source venv/bin/active`
# `pip install -r requirements.txt`
activate_this = '/var/www/apache/'
execfile(activate_this, dict(__file__=activate_this))
path = os.path.join(os.path.dirname(__file__), os.pardir)
mahmoudimus / export-device-hrefs.js
Last active Jan 14, 2019
Exports the history from Google Chrome's syncedTabs in chrome://history/syncedTabs
View export-device-hrefs.js
1. Go to chrome://history/syncedTabs
2. Open up the console
3. Copy & paste the script below into the console
4. Profit
const history = document.querySelector("#history-app").shadowRoot;
const main = (history.querySelector("#main-container > iron-pages#content > history-synced-device-manager#synced-devices")
.root.querySelector("div#synced-device-list > history-synced-device-card"));
mahmoudimus / emacs_daemon.scpt
Created Dec 10, 2018 — forked from dlukes/emacs_daemon.scpt
AppleScript wrapper app around Emacs for running it conveniently as a daemon on OS X
View emacs_daemon.scpt
1. Create an Application in Automator.
2. Add a Run AppleScript action.
3. Paste the content of this gist instead of the provided script skeleton.
4. Save the app, drag it to your dock and/or set it as the default app for
the filetypes of your choice using the Open With dialog in Finder.
mahmoudimus / emacs-loader
Created Dec 10, 2018 — forked from hadongsoo/emacs-loader
emacs for daemon
View emacs-loader
tell application "Terminal"
-- we look for <= 2 because Emacs --daemon seems to always have an entry in visibile-frame-list even if there isn't
set frameVisible to do shell script "/Applications/ -e '(<= 2 (length (visible-frame-list)))'"
if frameVisible is not "t" then
-- there is a not a visible frame, launch one
do shell script "/Applications/ -c -n"
end if
on error
-- daemon is not running, start the daemon and open a frame
You can’t perform that action at this time.