Skip to content

Instantly share code, notes, and snippets.

View madzak's full-sized avatar

Zakaria Zajac madzak

View GitHub Profile
@madzak
madzak / router.php
Last active August 29, 2015 13:56
Router for light PHP applications
<?php
// router.php
if (0 === strpos($_SERVER['REQUEST_URI'], '/bower_components/')) {
$this_page = $_SERVER['REQUEST_URI'];
if (strpos($this_page, "?") !== false) {
$exploded = explode("?", $this_page);
$this_page = reset($exploded);
}
readfile('..' . $this_page);
@madzak
madzak / original.js
Created February 18, 2014 16:53
Jquery Conversion
$(function(){
$('#variations-test .swatches a').hover(function(){
$('#variations-test .variation-color').html( $(this).attr('data-color') );
}, function() {
$('#variations-test .variation-color').html( $('#variations-test .swatches a.active').attr('data-color') );
});
});
@madzak
madzak / closure_and_scoping.js
Last active May 2, 2022 08:57
Javascript Interview Questions
/* Closures and Scoping */
!function(window) {
var body = window.getElementsByTagName('body')[0];
console.log(body);
}(document);
/*
Q: What would you expect the value of body to be?
var cards = document.querySelectorAll("section.game div.bottom"),
matches = {};
for(var i=0;i<cards.length;i++) {
var item = cards[i].className.split(" ")[1];
if(matches[item]) {
matches[item].click();
cards[i].click();
@madzak
madzak / .gitignore
Last active January 6, 2019 23:22
Sample Application using Module, Facade, and Mediator Patterns
*.swp
@madzak
madzak / facade_pattern.html
Last active December 16, 2015 13:59
Pattern Examples
<html>
<head>
<title>Facade Pattern</title>
</head>
<body>
<h1>Facade Pattern Example</h1>
<script type="text/javascript">
!function (window, document) {
var module = window.module = {},
@madzak
madzak / Lemmings Game Hack
Created January 24, 2013 01:35
I hacked the 404 page with some client side javascript - http://www.romainbrasier.fr/404.php?lang=en
function hoverImage($image){
var images = $('img');
if(images == 1) {
clearTimeout(hoverImage);
}
for(var i=0,len=images.length;i<len;i=i+1) {
$(images[i]).trigger("mouseenter")
}
setTimeout(hoverImage,100);
};
@madzak
madzak / Blueprint with DB.txt
Created November 2, 2012 17:22
Blueprint with DB
#!/usr/bin/env python
# coding=utf8
from flask import Blueprint, current_app
from flask.ext.sqlalchemy import SQLAlchemy
app = current_app
db = SQLAlchemy(app)
class Block(db.Model):
@madzak
madzak / xcode_gems
Created October 8, 2012 18:48
Xcode Handy Snippets
# Show View Hicharchy
po [[UIWindow keyWindow] recursiveDescription]
@madzak
madzak / Email Remark
Created January 31, 2012 17:41
Can we make this more offensive?
I think it is unreasonable to have a lower level engineer make design changes which violate the key design intent of the Senior Principal Enterprise architect and one of our most senior principals and I do not think we should proliferate multiple implementations.