Skip to content

Instantly share code, notes, and snippets.

View doganoo's full-sized avatar
🎯
Focusing

Doğan Can Uçar doganoo

🎯
Focusing
View GitHub Profile
@doganoo
doganoo / count_island_dfs_array.php
Last active November 14, 2020 19:00
Leetcode: 200. Number of Islands
<?php
function numIslands(array $grid):int {
$length = count($grid);
$islandCount = 0;
if ($length === 0) {
return 0;
}
for ($i = 0; $i < $length; $i++) {
@doganoo
doganoo / gist:552034fc990d3fb52a8493885b5d9031
Created August 27, 2020 18:16
Inkscape image resizing, needed once for android icons
var=1
# File source am Mac
# for file in /Users/dogano/Desktop/new/brazil.xcf
# File source Linux
for file in /home/dogano/Schreibtisch/flags_origin/*.svg
do
echo $file
<?php
use doganoo\PHPAlgorithms\Datastructure\Sets\HashSet;
use doganoo\PHPAlgorithms\Datastructure\Stackqueue\Queue;
require_once 'vendor/autoload.php';
/*
* COMPOSER.JSON CONTENT:
* ==================================================
@doganoo
doganoo / snippet.php
Last active July 3, 2019 10:51
snippets
<?php
$loggggggggger = function ($message): void {
if (is_array($message)) $message = print_r($message, true);
if (is_bool($message)) $message = $message ? "true" : "false";
if ($message instanceof \Exception) $message = $message->getTraceAsString();
$dateTime = (new \DateTime())->format("Y-m-d H:i:s");
file_put_contents("/var/log/application.log", "$dateTime : $message\n\n\n\n", FILE_APPEND);
};
@doganoo
doganoo / count_islands.php
Created January 5, 2019 21:48
count all distinct islands in a 2d array
<?php
function flood(array &$matrix, int $i, int $j) {
$matrix[$i][$j] = 0;
lookupFor($matrix, $i + 1, $j);
lookupFor($matrix, $i, $j + 1);
lookupFor($matrix, $i - 1, $j);
lookupFor($matrix, $i, $j - 1);
}
@doganoo
doganoo / second_highest.php
Created November 28, 2018 17:48
second highest value
//assumes that you have installed PHPAlgorithms properly:
//https://github.com/doganoo/PHPAlgorithms
$arr = [1, 2, 3, 4, 5, 6, 7, 8];
echo secondHighest($arr); //echo's 7
function secondHighest(array $array): int {
$maxHeap = new MaxHeap();
foreach ($array as $value) {
$maxHeap->insert($value);
@doganoo
doganoo / throttling.html
Last active October 12, 2018 14:57
Throttling HTML bars with jQuery JavaScript and CSS transitions
<html>
<head>
<style>
body{
display: flex;
flex-direction: column;
justify-content: center;
}
.container{