Skip to content

Instantly share code, notes, and snippets.

View Inobtenio's full-sized avatar

Kevin Martin Inobtenio

View GitHub Profile
@Inobtenio
Inobtenio / extractor.py
Created October 20, 2025 07:28
Takes a look at an image and returns the most dominant/eye-catching color trying to mimic Spotify's way of picking a color for the lyrics background and whatnot. More info at https://inobtenio.com/posts/spotify-song-colors/.
import math
import numpy as np
from PIL import Image
from sklearn.cluster import KMeans
qC = 4.9226
qD = 1.4060
qR = 0.7932
def calculate_dark_colorfulness(rgb):
@Inobtenio
Inobtenio / server.py
Last active October 20, 2025 07:27
updater gets what's playing on Spotify, looks at the album cover and extracts the most dominant/eye-catching color as well as the track data, server serves said data alongside a preformatted album cover for its use in the Vobot Mini Dock. More info at https://inobtenio.com/posts/vobot-mini-dock-spotify/.
import json
from flask import Flask, send_from_directory
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class CurrentSong(Resource):
def get(self):
with open('data.json') as f:
@Inobtenio
Inobtenio / make-service
Created September 9, 2019 00:13
Simple CLI tool to create a systemd service that executes on boot from any command. Usage: sudo bash make-service [name] [description] [command]
#!/bin/bash
cat > "/etc/systemd/system/${1}.service" << EOF
[Unit]
Description=$2
After=network-online.target
[Service]
Type=simple
User=%i
@Inobtenio
Inobtenio / playback.js
Last active January 18, 2018 19:34
Control video playback with your keys in case is not supported natively
$(document).keydown(function(event){
var player = $('video')[0]
if (event.keyCode == 39 || event.keyCode == 68){
player.currentTime = player.currentTime + 10
} else if (event.keyCode == 37 || event.keyCode == 65){
player.currentTime = player.currentTime - 10
} else if (event.keyCode == 32){
event.preventDefault();
if (player.paused){
player.play()
@Inobtenio
Inobtenio / dinoBot.js
Created October 27, 2017 03:42
A bot for the Google Chrome dinosaur game
var checkPixels = function(){
var pixelData = document.getElementsByClassName('runner-canvas')[0].getContext('2d').getImageData(220, 230, 1, 1).data;
if (pixelData.some(function(e) {return e>0})){
Runner.instance_.tRex.startJump()
}
}
var interval = setInterval(checkPixels, 10)
@Inobtenio
Inobtenio / goto
Created September 20, 2017 03:22
saveproj saves the project name and location to a file. goto takes you to the project you are looking for.
#!/bin/bash
RED='\033[0;31m'
PROJECT_NAME=$1
PROJECTS_REPOSITORY_FILE_FULL_PATH="/path/to/saveproj/output/file"
PROJECTS_FOLDER_FULL_PATH="/path/to/your/projects/folder"
if ! line=$(grep "\<$PROJECT_NAME\>" $PROJECTS_REPOSITORY_FILE_FULL_PATH)
then
echo -e "${RED}$PROJECT_NAME not found in projects list. You can create one by using the saveproj tool."
else
directory_name=${line##* }