Skip to content

Instantly share code, notes, and snippets.

View pioz's full-sized avatar
🧙‍♂️
[object Object]

Enrico pioz

🧙‍♂️
[object Object]
View GitHub Profile
require 'logger'
require 'net/http'
PUSHOVER_USER_KEY = 'xxx'.freeze
PUSHOVER_API_TOKEN = 'xxx'.freeze
def send_notification(message)
uri = URI.parse('https://api.pushover.net/1/messages.json')
request = Net::HTTP::Post.new(uri)
request.set_form_data(
@pioz
pioz / tenants.rb
Last active April 23, 2024 07:49
Tenants
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'activerecord'
gem 'mysql2'
end
require 'active_record'
@pioz
pioz / caffe.py
Last active February 9, 2024 15:50
Run caffeinate from Mac OS X menu bar
import rumps
import subprocess
class CaffeinateApp(rumps.App):
def __init__(self):
super(CaffeinateApp, self).__init__("Caffeinate")
self.icon = "inactive_icon.png"
self.caffeinate_process = None
self.menu = ["Run Caffeinate"]
@pioz
pioz / amazon.rb
Last active February 6, 2024 11:51
Ruby script to get Amazon expenses
require 'date'
regexp = /(\d{1,2} \w+ \d{4})|(?:-EUR (\d+,\d{2}))/
results = DATA.read.scan(regexp)
expenses = Hash.new { 0 }
date = nil
results.each do |str_date, str_amount|
date = Date.parse("0#{str_date}").strftime("%B-%Y") if str_date
if str_amount
@pioz
pioz / muffin.txt
Last active November 28, 2023 14:08
Ricetta Muffin con gocce di cioccolato
Ricetta per 36 muffin
* 375g di burro
* 800g di farina
* 400g di zucchero
* 400g di latte
* 300g di gocce di cioccolato
* 6 uova
* 2 bustine di vanillina
* 2 pizzichi di sale
@pioz
pioz / one_piece_downloader.rb
Last active September 6, 2023 18:45
One Piece Downloader
require 'open-uri'
require 'tty-progressbar'
CONCURRENCY = 8
FIRST_EPISODE_NUMBER = 1
LAST_EPISODE_NUMBER = 628
def get_bounds(episode_number)
episode_number = 1 if episode_number < 1
lower_bound = ((episode_number - 1) / 100) * 100 + 1
@pioz
pioz / autoclick.c
Last active July 10, 2023 15:24
Autoclick
// Written by Pioz.
// Compile with: gcc -o autoclick autoclick.c -lX11
#include <stdio.h> // printf, fprintf and fflush
#include <string.h> // memset
#include <unistd.h> // sleep and usleep
#include <X11/Xlib.h> // X11
#include <X11/Xutil.h> // XGetPixel and XDestroyImage
// Simulate mouse click
@pioz
pioz / edit_rails.md
Created March 21, 2023 09:46
Inflections on rails new
nano ~/.rbenv/versions/3.2.0/bin/rails

Add these lines before load Gem...:

require 'active_support'
ActiveSupport::Inflector.inflections { |inflect| inflect.acronym 'CT' }
@pioz
pioz / keymap_gmmk_pro.c
Last active November 28, 2022 16:40
QMK pioz keymap
/* Copyright 2021 Glorious, LLC <salman@pcgamingrace.com>
Copyright 2021 Pioz <epilotto@gmx.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@pioz
pioz / painting_height.md
Last active November 22, 2022 13:01
Perfect height to hang a painting

For hanging pictures I really like to follow the midline style. In practice an imaginary line is drawn on the wall which is at 5/8 the height of the wall itself. Once we have this line in mind the paintings must be hung with 3/8 of their height above the median line.

h = (H*5 + q*3) / 8

where H is the height of the wall and q is the height of the painting itself.