Skip to content

Instantly share code, notes, and snippets.

Avatar
😀
😄

Dino Korah codemedic

😀
😄
View GitHub Profile
@codemedic
codemedic / natophon.sh
Created Nov 16, 2020 — forked from bradland/natophon.sh
NATO phonetic string converter for bash
View natophon.sh
#!/bin/bash
#########################################################################
# #
# #
# NATO String converter #
# #
# Description: converts string (first parameter given) #
# to NATO phonetics-alphabet #
# #
@codemedic
codemedic / bubbles.cpp
Last active Sep 28, 2020
Blow bubbles with C++
View bubbles.cpp
void
blow_bubbles_till(bool& condition)
{
static const char* sprite = ". o O @ *";
unsigned frame = 0;
while (!condition) {
boost::this_thread::sleep_for(boost::chrono::milliseconds(250));
std::cerr << "\r‗‗" << std::string(sprite + frame * 5, 5) << ' ';
frame = (frame + 1) % 5;
}
@codemedic
codemedic / README.md
Last active Jan 15, 2020
GPG Key Backup
View README.md

Run pdflatex --shell-escape gpgbackup.tex to produce a pdf that you can print and lock away.

In order to recover the key, you will have to scan extract individual QR Codes with names IMGa.png, IMGb.png, IMGc.png and IMGd.png, as given in the name of each figure, then run the recovery commands.

NOTE: The above command WILL leave some artefacts in /tmp which should be removed using the command rm /tmp/IMG*png

PS: Original formula for this gist was from @costrouc.

@codemedic
codemedic / gpg2qrcodes.sh
Created Jan 15, 2020 — forked from joostrijneveld/gpg2qrcodes.sh
Producing printable QR codes for persistent storage of GPG private keys
View gpg2qrcodes.sh
# Heavily depends on:
# libqrencode (fukuchi.org/works/qrencode/)
# paperkey (jabberwocky.com/software/paperkey/)
# zbar (zbar.sourceforge.net)
# Producing the QR codes:
# Split over 4 codes to ensure the data per image is not too large.
gpg --export-secret-key KEYIDGOESHERE | paperkey --output-type raw | base64 > temp
split temp -n 4 IMG
for f in IMG*; do cat $f | qrencode -o $f.png; done
@codemedic
codemedic / README.md
Last active Jun 6, 2019
Linux-like terminal in Mac OS
View README.md

Linux-like terminal in Mac OS

Caveat: This was done in anger to aleviate my pain; There could be a better way to do this. Please do leave comments and suggestions.

This script is meant to be used as .bashrc, in order to make the transition from Linux to MacOS less painful. It makes available GNU tools and utils in your PATH so that they can be invoked effortlessly. It also allows you to leave an untainted terminal setup for anything very native to MacOS.

@codemedic
codemedic / bash-colors.sh
Created Apr 3, 2019
Utility function to print bash colour codes
View bash-colors.sh
# based on https://github.com/mathieu-aubin/c7repos/blob/master/functions/bash-colors
__print_color_row() {
local color
color=$(printf '%03d' "$1")
echo -ne "\\033[1;48;5;${color}m \\\\033[48;5;${color}m \\033[0m";
echo -ne "\\033[1;7;38;5;${color}m\\\\033[7;38;5;${color}m \\033[0m";
echo -ne " \\033[1;38;5;${color}m\\\\033[1;38;5;${color}m\\033[0m";
echo -ne " \\033[38;5;${color}m\\\\033[38;5;${color}m\\033[0m";
echo -ne " \\033[2;38;5;${color}m\\\\033[2;38;5;${color}m\\033[0m";
@codemedic
codemedic / kinesis-get-records.sh
Last active Mar 23, 2020
Get records from a AWS Kinesis Data Stream. It allows you to start iterating from a time in the past.
View kinesis-get-records.sh
#!/usr/bin/env bash
if ! aws_bin="$(which aws)" 2>/dev/null; then
echo "aws cli is missing; you can get it from https://aws.amazon.com/cli/"
exit 1
fi
if ! jq_bin="$(which jq)" 2>/dev/null; then
echo "jq is missing; you can get it from https://stedolan.github.io/jq/"
exit 1
@codemedic
codemedic / upload.sh
Created Jan 16, 2018
Uploading files to S3 via bash with minimum deps (curl, openssl, base64)
View upload.sh
#!/bin/bash
file="$1"
region="eu-west-1"
key_id="YOUR-AWS-KEY-ID"
key_secret="YOUR-AWS-KEY-SECRET"
path="some-directory/$file"
bucket="s3-bucket-name"
content_type="application/octet-stream"
date="$(LC_ALL=C date -u +"%a, %d %b %Y %X %z")"
@codemedic
codemedic / git-build-rpm.sh
Created Aug 21, 2017
Build RPM from a git repo that uses git-flow (AVH)
View git-build-rpm.sh
#!/bin/bash
: "${branch:="$(git rev-parse --abbrev-ref HEAD)"}"
: "${tag_or_branch:="$branch"}"
spec=( *spec )
spec=${spec%%.spec}
# Relies on git-describe being functional; so git-flow AVH edition is essential
version="$(git describe --abbrev=0 "$branch")"
View clion64.vmoptions
-server
-Xms1G
-Xmx3072m
-Xss2m
-XX:MaxMetaspaceSize=1536m
-XX:ReservedCodeCacheSize=240m
-XX:MetaspaceSize=512m
-XX:+DoEscapeAnalysis
-XX:SoftRefLRUPolicyMSPerMB=50
-XX:+UnlockExperimentalVMOptions
You can’t perform that action at this time.