Skip to content

Instantly share code, notes, and snippets.

View omaraboumrad's full-sized avatar

Omar Abou Mrad omaraboumrad

View GitHub Profile
@omaraboumrad
omaraboumrad / wiki.md
Last active January 6, 2024 17:08
How to contribute to a GitHub Project's Wiki

Setup

Assuming project is SOME/PROJECT And you are FOO

You will need to do the following one time only:

@omaraboumrad
omaraboumrad / splitlogs.py
Created October 6, 2017 14:18
View docker-compose services logs in split tmux panes
# Requires pyyaml
import os
import yaml
run = os.system
new_window = lambda cmd: run('tmux new-window -n "logs" "{}"'.format(cmd))
split_vertical = lambda cmd: run('tmux split-window "{}"'.format(cmd))
split_horizontal = lambda cmd: run('tmux split-window -h "{}"'.format(cmd))
even_vertical = lambda: run('tmux select-layout even-vertical')
@omaraboumrad
omaraboumrad / matrix
Created September 29, 2015 10:18
tmux with cmatrix
#!/bin/bash
# make sure cmatrix is installed
# make sure tmux is installed
# $ chmod 755 matrix
# $ ./matrix
SESSION=$USER
tmux -2 new-session -d -s $SESSION 'cmatrix'
@omaraboumrad
omaraboumrad / chat_cli.py
Last active June 1, 2018 08:53
curses chat ui
import curses
(NORMAL, GREEN, RED, YELLOW, BLUE) = range(1,6)
(BUSY, AVAILABLE, IDLE) = (RED, GREEN, YELLOW)
WIN_CONTACTLIST_X = 0
WIN_CONTACTLIST_Y = 0
WIN_CONTACTLIST_WIDTH = 28
WIN_CONTACTLIST_HEIGHT = 0
@omaraboumrad
omaraboumrad / fiddle.js
Last active May 30, 2018 13:45
character jumping
window.onload = init;
function init(){
var ImageLoader = function(args, callback){
// Usage: new ImageLoader({
// 'img1':'/url/to/img1',
// 'img2':'/url/to/img2',}, cb);
// Returns: {'img1': [Image], 'img2': [Image]}
@omaraboumrad
omaraboumrad / fiddle.js
Last active December 23, 2016 05:23
sprite management w/ sample
window.onload = init;
function init(){
// -- Sprite Management Api -- //
var rectangular_intersection = function(r1, r2){
var t1 = [r1[0], r1[0] + r1[2], r1[1], r1[1] + r1[3]];
var t2 = [r2[0], r2[0] + r2[2], r2[1], r2[1] + r2[3]];
return !(t2[0] > t1[1] ||
t2[1] < t1[0] ||
t2[2] > t1[3] ||
@omaraboumrad
omaraboumrad / config.json
Last active December 20, 2016 11:21
irc bot written in javascript for nodejs
{
"nickname": "xnodeuser",
"username": "xnodeuser",
"hostname": "myhost",
"servername": "myserver",
"realname": "xnodeuser",
"channel": "#xnodeuser"
}
@omaraboumrad
omaraboumrad / TransitionButton.java
Created November 18, 2016 14:49
android declarative activity transition
package info.aboumrad.transitiontest;
import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class TransitionButton extends Button {
@omaraboumrad
omaraboumrad / visualize.py
Last active October 28, 2016 13:45
Create a block diagram from a python class hierarchy using blockdiag
"""
Dependencies: pip install blockdiag
Run: python visualize.py
"""
from blockdiag import parser, builder, drawer
TEMPLATE = """
blockdiag {{ orientation = portrait
{}
@omaraboumrad
omaraboumrad / git-cdiff
Last active June 16, 2016 13:40
GitHub-like commit differences
#!/usr/bin/env python
"""
Checks the commit difference between current branch and target branch
a la GitHub.
Usage:
$ git cdiff upstream/master
This branch is 5 commits ahead, 10 commits behind upstream/master.