Skip to content

Instantly share code, notes, and snippets.

View aymanfarhat's full-sized avatar
🏠
Working from home

Ayman Farhat aymanfarhat

🏠
Working from home
View GitHub Profile
@aymanfarhat
aymanfarhat / urlobject.js
Last active July 27, 2017 00:04
JS utility function that: - Breaks down url to an object with accessible properties: protocol, parameters object, host, hash, etc... - Converts url parameters to key/value pairs - Convert parameter numeric values to their base types instead of strings - Store multiple values of a parameter in an array - Unescape parameter values
function urlObject(options) {
"use strict";
/*global window, document*/
var url_search_arr,
option_key,
i,
urlObj,
get_param,
key,
@aymanfarhat
aymanfarhat / tomorrow-night-eighties.css
Created April 10, 2013 15:01
An edit of https://github.com/isagalaev/highlight.js/blob/master/src/styles/tomorrow-night-eighties.css for styling code tags that are not necessarily within a pre tag, useful for inline code highlighting.
/* Tomorrow Night Eighties Theme */
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */
/* Edited by Ayman Farhat(http://aymanfarhat.com) for supporting inline code tags without pre */
.tomorrow-comment, code .comment, code .title {
color: #999999;
}
.tomorrow-red, code .variable, code .attribute, code .tag, code .regexp, code .ruby .constant, code .xml .tag .title, code .xml .pi, code .xml .doctype, code .html .doctype, code .css .id, code .css .class, code .css .pseudo {
color: #f2777a;
@aymanfarhat
aymanfarhat / CodeJamQ_2009_A.py
Last active December 15, 2015 15:39
Google Code Jam 2009 - Qualification Round Problem A https://code.google.com/codejam/contest/90101/dashboard
# Parses each string patterns to list of strings and lists(options)
def parse_patterns(patterns):
lines = []
def getclosing(i,pattern):
for x in xrange(i,len(pattern)):
if pattern[x] == ")":
return x
return -1
@aymanfarhat
aymanfarhat / String.format.js
Created January 6, 2013 14:31
Simple implementation of C#'s String.format() in Javascript for building strings
String.prototype.format = function()
{
var args = arguments;
return this.replace(/{(\d+)}/g, function(match, number)
{
return typeof args[number] != 'undefined'? args[number]:match;
});
};
@aymanfarhat
aymanfarhat / Intersection.py
Created January 4, 2013 19:52
Set Intersection algorithm O(nlogn) time. Code in Python.
from itertools import chain
intersection = []
sets = [[0,4,5,2,1],[1,3,6,2,4],[4,1,2,5,7,0]]
merged = list(chain.from_iterable(sets))
merged.sort()
@aymanfarhat
aymanfarhat / Euler 18.cs
Created September 9, 2012 16:49
Project Euler Problem 18
class Program
{
/* The triangle */
static int[][] triangle = null;
/* Saves respective optimal sums of nodes in the triangle */
static int[][] optimalSums = null;
static void Main(string[] args)
{