Skip to content

Instantly share code, notes, and snippets.

View matusstafura's full-sized avatar
👋

Matus Stafura matusstafura

👋
View GitHub Profile
@matusstafura
matusstafura / selection-sort-in-php.php
Last active March 15, 2024 10:33
Selection Sort in PHP
<?php
function selectionSort(array $a): array
{
for ($i = 0; $i < count($a) - 1; $i++) {
$min_i = $i;
for ($j = $i + 1; $j < count($a); $j++) {
if ($a[$j] < $a[$min_i]) {
$min_i = $j;
}
@matusstafura
matusstafura / bubble-sort-in-php.php
Created January 19, 2023 09:09
Bubble sort in PHP
<?php
function bubbleSort(array $a): array
{
for ($i = count($a) - 1; $i > 0; $i--) {
for ($j = 0; $j < $i; $j++) {
if ($a[$j] > $a[$j + 1]) {
$temp = $a[$j];
$a[$j] = $a[$j+1];
$a[$j+1] = $temp;
@matusstafura
matusstafura / basic-operations-in-queues-in-php.php
Created January 12, 2023 07:57
Basic operations in Queues in PHP
<?php
class Node
{
public $value;
public $next;
public function __construct($value)
{
$this->value = $value;
@matusstafura
matusstafura / basic-operations-in-stacks-in-php.php
Created January 12, 2023 07:54
Basic operations in stacks in PHP
<?php
class Node
{
public $value;
public $next;
public function __construct($value)
{
$this->value = $value;
@matusstafura
matusstafura / basic-operations-in-doubly-linked-list-in-php.php
Last active January 5, 2023 07:23
Basic operations in doubly linked list
<?php
class Node
{
public $value;
public $next;
public $prev;
public function __construct($value)
{
@matusstafura
matusstafura / basic-operations-in-singly-linked-list-in-php.php
Last active December 27, 2022 14:09
Basic operations in Singly Linked List In PHP
<?php
class Node
{
public $value;
public $next;
public function __construct($value)
{
$this->value = $value;
@matusstafura
matusstafura / packages.md
Last active December 27, 2022 14:31
Must have Laravel Packages

Pest PHP source

Install

composer require pestphp/pest --dev --with-all-dependencies
composer require pestphp/pest-plugin-laravel --dev
php artisan pest:install

Use

# SED replace all html tags
sed -e 's/<[^>]*>//g'
# SED multiple divided by ;
sed 's/ab/~/g; s/bc/ab/g; s/~/bc/g'
# SED delete empty lines
sed '/^\s*$/d'
# SED delete all lines except pattern
@matusstafura
matusstafura / tmux_cheatsheet.md
Last active October 1, 2016 09:29
tmux cheatsheet (default key ctrl-b)

tmux cheat sheet

Sessions

Creating a session:

tmux new-session -s work

Attach to a session: