Skip to content

Instantly share code, notes, and snippets.

View mohamedelshorbagy's full-sized avatar

mohamedelshorbagy

View GitHub Profile
@mohamedelshorbagy
mohamedelshorbagy / app.component.ts
Created October 8, 2019 11:19
Debounce Event using EventManagerPlugin
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: `
<div class="ui container">
<hr>
<div class="ui input">
<input type="text" (input.debounce.1000)="search($event)">
</div>
export function autoUnsubscribe(subscriptions: string[] = []) {
return (componentType) => {
const orgFactory = componentType.ngComponentDef.factory;
componentType.ngComponentDef.factory = (...args) => {
const component = orgFactory(...args);
componentType.ngComponentDef.onDestroy = () => {
if (component.ngOnDestroy) {
component.ngOnDestroy();
This file has been truncated, but you can view the full file.
<!DOCTYPE html>
<html>
<head><meta charset="utf-8" />
<title>Assignment 2</title><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<style type="text/css">
/*!
*
function base64ToUint8Array(base64String) {
let raw = atob(base64String);
let uint8Array = new Uint8Array(raw.length);
for (let i = 0; i < raw.length; i++) {
uint8Array[i] = raw.charCodeAt(i);
}
let pdfSrc = unit8Array;
return pdfSrc;
}
@mohamedelshorbagy
mohamedelshorbagy / data.js
Created March 4, 2019 15:50
Get all imports in a file including [import, require] , get the basic export
import { data } from 'data';
const fs = require('fs');
const d = require('babylon')
export { config, data };
This file has been truncated, but you can view the full file.
<!DOCTYPE html>
<html>
<head><meta charset="utf-8" />
<title>Instagram Filters</title><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<style type="text/css">
/*!
*
/**
* Question 1
*/
//#region qs1
function groupBy(arr, prop) {
return arr.reduce((group, item) => {
let value = item[prop];
group[value] = group[value] || [];
group[value].push(item);
@mohamedelshorbagy
mohamedelshorbagy / levenshtein-distance-algorithm.js
Created December 27, 2018 20:27
levenshtein distance algorithm
/**
*
* Levenshtein Distance Algorithm
* Source: https://en.wikipedia.org/wiki/Levenshtein_distance
*
*/
function getThreshold(word) {
if (word.length < 5) return 3;
return 5;