Skip to content

Instantly share code, notes, and snippets.

View ZappaBoy's full-sized avatar
Focusing

Zappone Federico ZappaBoy

Focusing
View GitHub Profile
@ZappaBoy
ZappaBoy / Dockerfile
Last active March 18, 2023 16:08
Dockerfile gdal latest version with conda - FastAPI, uvicorn and Python 3.11
# You can change the base image if you don't need FastAPI or Uvicorn
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.11-slim
WORKDIR /app
RUN apt update
RUN apt install -y libpq-dev build-essential wget
ENV CONDA_DIR /opt/conda
@ZappaBoy
ZappaBoy / check-host.sh
Created November 14, 2022 11:16
This simple script call the check-host.net API to check host status through ping, http, tcp and dns checks.
#!/usr/bin/env bash
# Created by: ZappaBoy
# Usage: ./check-host "your.domain"
# This simple script call the check-host.net API to check host status through ping, http, tcp and dns checks.
base_url='https://check-host.net'
headers="Accept: application/json"
sleep_time=10
@ZappaBoy
ZappaBoy / main.py
Created November 7, 2022 18:19
DALLE OpenAI API
import argparse
import os
from typing import List
import openai
secret_key = os.environ.get("OPENAI_SECRET_KEY")
if not secret_key:
raise ValueError("Please set the OPENAI_SECRET_KEY environment variable")
@ZappaBoy
ZappaBoy / ansible-cheatsheet.org
Created September 10, 2022 19:41
Ansible Getting Started Cheatsheet

Getting Started

Templating

You can copy-paste the code in this document and simply replace the UPPERCASE vairables with your configurations.

@ZappaBoy
ZappaBoy / convert.py
Last active August 26, 2022 10:00
Convert frequencies to marlin gcode sound
song = [
# Add here your song as tuples of (frequency, duration) or better (Hz, seconds)
# Check both:
# - Song example - https://gist.github.com/ZappaBoy/563533bb4d9a9cbc2709a75b84bc37fb
# - Output example - https://gist.github.com/ZappaBoy/701bbab166b0573b71be7e889f0af575
]
def convert_song(notes):
lines = []
for note in notes:
@ZappaBoy
ZappaBoy / NeverGonnaGiveYouUp.gcode
Last active January 3, 2024 20:45
Never Gonna Give You Up - Marlin gcode for 3d printer
; Play Never Gonna Give You Up
; Add the following lines to your slicer software to play the songs.
M300 S494 P250
M300 S554 P250
M300 S587 P250
M300 S494 P250
M300 S0 P250
M300 S659 P250
M300 S740 P250
M300 S659 P750
@ZappaBoy
ZappaBoy / main.py
Created August 25, 2022 22:32
Python play frequencies as a song
# First of all install pysine: `python -m pip install pysine`
from pysine import sine
from song import song
def play_song(notes):
for note in notes:
frequency = note[0]
duration = note[1] / 1000
sine(frequency=frequency, duration=duration)
@ZappaBoy
ZappaBoy / runinbackground.sh
Created August 10, 2022 15:10
Run in background aliases
# Run in background aliases
TMP_PID_PATH=/tmp/background.pid
function background(){
echo "Running in background: $@"
nohup "$@" > /dev/null 2>&1 & echo $! > $TMP_PID_PATH
disown -a
}
alias background="background"
alias background-pid="cat \$TMP_PID_PATH"
alias background-kill="pkill -F \$TMP_PID_PATH"
@ZappaBoy
ZappaBoy / mangodlpdf.sh
Created July 29, 2022 22:52
Manga pdf download
# This is a really simple script that work with mangodl
# Please check and support it: https://github.com/Gyro7/mangodl
# Afted downloaded mangodl set a default directory if you prefer:
# mangodl --directory "$HOME/Documents/manga"
# Usages:
#
# Download only first chapter
# mangodlpdf "Chainsaw Man"
@ZappaBoy
ZappaBoy / pdf2gif.sh
Created June 14, 2022 22:48
PDF to gif - pdf2gif
# This script convert pdf to a gif
# First parameter is the .pdf file and the second (optional) parameter is the delay between the images
# Hint:
# instead of copy the script simply add the pdf-to-gif function to your ~/.bash_aliases
# and add the line: alias pdf2gif="pdf-to-gif"
# Example:
#
# function pdf-to-gif(){
# mkdir -p /tmp/pdf2gif/