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 / 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 / mailthisto-example.html
Last active September 11, 2023 08:00
Mailthis.to Example
<form action="https://mailthis.to/example" method="POST" encType="multipart/form-data">
<h3>Contact Form (example)</h3>
<!-- Name -->
<input type="email" name="name" placeholder="Your name">
<!-- Email -->
<input type="email" name="email" placeholder="you@mail.com">
<!-- Phone Number -->
<input type="text" name="phone" placeholder="+1 (255) 555-5555">
<!-- Textarea (Message) -->
<textarea name="message" placeholder="Enter your message here" style="height:90px"></textarea>
@kidGodzilla
kidGodzilla / invert-binary-tree.js
Created May 28, 2016 19:42
Invert a Binary Tree in Javascript
// This problem was inspired by this original tweet by Max Howell:
// Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fuck off.
// So, let's invert a binary tree in Javascript
// Original Tree
// 4
// / \
// 2 7
// / \ / \
@kidGodzilla
kidGodzilla / is-working-hours.js
Last active July 31, 2023 04:22
Is currently during working hours (Javascript)
// Example config for 9-5, M-F, PST (US)
var config = {
0: {
open: 1,
close: 0
},
1: {
open: 9,
close: 17
},
@kidGodzilla
kidGodzilla / openai-chat-completion.js
Last active June 17, 2023 04:26
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);
}
@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 / mailthisto-ajax-example.js
Last active April 26, 2023 19:57
MailThis.to Ajax Example
// The following example POSTS data to mailthis.to, redirects the user to a confirmation page, and then sends an email (upon the successful completion of Recaptcha verification)
$.post('https://mailthis.to/test@example.com', {
email: 'foo@bar.co',
_subject: 'hi!',
message: 'Test'
}).then(function () {
location.href = 'https://mailthis.to/confirm'
});
@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 / list_cookies.js
Created February 8, 2023 03:54
List cookies for current domain
var cookies = await cookieStore.getAll();
for (var i in cookies) {
var c = cookies[i];
if (c.domain === location.host || c.domain === location.host.replace('www.', '') || c.domain === location.host.replace('www', '')) {
console.log(c.name);
}
}
@kidGodzilla
kidGodzilla / country_code_to_name.js
Created June 26, 2022 16:16
Country code to name
function countryCodeToName(code) {
const data = {
"AD": "Andorra",
"AE": "United Arab Emirates",
"AF": "Afghanistan",
"AG": "Antigua and Barbuda",
"AI": "Anguilla",
"AL": "Albania",
"AM": "Armenia",
"AO": "Angola",