Skip to content

Instantly share code, notes, and snippets.

View mohanadkaleia's full-sized avatar
🥝

Mohanad Kaleia mohanadkaleia

🥝
View GitHub Profile
NSLog(@"Hello Gist");
<?php
$serverName = "MOHANA-LAPTOP\SQLEXPRESS";
$connectionInfo = array("Database" => "test", "UID" => "sa", "PWD"=>"123456");
$conn = sqlsrv_connect($serverName, $connectionInfo);
if($conn) {
echo "Connection established .. :)";
} else {
echo "Connection could not be established :(";
dir(print_r(sqlsrv_errors(), true));
#git discard all local changes/commits and pull from upstream
git reset --hard origin/master
git pull origin master
import cv2
import os.path
import os
from PIL import Image
from os.path import basename
import sys
from decimal import Decimal
from __builtin__ import str
isfile = os.path.isfile
@mohanadkaleia
mohanadkaleia / permutation_matrix.py
Created August 12, 2017 19:45
Random and symmetric permutation matrix
import numpy as np
from itertools import product
def generatePermutationMatrix(n):
d = np.zeros((n, n))
index = np.random.permutation(range(n))
p = index[:n/2]
index1 = list(product(p, p))
for i in index1:
@mohanadkaleia
mohanadkaleia / shuffle_by_rows_columns.py
Created August 15, 2017 15:20
When you have 2D array, shuffle functionality in python numpy does the trick only for rows, the following gist is how to randomly shuffle rows and columns
import numpy as np
# Lets suppose you have a 2D array
c = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
# Suffle it for rows and columns
np.random.permutation(np.random.permutation(c.transpose()).transpose())
let user = {
name: 'Mohanad',
sayHi: function() {
console.log(`Hi ${this.name}`)
}
}
user.sayHi();
class User {
constructor(name) {
this.name = name;
}
sayHi() {
console.log(`Hi, ${this.name}`);
}
}
class Animal {
constructor(name) {
this.name = name;
}
eat() {
console.log("Start eating...");
}
}