Skip to content

Instantly share code, notes, and snippets.

View szabacsik's full-sized avatar
🖖

András Szabácsik szabacsik

🖖
View GitHub Profile
@szabacsik
szabacsik / sort.php
Last active July 4, 2019 09:47
How to sort a multidimensional array in PHP?
<?php
$array =
[
[ 'filename' => 'mno.jpg', 'description' => 'do' ],
[ 'filename' => '005.jpg', 'description' => 'amet' ],
[ 'filename' => 'abc.jpg', 'description' => 'consectetur' ],
[ 'filename' => '001.jpg', 'description' => 'lorem' ],
[ 'filename' => 'jkl.jpg', 'description' => 'sed' ],
[ 'filename' => '003.jpg', 'description' => 'dolor' ],
@szabacsik
szabacsik / codeception.md
Last active August 19, 2019 08:32
Codeception quickstart guide

Codeception quickstart guide

Testing RESTful WebService

Login with the deploy user
su - worker
Go to the project root folder
@szabacsik
szabacsik / tar.md
Created May 29, 2019 14:49
tar commands

Compress a whole directory

tar -zcvf archive.tar.gz /path/to/source/directory

Extract files in particular directory

tar -zxvf archive.tar.gz -C /path/to/target/directory
@szabacsik
szabacsik / .htaccess
Last active February 1, 2021 16:00
Some useful .htaccess configuration
# Redirect to maintenance page, deny all but allow some IP
RewriteEngine on
RewriteBase /
RewriteCond %{REMOTE_HOST} !^1.2.3.4
RewriteCond %{REMOTE_ADDR} !^10.20.30.40
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|svg) [NC]
RewriteCond %{REQUEST_URI} !/maintenance/index.html$ [NC]
RewriteRule .* /maintenance/index.html [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-d
@szabacsik
szabacsik / apache.conf
Created October 8, 2018 13:16
Apache TLS/SSL/HTTPS Configuration File
# https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-apache-in-debian-9
LogLevel debug
ErrorLog /proc/self/fd/2
CustomLog /proc/self/fd/1 combined
<VirtualHost *:80>
Redirect permanent "/" "https:/localhost"
</VirtualHost>
@szabacsik
szabacsik / ssl-params.conf
Created October 8, 2018 12:28
Apache configuration snippet to define some SSL settings
# https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-apache-in-debian-9
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLHonorCipherOrder On
Header always set X-Frame-Options DENY
Header always set X-Content-Type-Options nosniff
SSLCompression off
SSLUseStapling on
SSLStaplingCache "shmcb:logs/stapling-cache(150000)"
SSLSessionTickets Off
@szabacsik
szabacsik / index.html
Last active September 30, 2018 11:16
DEMO Clock App
<!doctype html>
<html lang="en">
<head>
<title>DEMO Clock App</title>
<meta charset="utf-8">
<meta name="description" content="DEMO Clock App">
<meta name="author" content="András Szabácsik">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://fonts.googleapis.com/css?family=Bowlby+One+SC" rel="stylesheet">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
@szabacsik
szabacsik / random_string.php
Created August 22, 2018 20:14
Variable length random string
function randomString ( $minimum_length = 3, $maximum_length = 30 )
{
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$length = rand ( $minimum_length, $maximum_length );
$string = '';
for ( $i = 0; $i < $length; $i++ )
{
$string .= $characters [ rand ( 0, strlen ( $characters ) - 1 ) ];
}
return $string;
@szabacsik
szabacsik / git.md
Last active August 5, 2021 13:14
Useful git commands

useful git commands

Create a new empty branch for 'new-branch-name'

git checkout --orphan new-branch-name
git rm --cached -r .
git rm --cached -r -f .
@szabacsik
szabacsik / rsync.md
Last active December 20, 2019 08:18
Rsync example

Copies new and modified files from the source to the target
Ignores file's size and time of last modification and detects changes by checksum
%1 /path/to/source/
%2 /path/to/target/

rsync -rclpogImvh --stats %1 %2
rsync -rclImvh --no-perms --no-owner --no-group --stats --chown=user:group --chmod=Du=rwx,Dgo=rx,Fu=rw,Fog=r "/path/to/source" "/path/to/target" 2&gt;&gt; error.log 1&gt;&gt; output.log