Skip to content

Instantly share code, notes, and snippets.

View mustafa-zidan's full-sized avatar

Mustafa Zidan Abuelfadl mustafa-zidan

View GitHub Profile
@mustafa-zidan
mustafa-zidan / search_insert.go
Created February 24, 2020 19:59
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
func searchInsert(nums []int, target int) int {
start, end := 0, len(nums)
if len(nums) == 0 || target < nums[start] {
return 0
} else if target > nums[end-1] {
return len(nums)
}
return getIndex(start, end, target, nums)
}
Verifying my Blockstack ID is secured with the address 1GpkKb47RaF5beufPCUQ52tx2gzmE4kCcu https://explorer.blockstack.org/address/1GpkKb47RaF5beufPCUQ52tx2gzmE4kCcu
package com.hawkai;
import java.util.*;
/*
* Refactor following code to get clean, readable code without coding smells.
*
* Hints:
* There is nothing wrong with this code in terms of functionality.
@mustafa-zidan
mustafa-zidan / frequency.py
Last active September 24, 2018 07:12
Code challenge solution for Finway
import argparse
# from nltk.corpus import stopwords
# stop_words = set(stopwords.words('english'))
def word_frequency(file_name):
frequency = {}
with open(file_name, "r") as lines:
for line in lines:
# With each line we need to trimmed, stemmed
@mustafa-zidan
mustafa-zidan / largest-prime-factor.scala
Created November 6, 2016 20:50
problem #3 in projecteuler to find the largest prime factor using sieve segmentation and scala streams
def sieve(s: Stream[Long]): Stream[Long] = s.head #:: sieve(s.tail filter (_ % s.head != 0))
def from(n: Long): Stream[Long] = n #:: from(n + 1)
def primes = sieve(from(2))
def largest(x: Long, p: Stream[Long]):Long = {
if (x <= p.head) x
else if (x % p.head == 0) largest(x / p.head, p)
else largest(x,p.tail)
@mustafa-zidan
mustafa-zidan / security_interceptor.js
Last active August 29, 2015 14:10
Security interceptor
/**
Private module, a utility, required internally by 'http-auth-interceptor'.
*/
window.interceptors.factory("httpBuffer", [
"$injector", function($injector) {
var ApiService, buffer, retryHttpRequest;
retryHttpRequest = function(config, deferred) {
var ApiService, errorCallback, successCallback;
successCallback = function(response) {

HTML5 Editable Table

Create and edit an HTML5 table without the use of a library. Uses HTML5's contenteditable and minimal JavaScript.

Forked from Ash Blue's Pen HTML5 Editable Table.

Using Foundation instead of bootstrap

A Pen by Mustafa Zidan on CodePen.

Keybase proof

I hereby claim:

  • I am mustafa-zidan on github.
  • I am mustafazidan (https://keybase.io/mustafazidan) on keybase.
  • I have a public key whose fingerprint is 7F98 9852 585F ACAC 8A38 06F8 0338 EBFB 5961 0CBB

To claim this, I am signing this object:

@mustafa-zidan
mustafa-zidan / dynamicarray.cpp
Created November 3, 2013 09:47
C++ implementation to Dynamic Array Data Structure.
#include "dynamicarray.h"
DynamicArray::DynamicArray() {
DynamicArray::DynamicArray(5);
}
DynamicArray::DynamicArray(int initSize){
size = initSize;
int* arr = (int *) malloc(sizeof(int) * initSize);
}