Skip to content

Instantly share code, notes, and snippets.

View OmarElgabry's full-sized avatar
🧑‍🌾

Omar Elgabry OmarElgabry

🧑‍🌾
View GitHub Profile
@OmarElgabry
OmarElgabry / JSONTutorial.html
Created January 20, 2015 13:26
JSON Tutorial
<!DOCTYPE html>
<html lang='en'>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>
JSON Tutorial
</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
function successFn(jsonData,status, xhr){
@OmarElgabry
OmarElgabry / Path Finding Algorithms.cpp
Last active July 5, 2025 11:25
Implementation of BFS, DFS(Recursive & Iterative), Dijkstra, Greedy, & Astart Algorithms. These algorithms are used to search the tree and finding the shortest paths from starting node to goal node in the tree.
#include <cstdlib>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <iterator>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <cmath>
@OmarElgabry
OmarElgabry / Dependency Injection (DI).java
Created September 6, 2017 08:34
Spring: A Head Start 🔥— Introduction (Part 1)
public class App {
private Service service;
// A service object will be injected by Spring IoC container
public App (Service service) {
this.service = service;
}
}
@OmarElgabry
OmarElgabry / pom.xml
Created September 6, 2017 08:37
Spring: A Head Start 🔥— Introduction (Part 1)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!-- ... -->
<properties>
<springframework.version>4.3.4.RELEASE</springframework.version>
</properties>
<dependencies>
<!-- Apache Common Logging API -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
@OmarElgabry
OmarElgabry / App.java
Last active September 6, 2017 08:46
Spring: A Head Start 🔥 — Beans Configuration (Part 2)
public class App {
private int id;
private String name;
public App(){
}
public App(int id){
this.id = id;
}
@OmarElgabry
OmarElgabry / beans.xml
Last active September 6, 2017 09:05
Spring: A Head Start 🔥 — Beans Configuration (Part 2)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
@OmarElgabry
OmarElgabry / beans.xml
Created September 6, 2017 08:52
Spring: A Head Start 🔥 — Beans Configuration (Part 2)
<!-- A simple bean definition -->
<bean id="..." class="...">
<!-- dependencies and configuration for this bean go here -->
</bean>
<!-- App bean -->
<bean id="app" class="App" lazy-init="true"></bean>
@OmarElgabry
OmarElgabry / Test.java
Created September 6, 2017 08:55
Spring: A Head Start 🔥 — Beans Configuration (Part 2)
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Test {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
}
}
@OmarElgabry
OmarElgabry / Test.java
Created September 6, 2017 09:05
Spring: A Head Start 🔥 — Beans Configuration (Part 2)
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Test {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
App app = context.getBean("app", App.class);
// App app = (App) context.getBean("app");
}
}
@OmarElgabry
OmarElgabry / App.java
Last active September 6, 2017 09:24
Spring: A Head Start 🔥 — Beans Configuration (Part 2)
public class App {
private Service mainService;
private Service[] services;
/* same as before */
public App(Service main){
this.mainService = main;
}