Skip to content

Instantly share code, notes, and snippets.

View omaraboumrad's full-sized avatar

Omar Abou Mrad omaraboumrad

View GitHub Profile
@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 / 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 / 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.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 / 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 / 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 / contracts.py
Created April 24, 2014 09:54
poor man's contracts
class Entity(object):
def __init__(self, name):
self.name = name
class Powered(object):
def is_on(self):
return self.state == 'on'
class Machine(Entity, Powered):
def __init__(self, name, state):
@omaraboumrad
omaraboumrad / index.html
Created February 21, 2014 12:19
d3 consume api and build document
<!doctype html>
<html>
<head>
<title>Reddit JSON</title>
<style>
body{ background-color: #C6C6C6; }
#content div {
border: 1px solid #000000;
margin: 5px;
padding: 5px;
@omaraboumrad
omaraboumrad / index.html
Last active August 29, 2015 13:56
d3 build form dynamically
<!doctype html>
<html>
<head>
<title>Sup</title>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script type="text/javascript">
window.onload = function(){
var schema = {
fields: [
{name: 'first_name', type: 'text', display: 'First Name'},
import operator
import collections
class Rule(object):
def __init__(self, logic, left=None, right=None, op=None, inv=False):
self.logic = logic
self.left = left
self.right = right
self.op = op
self.inv = inv