Skip to content

Instantly share code, notes, and snippets.

View Zabanaa's full-sized avatar
Liverpool will not win the league. (You've read it here first)

Karim Cheurfi Zabanaa

Liverpool will not win the league. (You've read it here first)
View GitHub Profile
@Zabanaa
Zabanaa / idiomatic.py
Created January 15, 2017 14:07
Tricks to write better, more efficient and beautiful code in python
# 0 - Loop over a range of numbers
# Use range instead of xrange
# Range in python 3 creates an iterator which produces the values one at a time (it's much more efficient and fast)
nums = [0,2, 34, 55, 32]
for i in range(nums):
print i
# 1 - Looping backwards
# Use reversed
@Zabanaa
Zabanaa / compare.js
Created November 25, 2016 10:52
Object comparison in Javascript
// Based on: http://stackoverflow.com/questions/14368596/how-can-i-check-that-two-objects-have-the-same-set-of-property-names
Object.prototype.isIdenticalTo = function(targetObject) {
// check that targetObject is an object
// if no argument is passed and it's not an object
// throw an error
if (!targetObject || typeof(targetObject) !== "object") {
throw new Error("Argument of type Object must be passed")
}
@Zabanaa
Zabanaa / composition.py
Created November 14, 2016 13:05
Composition vs Inheritance
# Main client class
# Makes the credentials available to the other classes
# In this scenario, User uses or has an API, but it isn't an API
# So we don't really need to inherit from the client class (Dribbble_API)
class Dribbble_API(object):
def __init__(self, client_id=None, client_secret=None, access_token=None):
self.client_id = client_id
@Zabanaa
Zabanaa / fsq-cli.py
Created July 28, 2016 07:54
CLI wrapper around the foursquare API. It can be used to fetch geographical data about venues or groups of venues. (GET only)
import argparse
import requests
import webbrowser
ROOT_URL = "https://api.foursquare.com/v2/venues/"
parser = argparse.ArgumentParser(description="Wrapper around the foursquare API. Use it to retrieve information about\
specific venues or groups of venues.")
parser.add_argument("endpoint", help="Name of the resource you want to access", choices=["categories", "trending",\
"explore", "search"])
@Zabanaa
Zabanaa / object-assign.js
Created June 25, 2016 18:22
Just playing around with object.assign
(function(){
window.Player = function(config = {}){
this.defaults = {
name: "Karim Benzema",
age: 29,
position: "CF",
club: "Real Madrid CF"
}
@Zabanaa
Zabanaa / stocks.py
Created December 3, 2015 22:19
First stab at creating a web crawler using requests and beautiful soup
# This script will attempt to fetch data from Yahoo finance for a particular
# stock, get the prices for the last 6 months and save the info to a csv file
import requests
from bs4 import BeautifulSoup
import csv
import time
def get_prices(url):
print("Fetching Prices ...")
@Zabanaa
Zabanaa / SassMeister-input.scss
Created October 8, 2015 16:46
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
.guide-block__item {
flex: 0 1 100%;
height: auto;
$count: 1;
// **** ANIMATION **** //
// zerosixthree
=animation($str)
-webkit-animation: #{$str}
-moz-animation: #{$str}
-ms-animation: #{$str}
-o-animation: #{$str}
animation: #{$str}
@Zabanaa
Zabanaa / pomodoro-codebar.js
Last active August 29, 2015 14:27
Codebar fix for the timer
// Pomodoro Module
var PomodoroApp = (function() {
var pomodoro = {
countDown: false,
minutesLeft: false,
secondsLeft: false,
endFunction: false
};
@Zabanaa
Zabanaa / pom.js
Created August 17, 2015 16:19
New pomodoro hahah
<script>
// Create a counter to check how many times the function was called
var numberSessionsDone = 0;
var initialTime = 25;
var output = document.getElementById('output');
// this is the countDown timer
function runSession(timeInMinutes, endFunction) {