Skip to content

Instantly share code, notes, and snippets.

package Proc::Knife;
use strict;
use warnings;
use v5.36;
use Exporter 'import';
use POSIX ":sys_wait_h";
our @EXPORT_OK = qw(knife);
import numpy as np
import simpleaudio as sa
import threading
import time
def play_tone(freq, dur, delay):
# Wait for the specified delay before playing the tone
time.sleep(delay)
# Sample rate (samples per second)
from __future__ import print_function
import sys
# Some color codes for terminals.
# You just print the text and color codes, and print rst to
# send the color reset sequence.
# The color sequence names are in the first bit of code below.
# Usually, just use with something like:
#!/usr/bin/env python3
# gist-paste -u https://gist.github.com/jaggzh/e9a5b31afc218b8d44fd5ddb976c8c96 bansi.py kbnb.py audiosplit.py
import librosa
import numpy as np
import random
from typing import Generator
import matplotlib.pyplot as plt
from bansi import *
import kbnb
import re
bgbla=''; bgred=''; bggre=''; bgbro='';
bgblu=''; bgmag=''; bgcya=''; bggra='';
bla=''; red=''; gre=''; bro='';
blu=''; mag=''; cya=''; gra='';
bbla=''; bred=''; bgre=''; yel='';
bblu=''; bmag=''; bcya=''; whi='';
rst=''; inv=''; cll=''; cllr='';
cls=''; clsb='';
bgblae='\033[40m'; bgrede='\033[41m'; bggree='\033[42m'; bgbroe='\033[43m';
# datagen.py
import numpy as np
import librosa
def load_audio_chunk(audio_path, start_frame, dur_s, sr):
# Load a specific chunk of the audio file
audio, _ = librosa.load(audio_path, sr=sr, mono=True, offset=start_frame/sr, duration=dur_s)
return audio
def preprocess_audio(audio_data):
/* gist-paste -u https://gist.github.com/jaggzh/7b483b183562db31bde6f9bc972f126e manifest.json content-script.js */
(function() {
const accentColor = `#f39c12`;
const messagesCss = `
/* Message body width */
@media (min-width: 1280px) {
.xl\\:max-w-3xl {
max-width: 90% !important;
}
#include <stdint.h>
#include <cfloat> // FLT_MIN FLT_MAX
#include "driver/adc.h" // use esp-idf directly
#define OPT_PLOT_DATA
/* #define OPT_PLOT_COUNT */
#define US_PER_SAMP 45
#define US_PER_60HZ_CYCLE 8333
/* #define BS 120 */
#define BS 150
// Ultrasonic module: HC - SR04
const int US1TRIGPIN = 12;
const int US1ECHOPIN = 13;
//define sound speed in cm/uS
#define SOUND_SPEED 0.034
#define CM_TO_INCH 0.393701
#define UL unsigned long
#define SUL static unsigned long
#include <stdint.h>
#include <cfloat> // FLT_MIN FLT_MAX
#include "driver/adc.h" // use esp-idf directly
#include "printutils.h"
#include "median.h"
#include "wifi.h"
#include "wifi_config.h"
#include "ota.h"
#include "netdata.h"