Skip to content

Instantly share code, notes, and snippets.

@noureddin
noureddin / youtube-shelf-dl
Created July 29, 2017 18:29
Download a shelf of playlists from Youtube
#!/usr/bin/env perl
# Download a shelf of playlists from Youtube
# using wget, perl and youtube-dl.
# After using it, you'll find folders with the playlists'
# names, and each has a file named '.get'. Issue `. .get`
# in your terminal to start downloading the playlist.
# You can run `for i in *; do cd "$i"; . .get; cd ..; done`
# to get them all after this script.
# License: CC0
@noureddin
noureddin / get_linux_voice.sh
Created March 22, 2017 18:13
Download Linux Voice magazines and optimize them for screens
#!/bin/bash
# Download Linux Voice magazines and optimize them for screens
# which makes them less than half in size
get_issue() {
temp_file=Linux-Voice-Issue-0$1_.pdf
final_file=Linux-Voice-Issue-0$1.pdf
[ -e $final_file ] && return
wget -qc --show-progress -O $temp_file \
https://www.linuxvoice.com/issues/0$1/Linux-Voice-Issue-0$1.pdf &&
ps2pdf -dSETTING=/ebook $temp_file $final_file &&
@noureddin
noureddin / frequency-counter.sh
Last active March 12, 2017 03:46
Letters and letter combinations frequency counter in POSIX shell
#!/bin/sh
## Introduction
# This script calculates the frequencies of letters and letter combinations (monograms, bigrams, trigrams) in a given text. The frequency is given as the percentage of occurrences.
# This script is language- and script-agnostic; it should work with any script whatsoever (it's tested with Arabic). It's written in POSIX sh, and uses Unix tools, so it should work on most OSes. Please note it's case-sensitive.
# This script is licensed under the terms of CC0. Attribution is really appreciated but not required.
# Contact the author at noureddin@protonmail.com or noureddin95@gmail.com
# defining a function that changes the numbered output of `uniq -c | sort -nr` to percentage
numbered2percent()
@noureddin
noureddin / dvqw.py
Created February 27, 2017 16:28
Dvorak-QWERTY Converter
#!/usr/bin/python3
# translate dvorak to qwetry and vice versa
# thank you, tr; you're useless to me!
# usage:
# run it, and input a line of dvorak-encoded text, then press enter to get the qwerty-decoded one
# run it with any argument, and input a line of qwerty, then press enter to get dvorak
h = {}
h[']'] = '/'; h['}'] = '+'
@noureddin
noureddin / fullcircle-downloader.sh
Created January 29, 2017 19:33
FullCircle magazine downloader
#!/bin/bash
if [ -z "$1" ]; then
wget -qc --show-progress http://dl.fullcirclemagazine.org/issue{117..0}_en.pdf 2>/dev/null
else
wget -qc --show-progress http://dl.fullcirclemagazine.org/issue${1}_en.pdf
fi
@noureddin
noureddin / egist.sh
Created January 29, 2017 06:26
Edit GIST
#!/bin/bash
# edit a gist file contents: https://developer.github.com/v3/gists/#edit-a-gist
# based on https://gist.github.com/noureddin/93d6182acdd1dcdf880daee1b97af05f
GITHUB_USERNAME=noureddin # change this to your github username
if [ $# -lt 2 ]; then
printf "Usage: %s id filename [gistname]\n" $(basename "$0") >&2
exit 1 # exit with error
fi
\documentclass{report}
\usepackage{caption}
\usepackage{polyglossia}
\setmainlanguage{arabic}
\newfontfamily\arabicfont[Script=Arabic,Scale=1]{KacstOne}
% https://tex.stackexchange.com/questions/350777/side-by-side-figures-are-reversed-in-lof-bidi-xetex
\newcommand{\dblimg}
[7][ht]{{%
\stepcounter{figure}
@noureddin
noureddin / pgist.sh
Last active March 12, 2019 17:40 — forked from rubo77/create-gist.sh
Post GIST
#!/bin/bash
GITHUB_USERNAME=noureddin # change this to your github username
# or see https://gist.github.com/s-leroux/7cb7424d33ba3753e907cc2553bcd1ba
if [ "$1" == "" ]; then
printf "Usage: %s [--public] filename [gistname]\n" $(basename "$0") >&2
exit 1 # exit with error
fi