Skip to content

Instantly share code, notes, and snippets.

View un1tz3r0's full-sized avatar
🕶️
acting natural

Victor Condino un1tz3r0

🕶️
acting natural
View GitHub Profile
@un1tz3r0
un1tz3r0 / prect.py
Created March 18, 2019 06:05
Some helpers for drawing fancy graphics in PyGame. Code mostly borrowed from elsewhere, cobbled together and missing functionality added where it was needed.
"""
Rounded rectangles for PyGame in both non-antialiased and antialiased varieties. 2019 edition... now with anti-aliased alpha support!
"""
import pygame
import pygame as pg
from pygame import gfxdraw
from collections import abc
def round_rect(surface, rect, color, rad=20, border=0, inside=(0,0,0,0)):
@un1tz3r0
un1tz3r0 / main.py
Created April 7, 2019 04:58 — forked from gear11/main.py
Simple Python proxy server based on Flask and Requests. See: http:/python-proxy-server/gear11.com/2013/12/python-proxy-server/
"""
A simple proxy server. Usage:
http://hostname:port/p/(URL to be proxied, minus protocol)
For example:
http://localhost:8080/p/www.google.com
"""
@un1tz3r0
un1tz3r0 / bookmarklet.js
Created April 10, 2019 06:10 — forked from ctesta01/bookmarklet.js
take me to a random url – a js bookmarklet
javascript:(function(){var links = [
"https://en.wikipedia.org/wiki/Special:Random",
"https://en.wikipedia.org/wiki/Portal:Current_events",
"http://mathworld.wolfram.com/",
"http://functions.wolfram.com/",
"https://en.wikipedia.org/wiki/Portal:Contents/Outlines",
"https://en.wikipedia.org/wiki/Glossary_of_areas_of_mathematics",
"http://mathworld.wolfram.com/classroom/",
"https://en.wikipedia.org/wiki/Lists_of_mathematics_topics",
"https://en.wikipedia.org/wiki/Mathematics_Subject_Classification#First-level_areas",
@un1tz3r0
un1tz3r0 / authorized_keys_cmd.py
Created August 31, 2019 16:02
Script for use as sshd authorized_keys command on DigitalOcean droplets. It pulls the list of public ssh keys from your account profile using DigitalOcean's API, so that you can manage your authorized_keys in one convenient place.
#!/usr/bin/python3
import requests
import json
import os
def get(path):
url = "https://api.digitalocean.com/v2/{}".format(path)
apikey = os.environ['DIGITALOCEAN_API_KEY']
headers = {
@un1tz3r0
un1tz3r0 / svgtoshapes.py
Created February 24, 2020 20:27
shapely svg import
''' Read and parse SVG files returning a shapely GeometryCollection containing the paths and primitives found.
Transforms are applied and all shapes are returned in the SVG root elements coordinate space. Primitives (rect,
circle and ellipse) are converted to equivalent paths, and only shape outlines are rendered, stroke properties
have no affect and are discarded.
Curved paths (arc and bezier commands and rounded rect, ellipse and circle elements) are linearized using a
naive approach that attempts to create enough segments to reduce maximum distance to the curve to below a
certain threshold, although this is probably not very efficient and most likely implemented in a fairly
broken way.'''
@un1tz3r0
un1tz3r0 / youtubemusicdownloader.py
Last active August 23, 2025 18:06
This script uses ytmusicapi and pytube together to download your playlists, history or 'liked' songs as high-quality audio-only streams from Youtube Music.
''' This script uses ytmusicapi and pytube together to download your playlists, history or 'liked' songs as
high-quality audio-only streams from Youtube Music, which are protected by a "signatureCipher" obfuscation scheme.
To use it, first install [ytmusicapi] and [pytube] using pip, then follow the instructions for creating the auth
file from the response in an authenticated session to a watch-page request as found in your browser's dev-tools.
The downloaded files are placed in ~/Music, named with the artist and track metadata, and will be skipped instead
of downloaded again next time it is run, based on the videoIds of the downloaded songs.
Merry Xmas - V.
@un1tz3r0
un1tz3r0 / kmeans_elbow.py
Last active July 27, 2021 04:13
kmeans in pure python
# -------------------------------------------------------------------------------
# a very basic k-means/elbow clustering
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# "wrote this up one day while sitting on the terlet. i do some of my best
# thinking there" - Author - Victor M. Condino - Wednesday, Feb. 3rd, 2020
#
# this is some code to find the optimal clustering of points in a n-dimensional
# dataset, when the number of clusters is not known uses the elbow-method.
#
# (I'd like to dedicate this to my mom, Martha, who knows way more about
@un1tz3r0
un1tz3r0 / catmullFitter.js
Created February 17, 2021 23:48 — forked from nicholaswmin/catmull-rom.js
Catmull Rom Fitting Algorithm in Javascript through a series of X/Y Points
/**
* Interpolates a Catmull-Rom Spline through a series of x/y points
* Converts the CR Spline to Cubic Beziers for use with SVG items
*
* If 'alpha' is 0.5 then the 'Centripetal' variant is used
* If 'alpha' is 1 then the 'Chordal' variant is used
*
*
* @param {Array} data - Array of points, each point in object literal holding x/y values
* @return {String} d - SVG string with cubic bezier curves representing the Catmull-Rom Spline
@un1tz3r0
un1tz3r0 / reindent.py
Last active January 16, 2023 11:32
reindent.py: Fix Python Indent Errors
#!/usr/bin/python3
'''
reindent.py
this script is a tool for fixing inconsistent indentation when your chosen editor chooses to hose your tabs with a bunch of spaces
'''
import os, sys, argparse
from io import StringIO
@un1tz3r0
un1tz3r0 / for_each_args.cpp
Created May 20, 2021 10:48 — forked from elbeno/for_each_args.cpp
Functions that work over their arguments
//------------------------------------------------------------------------------
// A function that will apply a function to each argument
#include <initializer_list>
#include <utility>
template <typename F, typename... Ts>
void for_each_arg(F&& f, Ts&&... ts)
{
using I = std::initializer_list<int>;
(void) I { (std::forward<F>(f)(std::forward<Ts>(ts)), 0)... };