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 / index.js
Last active December 18, 2015 09:49
SwipyJS with Fries integration
/** JS of the index **/
(function(){
var data = $('#dev_list').html();
for(var i = 0; i < 10; i++)
$("#dev_list").append(data);
/* Tab swiping init and next/prev functions */
def get_total(n,p):
if n < p:
return 0
elif n == p:
return 1
else:
return 1 + get_total(n-2,p)
n = int(raw_input("money:"))
f = open('input.txt')
lines = f.readlines()
lines = list(map(lambda x: int(x.strip()), lines))
f.close()
d = {}
found = {}
for line in lines:
if line in d:
@aymanfarhat
aymanfarhat / YoutubeAPIHelper.php
Created October 9, 2013 14:03
Youtube public API wrapper in PHP
class YoutubePublicAPI {
// Developers key to access the API
private $key;
private $base_url = "https://www.googleapis.com/youtube/v3/";
public function __construct($params){
$this->key = $params["key"];
}
var client = new DBClient();
var db = client.setDatabase("test"); // If test doesnt exist creates it
var collection = db.getCollection("coll");
// Find documents in a collection that match criteria
collection.selectDoc({name:"ayman"},function(data){
// Callback for accessing and managing the returned data
});
var async = function(func,callback){
return function(){
var args = arguments;
setTimeout(function(){
var values = func.apply(this, args);
callback.call(this, values);
}, 0);
};
};
// http://paulirish.com/2011/requestanimationframe-for-smart-animating
// shim later with setTimeout fallback
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function( callback ){
window.setTimeout(callback, 1000 / 60);
{
"title":"Tool Title",
"description": "Tool Description",
"version": "",
"author": {
"name":"",
"email":"",
"website":""
},
"repository_url": "",
@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 / 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()