Skip to content

Instantly share code, notes, and snippets.

View arest's full-sized avatar

Andrea Restello arest

View GitHub Profile
@arest
arest / gist:4eca1056bed4966b6c716cad95404fbb
Created March 29, 2025 16:29
Homeassistant - Print Wenhook
import aiohttp
async def print_pdf(pdf_url, paper_size=None, page_range=None, callback=None):
cups_addon_url = "http://localhost:8099/api/print"
# Prepare the request data with the PDF URL and optional parameters
request_data = {
"endpoint": pdf_url,
"paper_size": paper_size,
"page_range": page_range,
"callback": callback
@arest
arest / rw_ro_access.sql
Created October 25, 2023 09:32 — forked from checco/rw_ro_access.sql
How to create a read only user in AWS RDS PostgreSQL and a user with superuser privileges on AWS RDS PostgreSQL
--
-- Read only
--
-- Create a group
CREATE ROLE postgres_ro_group;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO postgres_ro_group;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO postgres_ro_group;
@arest
arest / sh
Created May 17, 2021 06:58
Convert GoPro Mp4 to DaVinci MOV
#!/usr/bin/env bash
#docker run -v $(pwd):$(pwd) -w $(pwd) jrottenberg/ffmpeg -i bensound-epic.mp3 -acodec pcm_s16le epic.wav
#docker run -v $(pwd):$(pwd) -w $(pwd) jrottenberg/ffmpeg -i ./YDXJ0061.MP4 -vcodec dnxhd -acodec pcm_s16le -s 1920x1080 -r 30000/1001 -b:v 36M -pix_fmt yuv422p -f mov ./YDXJ0061.mov
BASH_XTRACEFD=3
set -xeuo pipefail
# Optional ENV variables:
: "${SOURCE_DIR:=`pwd`}"
@arest
arest / sh
Created May 17, 2021 06:56
Convert DaVinci Avi to Youtube Mp4
#!/usr/bin/env bash
#
filename="$(basename -- "$1")"
extension="${filename##*.}"
filename="${filename%.*}"
outputPath=${OUTPUT_DIR}/${OUTPUT_NAME}
@arest
arest / polar_import.sh
Created June 5, 2020 20:24
Import activity from Polar swatch and upload to Strava
#!/usr/bin/env bash
: "${POLAR_DIR:=$HOME/Sites/polar}"
: "${DOWNLOAD_DIR:=$HOME/Downloads}"
: "${DEVICE_ID:=}"
: "${CLIENT_ID:=}"
: "${CLIENT_SECRET:=}"
: "${REFRESH_TOKEN:=}"
echo "Date?"
@arest
arest / make-animated-gifs-using-ffmpeg.md
Created December 4, 2018 11:00 — forked from gka/make-animated-gifs-using-ffmpeg.md
how to make a nice GIF from png frames

Make sure ffmpeg is up-to-date:

brew update
brew upgrade ffmpeg

Convert a MOV into frames. Tweak the 2/1 if you want more or fewer frames.

#!/bin/bash
# Anh Nguyen <anh.ng8@gmail.com>
# 2016-04-30
# MIT License
# This script takes in images from a folder and make a crossfade video from the images using ffmpeg.
# Make sure you have ffmpeg installed before running.
# The output command looks something like the below, but for as many images as you have in the folder.
@arest
arest / postgres-cheatsheet.md
Created August 19, 2018 06:59 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@arest
arest / index.js
Created April 27, 2018 17:04 — forked from digitalkaoz/index.js
gatsby in aws lambda
const AWS = require("aws-sdk");
const {link} = require("linkfs");
const mock = require('mock-require');
const fs = require('fs');
const tmpDir = require('os').tmpdir();
exports.handler = (event, context) => {
rewriteFs();
invokeGatsby(context);
}
@arest
arest / pre-push
Last active November 20, 2017 16:43
Git pre push hook - Check PSR2 compliance
#!/bin/bash
printf "Checking PSR2 before pushing\n"
vendor/bin/phpcs --standard=PSR2 src/AppBundle/ tests/
OUT=$?
if [ $OUT -eq 0 ];then
printf "OK! Pushing...\n"
exit 0