Skip to content

Instantly share code, notes, and snippets.

View omaraboumrad's full-sized avatar

Omar Abou Mrad omaraboumrad

View GitHub Profile
@omaraboumrad
omaraboumrad / astlookup.py
Last active October 9, 2015 08:11
Run static checks through various ast paths
import sys
import ast
is_if = lambda s: isinstance(s, ast.If)
is_for = lambda s: isinstance(s, ast.For)
is_call = lambda s: isinstance(s, ast.Call)
call_name_is = lambda s, n: is_call(s) and hasattr(s.func, 'attr') and s.func.attr == n
has_else = lambda s: is_if(s) and len(s.orelse) > 0
is_return = lambda s: isinstance(s, ast.Return)
is_name = lambda s: isinstance(s, ast.Name)
@omaraboumrad
omaraboumrad / main.lua
Last active August 29, 2015 14:08
Pixel clone of Flappy bird using Love2d
function love.load()
reset()
topscore = 0
local font = love.graphics.newFont(24)
love.graphics.setFont(font)
end
function reset()
x = 60
y = love.window.getHeight()/2
@omaraboumrad
omaraboumrad / chat.html
Created February 16, 2015 14:28
Experimenting with websocketd
<!DOCTYPE html>
<html>
<head>
<title>Chat!</title>
<style>
</style>
</head>
<body>
<ul id="messages"></ul>
@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 / foldtext.vim
Created November 5, 2015 08:09
light vim fold text
" class Foo(Bar): │
" └── [ 13 ] ────•
set fillchars="fold: "
setlocal foldtext=ManualFillCharText()
function! ManualFillCharText()
" TODO: make it support the tabs/spaces/different width
let total = (v:foldend - v:foldstart)
@omaraboumrad
omaraboumrad / .inputrc
Last active November 17, 2015 10:11
Enable reverse search in OSX's default python
bind "^R" em-inc-search-prev
@omaraboumrad
omaraboumrad / sample.py
Last active January 2, 2016 08:18
http url router
from toll import run, Toll
app = Toll(__name__)
@app.route(r'^/$')
def index():
return 'Hello World'
@omaraboumrad
omaraboumrad / bot.go
Created January 2, 2016 08:16
irc bot in golang
package main
import (
"bufio"
"fmt"
"gopkg.in/ini.v1"
"net"
"os"
"regexp"
"strings"
@omaraboumrad
omaraboumrad / checkdependents.py
Created February 26, 2016 10:11
Check pip dependants instead of requires
# Invert all requirements: python checkdependents.py
# View specific: python checkdependents.py somepackage
import collections
import sys
import pip
def invert_dependencies_graph(distributions):
packages = collections.defaultdict(list)
@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.