Skip to content

Instantly share code, notes, and snippets.

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

Enrico pioz

🧙‍♂️
[object Object]
View GitHub Profile
@pioz
pioz / populate.rb
Last active September 19, 2022 07:25
Active Record in script
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'activerecord'
gem 'pg'
end
require 'active_record'
@pioz
pioz / install_ortools.sh
Last active September 12, 2022 08:35
Install ortools on OSX M1
git clone https://github.com/google/or-tools.git
cd ./or-tools
cmake -S. -Bbuild -DBUILD_PYTHON=ON -DPython3_ROOT_DIR="/opt/homebrew/Cellar/[email protected]/3.9.10/"
cmake --build build -j8 -v
pip3 install ./build/python/dist/ortools-9.2.9974-cp39-cp39-macosx_12_0_arm64.whl
@pioz
pioz / query.md
Created May 4, 2022 13:50
Select products and order by converted price currency
SELECT price_cents FROM products ORDER BY price_cents * ('{"EUR": 2.0}'::jsonb->'EUR')::jsonb::numeric;
@pioz
pioz / qmk.md
Last active June 9, 2022 10:18
compile qmk firmware

Install qmk

brew install qmk/qmk/qmk

Config qmk environment

qmk config user.keyboard=gmmk/pro/rev1/ansi
qmk config user.keymap=pioz
@pioz
pioz / keymap_gmmk_pro.c
Last active November 28, 2022 16:40
QMK pioz keymap
/* Copyright 2021 Glorious, LLC <[email protected]>
Copyright 2021 Pioz <[email protected]>
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 / sheets.rb
Created September 8, 2021 06:51
Read Google sheets
# gem install google-apis-sheets_v4
require 'google/apis/sheets_v4'
scope = Google::Apis::SheetsV4::AUTH_SPREADSHEETS.freeze
spreadsheets_id = '1ga77r2sjPYTSLGh1IXClnGPvdqFAmkRf-Z5akqfpFEo'.freeze
authorizer = Google::Auth::ServiceAccountCredentials.make_creds(
json_key_io: File.open('./credentials.json'),
scope: scope
)
@pioz
pioz / memcache.go
Created March 5, 2021 14:04
Restore array of structs from memcache in GO
package main
import (
"bytes"
"encoding/gob"
"fmt"
"github.com/bradfitz/gomemcache/memcache"
)
@pioz
pioz / .bash_profile
Last active January 11, 2022 16:51
Pioz Bash prompt customization
parse_git_branch() {
test -d .git && echo "($(git rev-parse --abbrev-ref HEAD)) "
}
# PS1='\u@\h:\W $(parse_git_branch)\$ ' without colors
PS1='\e[0;33m\u@\h\e[m:\W \e[0;36m$(parse_git_branch)\e[m\e[0;33m\$\e[m '
@pioz
pioz / cover.sh
Created September 30, 2020 17:37
Golang test coverage
go test -coverprofile cover.out
go tool cover -html=cover.out
@pioz
pioz / enkin.txt
Last active January 11, 2022 16:49
D&D Enkin PG description
Enkin è un mago. Ha passato molti anni a studiare presso svariate accademie di
magia in tutto l'occidente. Nonostante la sua ampia conoscenza teorica sulla
magia è uno pratico. È sfacciato di fronte al pericolo, gli piace rischiare,
impulsivo nelle scelte ed è disposto a qualsiasi cosa per difendere i suoi
compagni e per portare a termine la sua missione. La magia per Enkin è una
passione, vive per la magia, e forse per lui è anche una ossessione. Quando si
mette in viaggio in cerca di avventura, non lo fa per la gloria, la fama o il
danaro, lo fa per aumentare il suo sapere magico, scoprire nuovi incantesimi,
perfezionare la sua arte magica. Possiamo dire che se si trovasse di fronte a
un djinn e dovesse esprimere 3 desideri il primo sarebbe diventare il più