Skip to content

Instantly share code, notes, and snippets.

View reconbot's full-sized avatar
🏴‍☠️

Francis Gulotta reconbot

🏴‍☠️
View GitHub Profile
@reconbot
reconbot / importing-exporting-examples.js
Last active May 9, 2025 03:34
CommonJS to ES modules test cases
// CommonJS to ES modules test cases
// Importing
var foo = require('bar');
// becomes
import foo from 'bar';
require('bar')(foo);
// becomes
@reconbot
reconbot / git.sh
Created April 3, 2025 15:51
My git workflow commands
# git checkout main then branch - used to make a new branch from the head of main
gcmb () {
git checkout $(git_detect_main_branch) && git pull origin $(git_detect_main_branch) --ff-only && git checkout -b reconbot/$1
}
# git checkout main pull - go back to main
gcmp: aliased to git checkout $(git_detect_main_branch) && git pull origin $(git_detect_main_branch) --ff-only
# git rebase origin main - move your branch to start from the tip of main
grom: aliased to git fetch && git rebase --autostash origin/$(git_detect_main_branch)
@reconbot
reconbot / createComplexityPlugin.ts
Last active March 4, 2025 23:39
An Apollo Plugin for graphql-query-complexity
import { ComplexityEstimator, getComplexity } from 'graphql-query-complexity'
import { GraphQLError, GraphQLSchema, separateOperations } from 'graphql'
import { PluginDefinition } from 'apollo-server-core'
export const createComplexityPlugin = ({
schema,
maximumComplexity,
estimators,
onComplete,
createError = (max, actual) => { throw new GraphQLError(`Query too complex. Value of ${actual} is over the maximum ${max}.`) },
include <BOSL2/std.scad>
// make it pretty
$fs = $preview ? 1 : 0.1;
$fa = $preview ? 3 : 0.1;
size = 140;
margin = 2;
lip = 15;
lip_thickness = 0.5;

So you want to send a message

Setup

  • Index cards and black markers
  • Two whiteboards
  • Get a volunteer (eventually 3)
  • Networking is divided into 7 layers

Layer 1 Physical

The physical layer is responsible for the actual physical connections between devices. They deal in bits and move bits from one thing (lets call it a node) to another. This is your ethernet cable and your hubs. A hub takes all input and brings it to all outputs.

substitutions:
name: esphome-web-sensors
friendly_name: Sensorbox
esphome:
name: ${name}
friendly_name: ${friendly_name}
min_version: 2024.6.0
name_add_mac_suffix: false
project:
@reconbot
reconbot / batchFetchExchange.ts
Last active May 23, 2024 05:07
A batching exchange for URQL that lets you opt out of batch queries adapted form @jakubriedl's POC This version works on non persisted queries.
// Adapted from https://gist.github.com/jakubriedl/812c2a7b26927a2249a4719555d9a0ca
import DataLoader from 'dataloader'
import { Exchange, Operation } from 'urql'
import { pipe, map } from 'wonka'
interface BatchRequest {
url: RequestInfo | string
options?: RequestInit
}
// label any email with archive-after/2-hours or archive-after/1-day (any number of days or hours) and it does!
// you can optionaly nest the labels eg `archive-after` and make `2-hours` inside the archive after - the script doesn't seem to care!
// Install steps
// create a new project here https://script.google.com/
// create a new file with this contents
// then create a trigger to run it every 10 minutes
// enjoy!
const LABEL_REGEX = /archive-after\/(\d+)-(day|hour)s?/
@reconbot
reconbot / graphql-playground.tsx
Created July 1, 2021 15:22
How to get graphql playground to work on nextjs
import dynamic from 'next/dynamic'
import Head from 'next/head'
const WS_URL = process.env.NEXT_PUBLIC_WS_API_ENDPOINT
const API_URL = process.env.NEXT_PUBLIC_API_ENDPOINT
// You might ask yourself, what is this business?
// And I might ask why on earth does Playground require window on module load breaking any hope
// of ssr even if we don't render it but only import it
const Playground = dynamic<any>(
@reconbot
reconbot / day1.go
Created December 4, 2023 17:42
a broken program for solving day 1
package main
import (
"bufio"
"os"
"regexp"
"strconv"
"strings"
)