Skip to content

Instantly share code, notes, and snippets.

View connebs's full-sized avatar
💭
Probably working

Connor connebs

💭
Probably working
View GitHub Profile
@connebs
connebs / naturalSortCaseSensitive.ts
Created September 27, 2024 03:39
A Better (case-sensitive) Natural Sort
const numericRegex = /^\d+/;
export function naturalSortCaseSensitive(a: string, b: string) {
let aIndex = 0;
let bIndex = 0;
while (aIndex < Math.max(a.length, b.length)) {
// if either slice is a number, use regex to find the entire number and compare
const aNumericMatch = a.slice(aIndex).match(numericRegex);
const bNumericMatch = b.slice(bIndex).match(numericRegex);
if (aNumericMatch && !bNumericMatch) return -1;
if (!aNumericMatch && bNumericMatch) return 1;
@connebs
connebs / poster_merger.py
Created September 8, 2024 02:52
A simple script to scrape specified French movie poster images and automatically fetch english posters from TMDB and merge them together
import os
import httpx
from wand.image import Image
french_poster_urls = {
"step_up": "https://fr.web.img4.acsta.net/c_1240_1680/medias/nmedia/18/62/86/83/18673315.jpg",
"step_up_2": "https://fr.web.img6.acsta.net/c_1240_1680/medias/nmedia/18/65/68/91/18926786.jpg",
"friends_with_benefits": "https://fr.web.img4.acsta.net/c_1240_1680/medias/nmedia/18/82/69/35/19757410.jpg",
@connebs
connebs / supernotesApiExample.js
Last active June 2, 2023 15:32
Demonstrate creating cards (simply), finding them again (using filtered select), and then modifying them using the Supernotes API.
// please note that this script contains limited error / success checking,
// and a production script should probably have more (e.g. checking the
// status of requests before you try to do things with the data)
const baseUrl = 'https://api.supernotes.app/v1'
const apiKey = 'MY_API_KEY'
const headers = new Headers({
'Api-Key': apiKey,
'Content-Type': 'application/json',
### Keybase proof
I hereby claim:
* I am acnebs on github.
* I am acnebs (https://keybase.io/acnebs) on keybase.
* I have a public key ASDj6KPjZAfkrFTKybH21srwh4FZ_Dr2W5vgBd5mMiZemwo
To claim this, I am signing this object:
@connebs
connebs / flatten.js
Last active June 1, 2020 16:36
Flatten a nested object into a flat object keyed by path strings
const flatten = (obj, flattened, prevStringKey) => {
Object.entries(obj).forEach(([key, value]) => {
const stringKey = prevStringKey ? `${prevStringKey}.${key}` : key;
if (typeof value === 'object') {
flattened = flatten(value, flattened, stringKey);
} else {
flattened[stringKey] = value;
}
});
return flattened;
@connebs
connebs / getClosestColorName.js
Last active November 22, 2019 11:21
Takes a hex color value and spits out a color based on some simple parameters
const greyThresh = 0.2;
const bwDelta = 20;
const hueMap = {
0: "red",
60: "yellow",
120: "green",
180: "teal",
240: "blue",
300: "purple",
360: "red"
@connebs
connebs / webpack.config.js
Created July 10, 2019 15:53
Override CRA config in storybook
const DirectoryNamedWebpackPlugin = require('directory-named-webpack-plugin');
const findBabelLoader = config =>
config.module.rules.findIndex(
rule => rule.use && rule.use[0] && rule.use[0].loader && rule.use[0].loader.includes('babel')
);
const addBabelPlugin = plugin => config => {
config.module.rules[findBabelLoader(config)].use[0].options.plugins.push(plugin);
return config;
@connebs
connebs / ClassfulBlueprint.py
Last active April 7, 2021 14:01
Subclass of `flask_rest_api.Blueprint` that is compatible with `flask_classful`
from flask_rest_api import Blueprint
class ClassfulBlueprint(Blueprint):
"""A subclass of flask_rest_api.Blueprint that stores endpoint documentation
not using :meth: `Blueprint.route` but instead with :meth: `Blueprint.add_url_rule`.
Since :meth: `Blueprint.route` should never be used from a `ClassfulBlueprint`
instance, it throws an error if you try to call it.
"""
def __getattribute__(self, name):
if name in ['route']:
Verifying my Blockstack ID is secured with the address 1B3YrvRZrUMropqYbQvjdqLpraQdAGXMoS https://explorer.blockstack.org/address/1B3YrvRZrUMropqYbQvjdqLpraQdAGXMoS