Skip to content

Instantly share code, notes, and snippets.

View szabacsik's full-sized avatar
🖖

András Szabácsik szabacsik

🖖
View GitHub Profile
@Trailingslashes
Trailingslashes / knock.sh
Created September 23, 2018 06:45
Port knocking bash script
#!/bin/bash
HOST=$1
shift
for ARG in "$@"
do
nmap -Pn --host-timeout 100 --max-retries 0 -p $ARG $HOST
done
@molotovbliss
molotovbliss / find-invalid-img.md
Last active March 30, 2022 13:00
Find malformed/invalid images recursively with ImageMagick's identify utility of current working dir

Find malformed/invalid images recursively

with ImageMagick's identify utility of current working dir

display output listing of current file scanned, only non 0 exit status get logged.

find -D rates . -type f \( -name '*.gif' -o -name '*.png' -o -name '*.jpg' -o -name '*.jpeg' \) -print -exec bash -c 'identify "$1" &> /dev/null || echo "$1" >> invalid-imgs.log' none {} \;


forked & modified from:

@pthiers
pthiers / PHP-Array.groovy
Last active March 7, 2024 14:26
datagrip php array extractor
/*
* Available context bindings:
* COLUMNS List<DataColumn>
* ROWS Iterable<DataRow>
* OUT { append() }
* FORMATTER { format(row, col); formatValue(Object, col) }
* TRANSPOSED Boolean
* plus ALL_COLUMNS, TABLE, DIALECT
*
* where:
@ManInTheBox
ManInTheBox / DateTimeImmutabilityExample.php
Created November 8, 2016 14:47
DateTime VS DateTimeImmutable example
<?php
class DateTimeImmutabilityExample
{
private $date;
/**
* Intentionaly no type hinting so you can test with both DateTime and DateTimeImmutable
*/
public function __construct($date)
@wojteklu
wojteklu / clean_code.md
Last active May 20, 2024 18:19
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@fedir
fedir / getPhpExtDir.sh
Last active November 17, 2022 14:57
Get PHP extension directory in shell
#!/bin/bash
PHP_EXT_DIR=$(grep extension_dir= `which php-config` | sed s/extension_dir=\'// | sed s/\'//)
echo $PHP_EXT_DIR
@deviantony
deviantony / install-latest-compose.sh
Last active May 6, 2024 16:22
Install latest version of Docker Compose
#!/bin/bash
## THIS IS THE OLD WAY
## Nowadays, simply follow the Compose installation instructions in the official documentation:
## https://docs.docker.com/compose/install/
# get latest docker compose released tag
COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)
@mehdichaouch
mehdichaouch / memory_usage.php
Last active April 11, 2024 15:55
PHP Snippet to get human readable memory usage
<?php
function convert($size)
{
$unit=array('b','kb','mb','gb','tb','pb');
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
}
convert(memory_get_usage());
@mahammad
mahammad / firefox-developer-edition.md
Last active August 29, 2023 11:28
How To install Firefox Developer Edition and create desktop icon for Ubuntu 14.04 LTS

chose other install way

  1. Open Terminal Ctrl+Alt+T Download Firefox Developer Edition tar file

    wget https://download.mozilla.org/?product=firefox-aurora-latest-ssl&os=linux64&lang=en-US

  2. Copy tar file to opt sudo cp -rp firefox-35.0a2.en-US.linux-x86_64.tar.bz2

  3. Open opt folder (cd /opt/) and untar file sudo tar xjf firefox-35.0a2.en-US.linux-x86_64.tar.bz2

@zuzuleinen
zuzuleinen / csv-symfony-action.php
Last active January 17, 2024 11:04
CSV Response in Symfony controller action
<?php
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class CsvController extends Controller
{
/**
* Get a CSV file from an array