Skip to content

Instantly share code, notes, and snippets.

View omaraboumrad's full-sized avatar

Omar Abou Mrad omaraboumrad

View GitHub Profile
@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
Created October 19, 2013 15:24
Parallax scrolling
window.onload = init;
function init(){
var canvas = document.createElement('canvas');
document.body.appendChild(canvas);
canvas.width = 400;
canvas.height = 400;
var ctx = canvas.getContext('2d');
@omaraboumrad
omaraboumrad / fiddle.html
Created October 19, 2013 15:34
space glider
<audio autoplay loop>
<source src="https://dl.dropboxusercontent.com/u/18982788/starwars.mp3" />
</audio>
@omaraboumrad
omaraboumrad / fiddle.css
Last active December 25, 2015 23:29
space shooter
p{
font-family: verdana;
font-size: 12px;
}
@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 / fiddle.html
Last active December 25, 2015 23:39
sprite management w/ test
<div id="qunit"></div>
<div id="qunit-fixture"></div>
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
@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'},
@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 / 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):