Skip to content

Instantly share code, notes, and snippets.

View ahmedsakr's full-sized avatar
💻
Coding from home

Ahmed Sakr ahmedsakr

💻
Coding from home
  • Wealthsimple
  • Ottawa, ON, Canada
View GitHub Profile
@ahmedsakr
ahmedsakr / stickman.py
Created February 25, 2015 14:19
stickman game!
import random
import sys
# parallel lists, potential_words & potential_words_type. The word and it's type respectively.
potential_words = ["League of legends", "Gone Girl", "Runescape"]
potential_words_type = ["Game", "Movie", "Game"]
letters_to_guess = {}
# revealed_indicies list is used to check whether the certain index of the word has been guessed
@ahmedsakr
ahmedsakr / transform.js
Created August 1, 2020 16:19
Implementation of transform.js for the simple MD5 Hash application
// ES6 import right from node modules
// Parcel js will take care of bundling this for us so it's web ready.
import md5 from 'md5'
export function transform() {
document.getElementById('md5-output').value = md5(document.getElementById('md5-input').value);
}
@ahmedsakr
ahmedsakr / NumberTuple.py
Created August 3, 2020 04:16
A class that extends the immutable tuple
class NumberTuple(tuple):
'''
NumberTuple is a tuple class that wishes to convert
string number to a tuple.
'''
def __init__(self, number):
'''
While our goal is to convert the string number
@ahmedsakr
ahmedsakr / Medium.py
Created August 3, 2020 04:38
A simple approach to overriding string output of an object
class Medium(object):
def __init__(self, username, age, interests):
self.username = username
self.age = age
self.interests = interests
def __str__(self):
'''
We swap the default string output of this class with an informative
@ahmedsakr
ahmedsakr / Medium.py
Created August 3, 2020 04:53
An example showcasing the need for developer friendly messages
class Medium(object):
def __init__(self, username, age, interests):
self.username = username
self.age = age
self.interal_id=2939
self.interests = interests
def __str__(self):
'''
@ahmedsakr
ahmedsakr / DPVector.py
Created August 3, 2020 05:06
Overriding default __mul__ class implementation
class DPVector(tuple):
'''
Dot Product (DP) Vector class that overrides the __mul__
implementation to perform dot product operation!
'''
def __init__(self, tup):
self.tup = tup
def __mul__(self, other):
'''
@ahmedsakr
ahmedsakr / style.scss
Created August 6, 2020 04:30
Stylesheet for rfs demo
@import "./node_modules/rfs/scss.scss";
body {
margin: 0;
}
#content-container {
display: flex;
height: 100vh;
flex-direction: column;
@ahmedsakr
ahmedsakr / requestFortune.js
Last active August 9, 2020 01:05
requestFortune lambda for the Fortune Cookie Serverless application
const fortunes = [
"A beautiful, smart, and loving person will be coming into your life.",
"A dubious friend may be an enemy in camouflage.",
"A faithful friend is a strong defense.",
"A feather in the hand is better than a bird in the air.",
"A fresh start will put you on your way.",
"A friend asks only for your time not your money."
];
/**
@ahmedsakr
ahmedsakr / fortune.js
Last active August 9, 2020 01:34
Handler for requesting a fortune
export function requestFortune() {
fetch('https://a9vymko126.execute-api.ca-central-1.amazonaws.com/test', { method: "GET" })
.then(response => response.json())
.then(data => document.getElementById('fortune-text').innerHTML = data)
}
@ahmedsakr
ahmedsakr / aws.yml
Created August 9, 2020 01:44
YAML file for uploading lambda to AWS
service: FortuneCookie
provider:
name: aws
runtime: nodejs12.x
profile: myaws
region: ca-central-1
stackName: fortune-backend
package: