Skip to content

Instantly share code, notes, and snippets.

View reconbot's full-sized avatar
Building at @github

Francis Gulotta reconbot

Building at @github
View GitHub Profile
reconbot / day1.go
Created December 4, 2023 17:42
a broken program for solving day 1
View day1.go
package main
import (
reconbot / AsyncDisposableTransaction.test.ts
Last active November 6, 2023 14:38
An example of using Symbol.asyncDispose to easily cleanup remote resources when an execption occures.
View AsyncDisposableTransaction.test.ts
import test, { describe } from 'node:test'
import { AsyncDisposableTransaction } from './AsyncDisposableTransaction'
import assert, { deepEqual, equal, rejects } from 'node:assert'
describe('AsyncDisposableTransaction', () => {
test('should rollback when not committed', async () => {
let rollbackCalled = false
await (async () => {
await using transaction = new AsyncDisposableTransaction()
transaction.rollback(() => {
View gist:b4bb188515ad58d0255bace9ac476efc
name: esphome-web-XXXXXX
friendly_name: XXXXX
board: esp01_1m
# Enable Home Assistant API
View baking_jokes.json
"Borrowing some flour",
"Waiting for the report to rise",
"Double checking the weights",
"Proofing the report",
"Was that one egg or two?",
"Toasting the oats",
"Loading the kneaded info",
"Reticulating splines",
"Mixing the customers and orders",
View home-assistant-wifi-plug.yml
- platform: cse7766
name: "current"
accuracy_decimals: 1
name: "voltage"
accuracy_decimals: 1
name: "power"
reconbot / createComplexityPlugin.ts
Last active June 20, 2023 14:43
An Apollo Plugin for graphql-query-complexity
View createComplexityPlugin.ts
import { ComplexityEstimator, getComplexity } from 'graphql-query-complexity'
import { GraphQLError, GraphQLSchema, separateOperations } from 'graphql'
import { PluginDefinition } from 'apollo-server-core'
export const createComplexityPlugin = ({
createError = (max, actual) => { throw new GraphQLError(`Query too complex. Value of ${actual} is over the maximum ${max}.`) },
reconbot / batchFetchExchange.ts
Last active June 10, 2023 04:13
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.
View batchFetchExchange.ts
// Adapted from
import DataLoader from 'dataloader'
import { Exchange, Operation } from 'urql'
import { pipe, map } from 'wonka'
interface BatchRequest {
url: RequestInfo | string
options?: RequestInit
reconbot /
Created February 22, 2023 03:35
this time it doesn't crash - doesn't seem to read from the network though
use std::{net::{SocketAddr, Ipv4Addr}, sync::Arc};
use tokio::net::{UdpSocket}; //UdpFramed
use anyhow::{Context, Result};
// use tokio::time::sleep;
// use std::time::Duration;
use socket2::{Socket, Domain, Type, Protocol};
use serde::{Deserialize, Serialize};
use std::time::{SystemTime, UNIX_EPOCH};
use tokio::sync::mpsc::{self, Receiver, Sender};
use futures::try_join;
View cargo.toml
name = "hackerchat-rust"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at
anyhow = "1.0.69"
async-channel = "1.8.0"
View main.go
package main
import (