Skip to content

Instantly share code, notes, and snippets.

@ammarlakis
ammarlakis / Dashboard.md
Last active February 28, 2025 06:09
Job Applications Tracker

📝 Job Applications

dv.table(
    ["Company", "Position", "Status", "Location"],
    dv.pages('"Job Applications/Applications"').map(p => [
        p.company,
        `[[${p.file.path}|${p._position}]]`,
        addEmoji(p.status),  // Add emoji dynamically
        p.location
 ])
@ammarlakis
ammarlakis / source_of_truth.md
Last active July 16, 2025 00:06
Source of Truth

"Git as a Single Source of Truth" means that when you put together the parts you have in git, you get your platform up and running in the current state.

Bits that run for your platform can be broken into 4 categories:

  1. Code you're developping; the actual code you write for your project.
  2. Code you didn't write; third party packages and modules.
  3. Configuration; this includes both apps configuration and infrastructure files.
  4. Data; which are stored in databases and file storage systems.

All of these combined make your "platform", and define the state it runs in given a specific environment (e.g. AWS). Among the aforementioned parts, your code, your dependencies list and hashes, and your configuration are the only parts that fit in a version contol system, while your data should be backed up properly.

@ammarlakis
ammarlakis / parse_slow.py
Last active May 16, 2019 11:57
Converts slow queries log of mysql to csv
#!/usr/bin/python
import re
import time
# Open a file
ifile = open("mariadb-slow.log", "r")
print("Name of the file: ", ifile.name)
text = ifile.read()
ifile.close()
text = re.split(r'\n# Time:', text)
pattern = re.compile("""# Time:.+\n#.+Host:\s+(.+)\s+@.+\n#.+hit:\s+(.+)\n#\s+Query_time:\s+(\d+(?:\.\d+))?.+ Rows_sent:\s+(\d+)\s+Rows_examined:\s+(\d+)\n#\s+Rows_affected:\s+(\d+)\n(?:.|\n)+SET\s+timestamp=(\d+);\n((?:.|\n)+;);""", re.MULTILINE)
@ammarlakis
ammarlakis / YoutubeWatchPlaylist.js
Last active August 13, 2017 12:17
Until fellows at YouTube refine their interface, this script changes playlists title url from starting videos to listing them.
// ==UserScript==
// @name Watch to Playlist
// @namespace https://gist.github.com/ammarlakis
// @version 0.1
// @description aghh, youtube's interface!
// @author Ammar Lakis
// @match https://www.youtube.com/user/**
// @match https://www.youtube.com/channel/**
// @grant none
// ==/UserScript==
@ammarlakis
ammarlakis / cipher.py
Last active December 27, 2016 19:20
CryptoCurrency μServer
from Crypto import Random
from Crypto.Cipher import AES
from Crypto.PublicKey import RSA
import md5
BLOCK_SIZE = 16
pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * \
chr(BLOCK_SIZE - len(s) % BLOCK_SIZE)
unpad = lambda s: s[:-ord(s[len(s) - 1:])]
@ammarlakis
ammarlakis / vpnbook.sh
Last active November 2, 2016 08:38
A wrapper for openvpn service with vpnbook servers
#!/bin/bash
case $1 in
update_cert)
rm -rf *.zip
rm -rf *.ovpn
wget https://www.vpnbook.com/free-openvpn-account/VPNBook.com-OpenVPN-Euro1.zip
wget https://www.vpnbook.com/free-openvpn-account/VPNBook.com-OpenVPN-Euro2.zip
wget https://www.vpnbook.com/free-openvpn-account/VPNBook.com-OpenVPN-US1.zip
wget https://www.vpnbook.com/free-openvpn-account/VPNBook.com-OpenVPN-US2.zip
@ammarlakis
ammarlakis / check_memory.sh
Last active September 29, 2016 12:40
Notification for Low Memory
#!/bin/bash
export DISPLAY=:0
CRITICAL_THRESHOLD=$1
MEM=`/usr/bin/free -m | /usr/bin/head -n 2 | /usr/bin/tail -n 1 | /bin/sed -n 's/Mem:\s\+[0-9]\+\s\+[0-9]\+\s\+\([0-9]\+\).*/\1/p'`
if [ "$MEM" -lt "$CRITICAL" ]; then
/usr/bin/notify-send --icon=dialog-warning --expire-time=10000 --urgency=normal "Low Memory" "Your only have $MEM of memory free, upgrade your pc stingy man";
fi
@ammarlakis
ammarlakis / bind-chroot.spec
Created January 25, 2015 20:41
Bind chroot spec file
%define name bind-chroot
%define version 9.9.6
%define release P1
%define url https://www.isc.org/downloads/BIND/
%define src %{name}-%{version}-%{release}.tar.gz
Name: %{name}
Version: %{version}
Release: %{release}
@ammarlakis
ammarlakis / Export-Sizes.PS1
Created January 18, 2015 05:23
Exports files' sizes to csv file.
Function Export-Sizes {
<#
.SYNOPSIS
Exports files' sizes to csv file.
.DESCRIPTION
The Export-Sizes function exports files names and sizes to a csv file.
@ammarlakis
ammarlakis / Convert-Size.PS1
Last active August 29, 2015 14:13
Converts file size to human readable format.
Function Convert-Size {
<#
.SYNOPSIS
Converts size from bytes to human readable format.
.DESCRIPTION
The Convert-Size function takes a number of bytes and convert it to KB, MB or GB depending on the most appropriate
and closest value.