Skip to content

Instantly share code, notes, and snippets.

View aelshamy's full-sized avatar

Amr Elshamy aelshamy

  • Huntington Bank
  • Columbus, United State
  • X @ajmoro
View GitHub Profile
@aelshamy
aelshamy / Observer Pattern
Last active February 1, 2016 21:01
Showcase of the observer design pattern
var Subject = function(){
var self = this;
self.observers = [];
return{
subscribeObserver:function(observer){
self.observers.push(observer);
@aelshamy
aelshamy / LinkedList.js
Created December 27, 2016 08:15
LinkedList created by aelshamy - https://repl.it/ExG4/4
function LinkedList(){
this.head = null;
this.tail = null;
}
function Node(value, next, prev){
this.value = value;
this.next = next;
this.prev = prev;
}
@aelshamy
aelshamy / Singleton Design Pattern.js
Created December 27, 2016 08:24
Singleton Design Pattern created by aelshamy - https://repl.it/ExOP/0
// Singleton design pattern ES5
var Singleton = (function(){
var instant;
function createInstant(){
var object = new Object("Iam instant");
return object;
}
return {
getInstant:function(){
@aelshamy
aelshamy / Binary Search Tree.js
Created December 27, 2016 12:02
Binary Search Tree created by aelshamy - https://repl.it/ExPZ/6
function BST(value){
this.value = value;
this.left = null;
this.right = null;
}
BST.prototype.insert = function(value){
if(value <= this.value){
if(!this.left) this.left = new BST(value);
else this.left.insert(value);
@aelshamy
aelshamy / Hash Table Data Structure.js
Created December 27, 2016 13:10
Hash Table Data Structure created by aelshamy - https://repl.it/ExRG/2
function HashTable (size){
this.buckets = Array(size);
this.numBuckets = this.buckets.length;
}
function HashNode(key, value, next){
this.key = key;
this.value = value;
this.next = next || null;
}
void main() {
var deck = new Deck();
deck.shuffle();
deck.deal(5);
print(deck.deal(5));
}
class Deck {
List<Card> cards = [];
@aelshamy
aelshamy / streamprovider_example.dart
Created January 11, 2020 15:07 — forked from jtlapp/streamprovider_example.dart
StreamProvider example
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
const appTitle = 'StreamProvider Demo';
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
void main() => runApp(MyApp());
class CountDown extends ValueNotifier<int> {
CountDown(int downFrom) : super(downFrom) {
scheduleDecrement();
}