Skip to content

Instantly share code, notes, and snippets.

@fxpires
fxpires / QRLogo.php
Created November 4, 2015 15:42 — forked from NTICompass/QRLogo.php
QR Code + Logo Generator
<?php
/**
* QR Code + Logo Generator
*
* http://labs.nticompassinc.com
*/
$data = isset($_GET['data']) ? $_GET['data'] : 'http://labs.nticompassinc.com';
$size = isset($_GET['size']) ? $_GET['size'] : '200x200';
$logo = isset($_GET['logo']) ? $_GET['logo'] : FALSE;
@fxpires
fxpires / gz2xz.sh
Created February 21, 2018 16:43
Recompress all gzip files in current directory as xz / Recomprime os arquivos gzip em um diretório como xz
#!/bin/bash
GZ_LIST="*gz"
for GZ_FILE in ${GZ_LIST}
do
echo "Processing file ${GZ_FILE}"
FILENAME="${GZ_FILE%.*}"
gunzip -c ${GZ_FILE} | xz -3vv -c > ${FILENAME}.xz
RES=$?
touch -r ${GZ_FILE} ${FILENAME}.xz
if [ $? -eq 0 ]; then
@fxpires
fxpires / unsplash-random.sh
Created February 21, 2018 16:55
Change the lockscreen of Gnome with a random image from unsplash.com / Defne a imagem da tela de bloqueio do Gnome com uma imagem aleatória do site unsplash.com
#!/bin/bash
#IMG_DIR=${HOME}/.unsplash
IMG_DIR=/home/fabiano/.unsplash
URL="http://source.unsplash.com/random"
DATE_TIME=$(LANG=C date +%F_%T | sed 's/:/./g')
IMG=${IMG_DIR}/${DATE_TIME}.jpg
if [ ! -d ${IMG_DIR} ]; then
mkdir ${IMG_DIR}
@fxpires
fxpires / array_chunk.py
Last active June 8, 2018 19:48 — forked from amitittyerah/array_chunk.py
array_chunk($arr, $size) version of Python
def array_chunk(arr, size):
chunks=[arr[x:x+size] for x in xrange(0, len(arr), size)]
return chunks
from PIL import Image
# Partially inspired by https://stackoverflow.com/a/30228308/2237660
# images: list() of PIL.Image.Image
# stack: False=> append horizontally (side-by-side), True=> append vertically (stacking bottom-to-up)
# bgcolor: final image background color. Default: white
def append_images(images, stack=False, bgcolor='white'):
# sanity checks
if not isinstance(images, list):
return False
@fxpires
fxpires / recompress.sh
Created October 26, 2018 14:29
recompress all gzip in current dir files as xz files, keeping the timestamps / recomprime arquivos no diretório atual, de gz para xz, mantendo os timestamps
#!/bin/bash
for FILE in *gz
do
gunzip ${FILE}
UNFILE=${FILE%.*}
xz -3vv ${UNFILE}
done
@fxpires
fxpires / jboss-log-compression.sh
Created October 26, 2018 14:38
JBoss/Wildfly Log compression. Compress both server.log and access_log (if exists). Ignores already compressed logs in gz or xz formats
# Server log compression
find /opt/jboss/standalone/log -maxdepth 1 -type f -name 'server.log.*' -not -name '*xz' -not -name '*gz' -exec xz -3 {} \;
# default-host log compression
test -d /opt/jboss/standalone/log/default-host && find /opt/jboss/standalone/log/default-host -type f -mtime +0 -not -name '*xz' -exec xz -3 {} \;
@fxpires
fxpires / newcert.py
Created November 28, 2019 20:59 — forked from Zeerg/newcert.py
Python script to generate CSR/Self Signed Cert. Needs pyOpenssl and python-whois
#!/usr/bin/python
from OpenSSL import crypto
import os
import sys
import datetime
import whois
#Variables
TYPE_RSA = crypto.TYPE_RSA
TYPE_DSA = crypto.TYPE_DSA
@fxpires
fxpires / sqlalchemy_mysql_binary_uuid.py
Created December 5, 2019 19:16 — forked from craigdmckenna/sqlalchemy_mysql_binary_uuid.py
SQLAlchemy, MySQL 16 bit UUID, Custom Data Type
import UUID
from sqlalchemy.dialects.mysql import BINARY
from sqlalchemy.types import TypeDecorator
class BinaryUUID(TypeDecorator):
'''Optimize UUID keys. Store as 16 bit binary, retrieve as uuid.
inspired by:
http://mysqlserverteam.com/storing-uuid-values-in-mysql-tables/
@fxpires
fxpires / kubedf
Created December 12, 2019 19:43 — forked from redmcg/kubedf
Bash script to show k8s PVC usage
#!/usr/bin/env bash
KUBEAPI=127.0.0.1:8001/api/v1/nodes
function getNodes() {
curl -s $KUBEAPI | jq -r '.items[].metadata.name'
}
function getPVCs() {
jq -s '[flatten | .[].pods[].volume[]? | select(has("pvcRef")) | '\