Skip to content

Instantly share code, notes, and snippets.

View Jassem's full-sized avatar

Jassem GHRISS Jassem

View GitHub Profile
@Jassem
Jassem / Git Content have differences only in line separators.txt
Last active November 22, 2022 12:04
Git Content have differences only in line separators
To fix this bug, backup your changes and execute those commands at the root of git repository to reset git index:
rm .git/index
git reset
<?php
$neededObject = array_filter(
$arrayOfObjects,
function ($e) use ($searchedValue) {
return $e->id == $searchedValue;
}
);
@Jassem
Jassem / find-smallest-interval-in-array.php
Created November 5, 2022 06:52
How to find the minimum difference between 2 numbers inside an array of n size (find smallest interval) in PHP
/**
* Find the smallest interval (minimum difference) between the numbers of an array.
*
* @param array $numbers
* @return {Int} $diff
*/
function findSmallestInterval(array $numbers)
{
// Number of items in the array
$length = count($numbers);
<?
/**
* Performs the binary search over
* sorted array
*
* It should perform this operation in O(logn)
*/
function binary_search(array $sortedArray, $searchElement) {
// Check if array is sorted
$min_index = 0;