Skip to content

Instantly share code, notes, and snippets.


Ayman Farhat aymanfarhat

Block or report user

Report or block aymanfarhat

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
aymanfarhat / Euler 18.cs
Created Sep 9, 2012
Project Euler Problem 18
View Euler 18.cs
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)
aymanfarhat /
Created Jan 4, 2013
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))
aymanfarhat / String.format.js
Created Jan 6, 2013
Simple implementation of C#'s String.format() in Javascript for building strings
View String.format.js
String.prototype.format = function()
var args = arguments;
return this.replace(/{(\d+)}/g, function(match, number)
return typeof args[number] != 'undefined'? args[number]:match;
# 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 / tomorrow-night-eighties.css
Created Apr 10, 2013
An edit of for styling code tags that are not necessarily within a pre tag, useful for inline code highlighting.
View tomorrow-night-eighties.css
/* Tomorrow Night Eighties Theme */
/* Original theme - */
/* */
/* Edited by Ayman Farhat( 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 / urlobject.js
Last active Jul 27, 2017
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
View urlobject.js
function urlObject(options) {
"use strict";
/*global window, document*/
var url_search_arr,
aymanfarhat / index.js
Last active Dec 18, 2015
SwipyJS with Fries integration
View index.js
/** JS of the index **/
var data = $('#dev_list').html();
for(var i = 0; i < 10; i++)
/* Tab swiping init and next/prev functions */
def get_total(n,p):
if n < p:
return 0
elif n == p:
return 1
return 1 + get_total(n-2,p)
n = int(raw_input("money:"))
aymanfarhat /
Last active May 25, 2020
Implementation of Karger's algorithm in Python. Randomized algorithm for computing minimum cuts in a connected graph. Input file source is Coursera's Algo 1 course HW3:
import re
import random
# Load the file into a graph represented by a dict of lists
def load_graph():
g = {}
f = open('kargerMinCut.txt')
lines = f.readlines()
f = open('input.txt')
lines = f.readlines()
lines = list(map(lambda x: int(x.strip()), lines))
d = {}
found = {}
for line in lines:
if line in d:
You can’t perform that action at this time.