Skip to content

Instantly share code, notes, and snippets.

View ddrscott's full-sized avatar

Scott Pierce ddrscott

View GitHub Profile
@ddrscott
ddrscott / LICENSE
Last active November 15, 2024 15:23
Checks files in the specified directory and determines if changes have occurred within the given age limit
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
@ddrscott
ddrscott / txt2img.py
Last active February 20, 2024 22:20
Generate Image from Text using Together API Generate Image
#!/usr/bin/env python3
"""
Generate Image from Text using Together API Generate Image
## requirements.txt
click
requests
pillow
piexif
"""
@ddrscott
ddrscott / cf-gpt.sh
Created November 22, 2023 19:02
Cloudflare AI inference API
#!/bin/sh
# message can come from script args or environment
message=${message:-"${*}"}
model=${model:-"@cf/mistral/mistral-7b-instruct-v0.1"}
system=${system:-"You are a consice AI assistant. You help the user the best you can. If you don't know something, you admin it and ask clarifying questions. Use markdown as needed."}
post_data=$(cat <<JSON
{"messages":[{"role":"system","content":"${system}"},{"role":"user","content":"${message}"}],"max_tokens":10240,"stream":true}
JSON
)
#!/usr/bin/env python3
"""
Requirements:
pip install click langchain openai
Environment Variables:
OPENAI_API_KEY=...
"""
import sys
import click
@ddrscott
ddrscott / auto.py
Last active August 29, 2023 21:55
#!/usr/bin/env python3
"""
Requirements:
pip install click langchain openai
"""
import sys
import click
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
class CustomHandler(StreamingStdOutCallbackHandler):
def on_llm_start(self, serialized, prompts, **_) -> None:
import torchaudio
from speechbrain.pretrained import Tacotron2
from speechbrain.pretrained import HIFIGAN
# Intialize TTS (tacotron2) and Vocoder (HiFIGAN)
tacotron2 = Tacotron2.from_hparams(source="speechbrain/tts-tacotron2-ljspeech", savedir="tmpdir_tts")
hifi_gan = HIFIGAN.from_hparams(source="speechbrain/tts-hifigan-ljspeech", savedir="tmpdir_vocoder")
# Running the TTS
mel_output, mel_length, alignment = tacotron2.encode_text("This is an open-source toolkit for the development of speech technologies.")
(() => {
const className = 'dataturd-sidebar';
function openIframe(url) {
if ( document.querySelector('.' + className) ) {
console.log('Sidebar already exists');
return
}
var styleTag = document.createElement('style');

Prompt

I want to create a FFT visualization in a single page web app. Please separate the HTMLCSS in JavaScript. The canvas should fill up the entire bottom of the screen. Provide a button at the top to start and stop recording. The FFT should be based on web audio taking microphone recordings.

Code

<!DOCTYPE html>
<html>
  <head>
"""
Prompt: Help me create Python script to play connect four against a computer ai opponent.
"""
# Define the game board
board_rows = 6
board_cols = 7
# Define the evaluation function for the minimax algorithm
def evaluate_window(window, piece):
@ddrscott
ddrscott / Makefile
Created January 3, 2023 17:41
Compile a bunch of pixel art frames into an animated gif.
frames=$(shell ls -tr bouncing-ball/*.png)
bouncing-ball.gif: $(frames)
convert -delay 12 -loop 0 -dispose previous -resize 256x -filter Point $(frames) $@