Skip to content

Instantly share code, notes, and snippets.

View piorus's full-sized avatar
🏠
Working from home

Piotr Rusin piorus

🏠
Working from home
View GitHub Profile
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: whatsapp-metrics
name: whatsapp-metrics
spec:
replicas: 1
selector:
matchLabels:
@piorus
piorus / bash_strict_mode.md
Created April 21, 2023 12:09 — forked from vncsna/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation

set -e, -u, -o, -x pipefail

The set lines

  • These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
  • With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
  • set -euxo pipefail is short for:
set -e
set -u
@piorus
piorus / aws-ec2-metadata.sh
Created April 10, 2023 09:13
Retrieve basic AWS EC2 Meta Data (Availability Zone, Instance ID, Public IP, Private IP) and put it into HTML file
#!/bin/bash
META_DATA_URL="http://169.254.169.254/latest/meta-data"
TOKEN=`curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"`
function metadata() {
echo `curl -s -H "X-aws-ec2-metadata-token: $TOKEN" "$META_DATA_URL/$1"`
}
cat <<EOT >> index.html
zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.scream = 0
xdebug.cli_color = 1
xdebug.show_local_vars = 1
xdebug.idekey = PHPSTORM
xdebug.mode=debug
@piorus
piorus / script.sh
Last active January 24, 2021 10:10
GitHub webhooks install script
#!/bin/bash
echo -n "Where are your websites stored? [/var/www]: "
read WEBSITES_ROOT_DIRECTORY
if [ -z "$WEBSITES_ROOT_DIRECTORY" ]
then
WEBSITES_ROOT_DIRECTORY="/var/www"
fi
echo -n "git user (user that SSH key was added to the GitHub) [root]: "
@piorus
piorus / AdDisapprovalReasons.txt
Created December 1, 2020 19:49 — forked from 1mrat/AdDisapprovalReasons.txt
Reasons Why Facebook Disapprove Ads
UNKNOWN
IRREGULAR_APP_INSTALL
TEXT_OVERLAY
ADULT_CONTENT
ADULT_HEALTH
ALCOHOL
ANIMATED_IMAGE
BEFORE_AND_AFTER
CASUAL_DATING
DATING
@piorus
piorus / php-snipptets.MD
Last active October 31, 2022 07:35
PHP Snippets

Remove key prefix from associative array

<?php

function remove_key_prefix( $prefix, $array ) {
    return array_combine(
        // remove key prefix
        array_map(function($v) use ($prefix) {
 return str_replace( $prefix, '', $v );
@piorus
piorus / pdf_merge.py
Created July 1, 2018 20:18
PDF merge script for python
#!/usr/bin/env python
import sys
from os import listdir
from os.path import isfile, join, dirname, realpath
try:
from PyPDF2 import PdfFileReader, PdfFileWriter
except ImportError:
from pyPdf import PdfFileReader, PdfFileWriter