Skip to content

Instantly share code, notes, and snippets.

View hrvoj3e's full-sized avatar
💻
Cloning ...

hrvoj3e

💻
Cloning ...
View GitHub Profile
@hrvoj3e
hrvoj3e / gist:030975f03f3762299cc6220914de5b0f
Created November 15, 2018 15:22 — forked from jaxbot/gist:5748513
Block nginx from serving .git directories
location ~ /\.git {
deny all;
}
# or, all . directories/files in general (including .htaccess, etc)
location ~ /\. {
deny all;
}
@hrvoj3e
hrvoj3e / db_backup.sh
Created January 30, 2019 13:18 — forked from bendavis78/db_backup.sh
A simple database backup / rotation / prune script
#!/bin/bash
# for use with cron, eg:
# 0 3 * * * postgres /var/db/db_backup.sh foo_db
if [[ -z "$1" ]]; then
echo "Usage: $0 <db_name> [pg_dump args]"
exit 1
fi
@hrvoj3e
hrvoj3e / sync-using-gitignore.sh
Created February 7, 2019 14:30 — forked from theothermattm/sync-using-gitignore.sh
Rsync files using .gitignore
# sync everything excluding things in .gitignore
# delete anything on target not in source
# include dotfiles and symlinks, also use compression
rsync -azP --delete --filter=":- .gitignore" . my-target-host:/my/target/directory
@hrvoj3e
hrvoj3e / php7.2-yaz.sh
Last active April 19, 2019 07:39
Install YAZ for PHP 7.2
## PHP 7.2
apt install yaz php7.2-dev php7.2-pear libyaz5-dev
pecl channel-update pecl.php.net
pecl install yaz
## Installing '/usr/lib/php/20170718/yaz.so'
echo 'extension=yaz.so' > /etc/php/7.2/mods-available/yaz.ini
ln -s /etc/php/7.2/mods-available/yaz.ini /etc/php/7.2/fpm/conf.d/20-yaz.ini
ln -s /etc/php/7.2/mods-available/yaz.ini /etc/php/7.2/cli/conf.d/20-yaz.ini
@hrvoj3e
hrvoj3e / php7.3-yaz.sh
Created April 24, 2019 06:30
Install YAZ for PHP 7.3
## PHP 7.3
apt update
apt install software-properties-common
apt-add-repository ppa:ondrej/php
apt install yaz libyaz5-dev
apt install php7.3-dev php7.3 php7.3-fpm
pecl channel-update pecl.php.net
pecl install yaz
## Installing '/usr/lib/php/20180731/yaz.so'
## install ok: channel://pecl.php.net/yaz-1.2.3
@hrvoj3e
hrvoj3e / semver.sh
Created October 10, 2019 19:13 — forked from Ariel-Rodriguez/semver.sh
semver compare tool in bash
#!/bin/bash
###
# semantic version comparition using semver specification http://semver.org/
# This bash script compares pre-releases alphabetically as well
#
# returns 1 when A greater than B
# returns 0 when A equals B
# returns -1 when A lower than B
#
@hrvoj3e
hrvoj3e / keybase.md
Created October 24, 2019 18:16
keybase.md

Keybase proof

I hereby claim:

  • I am hrvoj3e on github.
  • I am hrvoj3e (https://keybase.io/hrvoj3e) on keybase.
  • I have a public key ASCouDrOYVr7vbfxwRQatfK00eIaLr07bFnUYfPSHn131Ao

To claim this, I am signing this object:

@hrvoj3e
hrvoj3e / jwt-expiration.md
Created December 31, 2019 15:20 — forked from soulmachine/jwt-expiration.md
How to deal with JWT expiration?

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC:

<?php
namespace Core\UserBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class SecurityController extends Controller
{
public function loginAction(Request $request)
@hrvoj3e
hrvoj3e / docker-compose.yml
Created February 27, 2020 16:39 — forked from iki/docker-compose.yml
Docker-compose nginx CORS proxy
version: '3.7'
services:
whoami:
image: jwilder/whoami
ports:
- 127.0.0.1:7000:8000
cors: