Skip to content

Instantly share code, notes, and snippets.

View mos3abof's full-sized avatar

Mosab Ibrahim mos3abof

View GitHub Profile
@mos3abof
mos3abof / qt-fix.sh
Last active June 25, 2019 16:55
Fix qt @ version 5.5, after an accidental brew upgrade
#!/usr/bin/env bash
cd $( brew --prefix )/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
if [[ -e qt@5.5.rb ]]; then
mv qt@5.5.rb qt@5.5.rb.bkp
fi
wget -q https://raw.githubusercontent.com/Homebrew/homebrew-core/9ba3d6ef8891e5c15dbdc9333f857b13711d4e97/Formula/qt@5.5.rb
# delete line 25
@mos3abof
mos3abof / git-flow-multi-hotfix.sh
Last active August 2, 2018 11:06
Allow git-flow to have more than one hotfix branch at a time
git config --global --add gitflow.multi-hotfix true
@mos3abof
mos3abof / ps-ef.bash
Created July 3, 2018 21:46
PID 0, PID 1, and PID 2 in linux.
mosab@debian:~$ ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 22:53 ? 00:00:01 /sbin/init
root 2 0 0 22:53 ? 00:00:00 [kthreadd]
@mos3abof
mos3abof / palindrome.py
Last active April 28, 2018 19:37
Function to determine whether a string is a palindrome
def is_palindrome(s):
return all(s[i] == s[~i] for i in range(len(s) // 2))
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#@author Mosab Ahmad <mosab.ahmad@gmail.com>
import os
import sys
import config
import requests
import traceback
@mos3abof
mos3abof / soundcloud-perspective.py
Created March 30, 2016 00:04
Some Soundcloud Perspective XKCD Style
import matplotlib.pyplot as plt
with plt.xkcd():
fig = plt.figure()
ax = fig.add_axes((0.1, 0.2, 0.8, 0.7))
ax.bar([-0.125, 1.0 - (5 * 0.125), 1.0 - 0.125], [10, 50, 250], 0.25)
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.set_xticks([0, 0.5, 1])

Renaming multiple files at once in linux:

$ cd /path/to/files $ rename 's/-mIF-/-mImpFRA-/' *

<?php
/**
* A quick solution for the question in this blog post:
* http://www.thousandtyone.com/blog/EasierThanFizzBuzzWhyCantProgrammersPrint100To1.aspx
*
* Took me 30 seconds, without the comments.
*
* The problem:
* Print 100 to 1.
* You need to start with "for(int i=0;" and continue from there.
@mos3abof
mos3abof / 100_countdown.c
Last active August 29, 2015 14:18
Count down from 100 to 1
/**
* A quick solution for the question in this blog post:
* http://www.thousandtyone.com/blog/EasierThanFizzBuzzWhyCantProgrammersPrint100To1.aspx
*
* Took me 30 seconds, without the comments.
*
* The problem:
* Print 100 to 1.
* You need to start with "for(int i=0;" and continue from there.
* You cannot write anything before "for(int i=0;".
@mos3abof
mos3abof / organize_movie_files.py
Created December 13, 2014 15:27
Removes any non-alphanumeric characters, chacnges cases to lower cases and spaces to dots.
#!/usr/bin/python
# -*- coding: utf-8 -*-
#@author Mosab Ahmad <mosab.ahmad@gmail.com>
import os
import re
MOVIES_PATH = '/home/mosab/Videos/youtube'