Skip to content

Instantly share code, notes, and snippets.

View kidGodzilla's full-sized avatar
👋
Working from home forever

James Futhey kidGodzilla

👋
Working from home forever
View GitHub Profile
@kidGodzilla
kidGodzilla / barkov-chain.js
Last active April 21, 2025 08:11
🐶 Barks Endlessly (2nd order markov chain but barking)
// Barks endlessly in your console (Paste it in)
(function () {
class MarkovChainGenerator {
constructor(tokens, order = 2) {
this.order = order;
this.model = new Map();
for (let i = 0; i <= tokens.length - order; i++) {
const key = tokens.slice(i, i + order).join(',');
const next = tokens[i + order];
@kidGodzilla
kidGodzilla / flex-center-component.html
Created March 19, 2025 07:21
Flexbox center a div (wrong answers only)
<script>
class FlexCenter extends HTMLElement {
constructor() {
super();
const shadow = this.attachShadow({ mode: 'open' });
const wrapper = document.createElement('div');
wrapper.classList.add('center');
const slot = document.createElement('slot');
@kidGodzilla
kidGodzilla / chunked-video-uploads.js
Created December 19, 2024 07:40
Chunked video uploads frontend/backend
// Frontend
const fileInput = document.querySelector('input[name="video"]');
const file = fileInput.files[0];
const chunkSize = 10 * 1024 * 1024; // 10MB
const totalChunks = Math.ceil(file.size / chunkSize);
for (let chunk = 0; chunk < totalChunks; chunk++) {
const start = chunk * chunkSize;
const end = Math.min(start + chunkSize, file.size);
const blob = file.slice(start, end);
@kidGodzilla
kidGodzilla / pdf2png.sh
Last active May 20, 2024 07:03
PDF to PNG Script for Quickdrop App
# PDF to PNG shell script for Quickdrop app
# https://quickdrop.antran.app/
# pdfburst shell script
# chmod 0755 pdfburst
#!/usr/bin/swift
import Foundation
import PDFKit
#!/bin/bash
set -e
######################################################################
# This simple backup script generates commands to recreate dokku apps
#
# It creates the app, adds domains, and restores configuration for each app
# It does not handle databases, persistent storage, or other plugin settings
#
# Usage: Run this script on a Dokku server (you must either be logged in as the
#!/bin/bash
set -e
######################################################################
# This Bootstrap Script installs Dokku latest on Ubuntu (use LTS or latest)
#
# This script also installs UFW (firewall), some basic Dokku plugins, and
# raises ulimits. Comment out any step you wish to skip.
#
# IMPORTANT: This script also disables password authentication via SSH for
@kidGodzilla
kidGodzilla / set ulimit
Created March 22, 2024 17:20 — forked from bfgits/set ulimit
Set Permanently ulimit -n / open files in ubuntu
# available limit
user@ubuntu:~$ ulimit -n
1024
# To increase the available limit to say 65535
user@ubuntu:~$ sudo vim /etc/sysctl.conf
# add the following line to it
fs.file-max = 65535
@kidGodzilla
kidGodzilla / sitegptai.js
Last active May 9, 2023 23:01
SiteGPT.AI Unofficial button API
// Script to control SiteGPT.AI chat Interface elements
// Usage:
// _sitegpt.open()
// _sitegpt.hide()
// _sitegpt.show()
// etc.
window._sitegpt = {
is_open: function() { return !document.querySelector('#sitegpt-chat-icon img').src.includes('logo') },
open: function() { if (!_sitegpt.is_open()) { _sitegpt.toggle() } },
close: function() { if (_sitegpt.is_open()) { _sitegpt.toggle() } },
@kidGodzilla
kidGodzilla / retrievalQA.js
Created April 19, 2023 04:44 — forked from linuxandchill/retrievalQA.js
Create and retrieve embeddings using Langchain and Supabase
////////////////////////////////////
/* "dependencies": {
"@supabase/supabase-js": "^2.13.1",
"langchain": "^0.0.44"
} */
////////////////////////////////////
import { OpenAI } from "langchain/llms";
import {
@kidGodzilla
kidGodzilla / openai-chat-completion.js
Last active April 5, 2024 21:15
OpenAI Chat Completion Example
const { Configuration, OpenAIApi } = require('openai');
let openai;
const instructions = ``;
if (process.env.OPEN_AI_API_KEY) {
const configuration = new Configuration({ apiKey: process.env.OPEN_AI_API_KEY });
openai = new OpenAIApi(configuration);
}