Skip to content

Instantly share code, notes, and snippets.

@xmsi
xmsi / Php_xmsi.md
Last active April 22, 2025 13:08
Code sheat

Null Coalescing (??) vs Ternary (?:) operators

  • Null coalescing - check for null and performs next (?? ??=)
  • Ternary - check for false and performs next (?:)

Oneline if

if (is_string($hashesForCherryPick)) $hashesForCherryPick = explode(" ", $hashesForCherryPick);
@xmsi
xmsi / docker.md
Last active March 5, 2025 09:28
Docker helper

Docker Engine, Compose, Portainer on Ubuntu 22

Docker Engine, Compose and Portainer installation on ubuntu 22. Optional: how to change default docker root folder (where images and containers are stored)

Install docker engine

tutorial video tested it works To install on Ubuntu 22 you should type these commands in your CLI

  1. $ curl -fsSl https://get.docker.com -o get-docker.sh
  2. $ sudo sh get-docker.sh
  3. $ sudo groupadd docker
@xmsi
xmsi / git.md
Last active January 16, 2025 07:16
Git helper

Undo pushed Merge request

  1. git log --oneline see to which commit you need to jump
  2. git reset --hard branch_hash
  3. git push origin feature/DATRUECALL-180 --force force push branch to remote origin

It is better to pull from origin before doing massive changes

Server certificate verification failed CAfile:

@xmsi
xmsi / intellijHelper.md
Last active November 21, 2024 11:37
Intellij IDEA helper

Search regex and replace

  • Search (\{\{\s*\$[^}]+)\s+or\s+([^}]+\s*\}\})
  • Replace DOESN"T KNOW

Change or with ??

@xmsi
xmsi / Versioning.md
Last active February 21, 2025 06:46
Packages Versioning in composer.json, PHP

There is a difference between ~ and ^ in Composer, though it might not be immediately obvious in some cases. Let me clarify:

Key Difference Between ~ and ^:

  • ~ (tilde): Allows updates for the last digit specified.
  • ^ (caret): Allows updates for all minor versions within the same major version.

In your example, ~7.3 vs. ^7.3:

  • ~7.3:
@xmsi
xmsi / database_knowledgebase.md
Last active April 12, 2025 07:06
Database theory

MYSQL

Export from docker

mysqldump -u root -p database_name --skip-comments > my_export_file.sql

Import from docker

mysql -u root -ppassword db_name < /tmp/database.sql

@xmsi
xmsi / css_talwind.md
Last active October 14, 2024 09:28
css_talwind.md

Css

Flex

  • if you want for childrens create wrapper, but it destroys flex, use display: contents, which ensures that your childrens contnue behaviour as previous

Author: GPT-4o

In JavaScript, there are three primary ways to define functions: Function Declarations, Function Expressions, and Arrow Functions. Each has its own syntax, behavior, and use cases. Here’s a detailed explanation of the differences:

1. Function Declaration

Syntax:

function functionName(parameters) {
@xmsi
xmsi / Larahelper.md
Last active March 18, 2025 05:51
Helper for Laravel

Sail

docker run --rm \
    -u "$(id -u):$(id -g)" \
    -v $(pwd):/var/www/html \
    -w /var/www/html \
    laravelsail/php82-composer:latest \
    composer install
@xmsi
xmsi / linux_helper.md
Last active January 14, 2025 05:26
Linux helper

How to create SSH key (in terminal $):

$ ssh-keygen -b 2048 -t rsa -C "[email protected]"

Start service automatically on every boot (start computer)

sudo systemctl enable [service_name]

Extract tar into executable

sudo tar -xvzf ngrok-v3-stable-linux-amd64.tgz -C /usr/local/bin/