Skip to content

Instantly share code, notes, and snippets.

View mohnoor94's full-sized avatar
📘
Always Learning...

Mohammad Noor Abu Khleif mohnoor94

📘
Always Learning...
View GitHub Profile
@mohnoor94
mohnoor94 / multiplyAndDivideFunction.cpp
Created August 20, 2017 21:21
A function that takes 2 integer variables x and y, returns the multiplication of x and y in variable mul, and the division of x and y in variable div.
// www.abukhleif.com
void multiplyAndDivide (int x, int y, int& mul, double& div) {
mul = x * y;
div = (x * 1.0) / y;
}
@mohnoor94
mohnoor94 / multiplyAndDivideFull.cpp
Last active August 20, 2017 21:27
A full C++ program contains a function that takes 2 integer variables x and y, returns the multiplication of x and y in variable mul, and the division of x and y in variable div.
// www.abukhleif.com
#include <iostream>
using namespace std;
void multiplyAndDivide (int x, int y, int& mul, double& div) {
mul = x * y;
div = (x * 1.0) / y;
}
int main() {
int n1, n2, m;
double d;
@mohnoor94
mohnoor94 / selenium
Created October 23, 2017 14:30 — forked from adeubank/selenium
Set up selenium on Ubuntu 16.04 as a service
#!/bin/bash
case "${1:-''}" in
'start')
if test -f /tmp/selenium.pid
then
echo "Selenium is already running."
else
export DISPLAY=localhost:99.0
java -Dwebdriver.gecko.driver="/usr/lib/geckodriver/geckodriver" -jar /usr/lib/selenium/selenium-server-standalone.jar -port 4444 > /var/log/selenium/output.log 2> /var/log/selenium/error.log & echo $! > /tmp/selenium.pid
@mohnoor94
mohnoor94 / grid-node.json
Created October 24, 2017 08:02
Simple Configurations for a Selenium Node
{
"capabilities":
[
{
"browserName": "firefox",
"maxInstances": 10
}
],
"port":5555,
"hubPort":4444,
@mohnoor94
mohnoor94 / Java Calculator Using Reflection.java
Created December 30, 2017 17:36
A simple Java calculator supports four operations (Summation, Subtraction, Multiplying, and Division) without using if or switch statements. (Using Reflection)
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Scanner;
public class MainClass {
public static void main(String[] args) throws ClassNotFoundException, InvocationTargetException, IllegalAccessException, NoSuchMethodException {
Scanner scanner = new Scanner(System.in);
Class<?> operations = Class.forName("MainClass");
MainClass mainClass = new MainClass();
Method method = operations.getDeclaredMethod(scanner.next(), double.class, double.class);
@mohnoor94
mohnoor94 / PascalTriangle.sc
Last active March 3, 2018 21:58
Functional Programming Principles in Scala - Exercise 1: Pascal’s Triangle
object Main {
def main(args: Array[String]) {
println("Pascal's Triangle")
for (row <- 0 to 10) {
for (col <- 0 to row)
print(pascal(col, row) + " ")
println()
}
}
@mohnoor94
mohnoor94 / ParenthesesBalancing.sc
Created March 3, 2018 21:58
Functional Programming Principles in Scala - Exercise 2: Parentheses Balancing
/**
* Exercise 2
*/
def balance(chars: List[Char]): Boolean = {
def difference(acc: Int, ch: List[Char]): Int = {
val head = ch.head
val tail = ch.tail
val isLeft = head == '('
val isRight = head == ')'
val notEmptyTail = tail.nonEmpty
@mohnoor94
mohnoor94 / CountingChange.sc
Created March 3, 2018 22:13
Functional Programming Principles in Scala - Exercise 3: Counting Change
/**
* Exercise 3
*/
def countChange(money: Int, coins: List[Int]): Int = {
if (money == 0) 1
else if (money < 0 || coins.isEmpty) 0
else countChange(money - coins.head, coins) + countChange(money, coins.tail)
}
@mohnoor94
mohnoor94 / evenOddSum.cpp
Created March 17, 2018 18:10
Write a C++ program that reads a set of integers then finds and prints the sum of even and odd integers.
#include <iostream>
using namespace std;
int main () {
int n, x, oddSum = 0, evenSum = 0;
cout << "Enter the number of values: ";
cin >> n;
cout << "Enter your values:" << endl;
for (int i = 0; i < n; i++) {
cin >> x;
@mohnoor94
mohnoor94 / installScala.txt
Last active August 28, 2023 14:58 — forked from Frozenfire92/gist:3627e38dc47ca581d6d024c14c1cf4a9
Install Scala and SBT using apt on Ubuntu or any Debian derivative using apt
## Java
sudo apt update
sudo apt install default-jdk
## Scala
sudo apt remove scala-library scala
sudo wget http://scala-lang.org/files/archive/scala-2.12.6.deb
sudo dpkg -i scala-2.12.6.deb
## SBT