Skip to content

Instantly share code, notes, and snippets.

View kopiro's full-sized avatar

Flavio Maria De Stefano kopiro

View GitHub Profile
/**
* Helper to sum an array
*/
function sum(array) {
return array.reduce((carry, e) => (carry += e), 0);
}
/**
* This procedure will build all possible combinations of K elements by making sure we never go into the
* branches where the sum of the sub-list is greater than T.
@kopiro
kopiro / geoguessr_flag_replacer.js
Created June 25, 2021 16:16
Geoguessr Flag replacer
const CCC = [{"name":"Afghanistan","alpha-2":"AF","country-code":"004"},{"name":"Åland Islands","alpha-2":"AX","country-code":"248"},{"name":"Albania","alpha-2":"AL","country-code":"008"},{"name":"Algeria","alpha-2":"DZ","country-code":"012"},{"name":"American Samoa","alpha-2":"AS","country-code":"016"},{"name":"Andorra","alpha-2":"AD","country-code":"020"},{"name":"Angola","alpha-2":"AO","country-code":"024"},{"name":"Anguilla","alpha-2":"AI","country-code":"660"},{"name":"Antarctica","alpha-2":"AQ","country-code":"010"},{"name":"Antigua and Barbuda","alpha-2":"AG","country-code":"028"},{"name":"Argentina","alpha-2":"AR","country-code":"032"},{"name":"Armenia","alpha-2":"AM","country-code":"051"},{"name":"Aruba","alpha-2":"AW","country-code":"533"},{"name":"Australia","alpha-2":"AU","country-code":"036"},{"name":"Austria","alpha-2":"AT","country-code":"040"},{"name":"Azerbaijan","alpha-2":"AZ","country-code":"031"},{"name":"Bahamas","alpha-2":"BS","country-code":"044"},{"name":"Bahrain","alpha-2":"BH","count
import json
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("socket.cryptohack.org", 13372))
s.recv(64)
s.sendall(b'{"option": "encrypt_data", "input_data": "0000000000000000000000000000000000000000000000000000000000000000"}')
data = json.loads(s.recv(64))
key = bytes.fromhex(data['encrypted_data'])
@kopiro
kopiro / switch-groups-hue.sh
Created March 15, 2021 19:12
Switch a Philips Hue group on/off
#!/bin/bash
key=''
url="http://Philips-Hue.local/api/$key/groups/3"
/usr/bin/curl "$url/action" -X PUT -d "{\"on\":$(/usr/bin/curl "$url" | /usr/local/bin/jq "if (.state.all_on) then false else true end")}"
import base64
import json
import socket
import math
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("socket.cryptohack.org", 13370))
data = s.recv(9)
mappina = []
@kopiro
kopiro / nef-to-jpg.sh
Created February 3, 2021 16:03
NEF to JPG converter
mkdir -p ./JPG
find . -name "*.NEF" -print0 | xargs -0 -P "$(sysctl -n hw.ncpu)" -I file sips -s format jpeg file --out ./JPG/file.jpg
@kopiro
kopiro / README.md
Last active April 10, 2022 20:57
RATV - RetroPie Apple TV
@kopiro
kopiro / git-oncommits.sh
Last active February 3, 2021 16:00
GIT notifications
#!/bin/bash
# For Windows, install https://github.com/Windos/BurntToast first
# Setup
PROJECT_DIR=~/Desktop/test-git
BRANCH_NAME="main"
CHECK_SEC=30
# End setup
@kopiro
kopiro / atv-emulator.sh
Last active December 19, 2020 15:51
Apple TV on Raspberry PI emulator
#!/bin/bash
pkill -f rpiplay
pkill -f simple-atv-aerial
rpiplay -n Mela -a hdmi -b auto -I &
simple-atv-aerial &
connected=0
/**
* Return a table string representation of the matrix
* @param {Array} matrix The matrix
* @param {String} prop The property to print
*/
function stringifyMatrix(matrix, prop = "originalValue") {
return matrix
.map((e) => e.map((e) => (prop === "" ? String(e) : e[prop])))
.join("\n")
.replace(/\,/g, " ");