Skip to content

Instantly share code, notes, and snippets.

View b-bot's full-sized avatar
🛸

Byron Polley b-bot

🛸
View GitHub Profile
@b-bot
b-bot / router.ts
Created May 29, 2024 07:55
S3 Backend Upload
import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3';
import {
MetadataAttributeType,
ProfileMetadataSchema,
profile,
} from '@lens-protocol/metadata';
import { v4 as uuidv4 } from 'uuid';
import { z } from 'zod';
import { env } from '~/env';
@b-bot
b-bot / flightcontrol.yml
Created September 5, 2023 10:34
Flightcontrol Webhook GitHub Action
name: Flightcontrol Webhook Deployment
env:
DEPLOYMENT_URL: ""
on: workflow_dispatch
jobs:
backend-deploy:
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
@b-bot
b-bot / build-id.route.ts
Created November 15, 2022 18:49
Problematic Lambdas
import type { NextApiRequest, NextApiResponse } from "next"
import { withSentry } from "@sentry/nextjs"
import { BUILD_ID } from "constants/frontend"
const handler = (_req: NextApiRequest, res: NextApiResponse) => {
res.status(200).json({
buildId: BUILD_ID,
})
}
// The `CreateCollection` is similar to `CREATE TABLE ` in SQL. The same for `CreateIndex`.
CreateCollection({name: "artists"});
CreateCollection({name : "songs"});
CreateCollection({name : "albums"});
// We are emulating the primary keys of each respective table by specifying unique as true.
CreateIndex({name : "artists_by_id", source : Collection("artists"), terms : [ {field : [ "data", "artist_id" ]} ], unique : true})
CreateIndex({name : "songs_by_id", source : Collection("songs"), terms : [ {field : [ "data", "song_id" ]} ], unique : true})
@b-bot
b-bot / getUrlParameterByName.js
Created July 25, 2019 08:16
REGEX-based solution to getting any parameter in a given URL by passing `name`.
getParameterByName(name: string, url: string) {
if (!url) { url = window.location.href; }
name = name.replace(/[\[\]]/g, '\\$&');
const regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
if (!results) { return null; }
if (!results[2]) { return ''; }
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
@b-bot
b-bot / FizzBuzz.js
Created July 25, 2019 08:12
The solution to the basic "FizzBuzz" test used in first time interviews.
for (var i=1; i <= 100; i++) {
if (i % 15 == 0)
console.log("FizzBuzz");
else if (i % 3 == 0)
console.log("Fizz");
else if (i % 5 == 0)
console.log("Buzz");
else
console.log(i);
@b-bot
b-bot / Romanizer.js
Created July 25, 2019 08:09
Function to convert any number to roman numerals. eg. 10 = X
var numeralCodes = [["","I","II","III","IV","V","VI","VII","VIII","IX"], // Ones
["","X","XX","XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"], // Tens
["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"]]; // Hundreds
function convert(num) {
var numeral = "";
var digits = num.toString().split('').reverse();
for (var i=0; i < digits.length; i++){
numeral = numeralCodes[i][parseInt(digits[i])] + numeral;
}
@b-bot
b-bot / ordinalSuffix.js
Last active July 25, 2019 08:06
Get the ordinal suffix for any number you want converted to a day. ie. suffixes -st, -nd, -rd, -th in written ordinals (represented as 1st, 2nd, 3rd, 4th)
function ordinalSuffix(i) {
const j = i % 10,
k = i % 100;
if (j === 1 && k !== 11) {
return i + 'st';
}
if (j === 2 && k !== 12) {
return i + 'nd';
}
if (j === 3 && k !== 13) {
@b-bot
b-bot / Hacked Smoothscroll in JQuery.js
Created July 25, 2019 07:40
A quick and dirty way to add smoothscroll to all hashlinks in your file without adding additional dependancies.
$('a[href*="#"]:not([href="#"], [href="#carousel"])')
.click(function() {
if (location.pathname.replace(/^\//, '') ===
this.pathname.replace(/^\//, '') &&
location.hostname === this.hostname) {
var target = $(this.hash);
target = target.length ? target :
$('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html, body').animate({
$ brew install putty
Place the two keys in the .ssh folder in the user directory.
Now convert the PPK keys to SSH keypairs
$ cd ~/.ssh
Private key generation:
$ puttygen id_rsa.ppk -O private-openssh -o id_rsa