Skip to content

Instantly share code, notes, and snippets.

View ZacharyGodfrey's full-sized avatar

Zachary Godfrey ZacharyGodfrey

View GitHub Profile
@ZacharyGodfrey
ZacharyGodfrey / fizzbuzz-generator.js
Created March 21, 2025 17:21
Implements the classic FizzBuzz logic using a JavaScript generator function
function* fizzBuzz(start = 1) {
let i = start;
while (true) {
const isFizz = i % 3 === 0;
const isBuzz = i % 5 === 0;
const isFizzBuzz = isFizz && isBuzz;
switch (true) {
case isFizzBuzz: yield 'FizzBuzz'; break;

Rename a branch in Git

These instructions assume you're renaming a branch locally and on the server.

Checkout the local branch

git checkout <old_name>

AWS RDS Restore SQL Server DB From S3

S3 Bucket

  • In the AWS Console, go to the S3 service
  • Create an S3 bucket for storing your database backup files
  • Upload a .bak database backup file to the S3 bucket

3D Printing

General Notes

  • Use 3MF files if possible because they're far smaller than STL
  • Set Z to 0.1 mm before leveling with regular printer paper. Then you get the correct distance.

Filament Change

Remove Old Filament

// Sum of Two
(() => {
// Given two arrays of integers and a desired sum,
// determine whether a pair exists such that each
// value in the pair comes from a different array
// and they add up to the desired sum
// left: an array of integers
// right: an array of integers
// sum: an integer
@ZacharyGodfrey
ZacharyGodfrey / keyboardLayout.json
Created February 11, 2020 22:13
Mechanical Keyboard Firmware
{
"keyboard": "idobo",
"keymap": "default_d6184be",
"layout": "LAYOUT_ortho_5x15",
"layers": [
[
"KC_GRV",
"KC_1",
"KC_2",
"KC_3",
@ZacharyGodfrey
ZacharyGodfrey / AirGunOne.md
Last active January 29, 2020 19:45
Documentation for my air gun design.

Air Gun One

This design features an 18 inch barrel with a 0.5 inch diameter, a 3:1 ratio of compression tank volume to barrel volume, and can handle pressures up to 150 PSI (10.3421 Bar).


Design Considerations

Modularity:

@ZacharyGodfrey
ZacharyGodfrey / beaufort-autokey-cipher.js
Last active August 22, 2021 15:52
Beaufort + Autokey cipher with Base64 encoded ASCII output.
// - Expands the 26x26 table to 256x256 to encrypt ASCII text
// - Uses the Beaufort cipher's method of symmetric encryption/decryption using the table
// - Uses the Autokey cipher's method of expanding the encryption key with the plaintext
// - Base64 encodes the resulting ASCII ciphertext for easier display
const beaufortAutokey = (key) => {
const ascii = () => Array.from({ length: 256 }, (_, i) => String.fromCharCode(i)).join('');
const shift = (text) => text.length <= 1 ? text : text.slice(1) + text[0];
const rotate = (text, distance) => Array(distance).fill().reduce(result => shift(result), text);
const base64Encode = (text) => btoa(text);
const fibonacci = (() => {
const memory = [0, 1];
return (index) => {
if (!Number.isInteger(index) || index < 0) return NaN;
while (memory.length < index + 1) {
const right = memory[memory.length - 1];
const left = memory[memory.length - 2];