This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
#%pip install click clip-retrieval img2dataset aiomultiprocess aiohttp aiofile | |
from clip_retrieval.clip_client import ClipClient, Modality | |
import json, pathlib, functools | |
import aiomultiprocess, asyncio, aiohttp, aiofile | |
from aiohttp import request, ClientTimeout | |
from aiomultiprocess import Pool | |
import click |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import socket | |
import os | |
import struct | |
if getattr(socket, "NETLINK_CONNECTOR", None) is None: | |
socket.NETLINK_CONNECTOR = 11 | |
CN_IDX_PROC = 1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def parsesvg(svg_file): | |
from xml.dom import minidom | |
#from svg.path import parse_path | |
#import svg.path | |
#from shapely import geometry as g | |
#from shapely import ops | |
try: | |
with open(svg_file, "r") as f: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------------------------------ | |
// 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)... }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------------------------------------------------------- | |
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' 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.''' |