Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

# Use to merge docker files together and output them as one single file.
# Usage: python docker_compose_combine.py -f docker-compose1.yaml -f docker-compose2.yaml
# Courtesy of our good friend ChatGPT.
import argparse
import yaml
from collections import OrderedDict
// Compare two tuples for array.sort(); i.e. returns 1 if first item is larger; 2 if second item is larger, using the < operator.
// Similar to the std::tie comparison in c++: https://bajamircea.github.io/coding/cpp/2017/03/10/std-tie.html
type Comparable = number | string;
const tupleCompare = (a: Comparable[], b: Comparable[]) => {
return a.reduce((prev, el, idx) => {
if (prev != 0) return prev;
else {
if (el > b[idx]) return 1;
else if (el < b[idx]) return -1;
@acenturyandabit
acenturyandabit / ipynb_cache.py
Last active February 3, 2024 00:11
ipynb cache
from typing import Dict, List, Any
import inspect
Result = Any
global_run_cache: Dict[int, Result] = {}
def cached_function(fn):
def wrapper(*args, **kwargs):
global global_run_cache
consty_types = [str, int, float]
@acenturyandabit
acenturyandabit / dblclick.js
Created September 3, 2020 14:02
in case double click doesnt work for some reason
(() => {
Element.prototype.pre_doubleclick_addEventListener = Element.prototype.addEventListener;
Element.prototype.addEventListener = function (ename, fn) {
let clickCount = 0;
let singleClickTimer = 0;
if (ename == "dblclick") {
this.pre_doubleclick_addEventListener("click", (e) => {
clickCount++;
if (clickCount == 1) {
singleClickTimer = setTimeout(function () {
#import modules
import os.path
from gensim import corpora
from gensim.models import LsiModel
from nltk.tokenize import RegexpTokenizer
from nltk.corpus import stopwords
from nltk.stem.porter import PorterStemmer
from gensim.models.coherencemodel import CoherenceModel
from multiprocessing import freeze_support
import matplotlib.pyplot as plt
people
history
way
art
world
information
map
two
family
government
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Praesent at malesuada mi.
Quisque suscipit, arcu non viverra iaculis, magna sapien consequat quam, non fringilla nunc nunc at leo.
Etiam rhoncus non ligula non finibus.
Phasellus congue tincidunt tortor aliquet volutpat.
Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Maecenas eget nisi mi.
Sed congue aliquam viverra.
Pellentesque quis lectus velit.
Cras consequat velit sed ante viverra blandit.
@acenturyandabit
acenturyandabit / sampletext.txt
Created October 13, 2019 11:21
Sample text.
[Intro]
[Verse 1]
We're no strangers to love
You know the rules and so do I
A full commitment's what I'm thinking of
You wouldn't get this from any other guy
[Pre-Chorus 1]
I just wanna tell you how I'm feeling
@acenturyandabit
acenturyandabit / smartloop.py
Created March 20, 2019 05:32
python smart audio looper
#!/usr/bin/env python
import os
import librosa
import random
import pyaudio
import numpy as np
import time
p = pyaudio.PyAudio()
# Open stream with correct settings
var date_parser_regexes = {
time: /(?:(?:(\d+)\/(\d+)(?:\/(\d+))?)|(?:(\d+):(\d+)(?::(\d+))?\s*|(am|pm)))/g,
hourOnlyTime: /^(\d+)(am|pm)/g,
dayofweek: /(?:(mon)|(tue)s*|(?:(wed)(?:nes)*)|(?:(thu)r*s*)|(fri)|(sat)(?:ur)*|(sun))(?:day)*/ig,
plusTime: /\+(\d+)(?:(m)(?:in)*|(h)(?:ou)*(?:r)*|(d)(?:ay)*|(w)(?:ee)*(?:k)*|(M)(?:o)*(?:nth)*|(y(?:ea)*(?:r)*))/g,
done: /done/g,
auto: /auto/g,
now: /now/g,
waiting: /waiting/g,