Skip to content

Instantly share code, notes, and snippets.

Avatar
Building at @vercel

Francis Gulotta reconbot

Building at @vercel
View GitHub Profile
View gist:b4bb188515ad58d0255bace9ac476efc
esphome:
name: esphome-web-XXXXXX
friendly_name: XXXXX
esp8266:
board: esp01_1m
# Enable Home Assistant API
api:
encryption:
View home-assistant-wifi-plug.yml
sensor:
- platform: cse7766
current:
name: "current"
accuracy_decimals: 1
voltage:
name: "voltage"
accuracy_decimals: 1
power:
name: "power"
@reconbot
reconbot / hackerchat.rs
Created February 22, 2023 03:35
this time it doesn't crash - doesn't seem to read from the network though
View hackerchat.rs
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
[package]
name = "hackerchat-rust"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0.69"
async-channel = "1.8.0"
View main.go
package main
import (
"bufio"
"encoding/json"
"fmt"
"net"
"os"
"sync"
"time"
View planetscale workflows.md

Database Workflows

  • local development workflow
    • ensure there's a dev branch that matches the machine ID and force schema, truncate tables, load dev data, write branch name/access keys to envs
    • ensure there's a test branch that matches the machine ID and force schema, truncate tables, write branch name/access keys to envs
  • github branch workflow
    • ensure there's a test branch that matches 'github', branch_name, and force schema, truncate data, write branch name/access keys to envs
  • deployment workflows
    • deploying to staging, create a branch off of staging if schema changed, force schema, try to merge, block code deploy if you can't merge
  • deploying to production, create a branch off of production if schema changed, force schema, try to merge, block code deploy if you can't merge
View space-parser.d.ts
export interface SpacePacketHeader {
versionNumber: string | number
identification: {
apid: number
secondaryHeader: number
type: number
}
sequenceControl: {
packetName: number
sequenceFlags: number
@reconbot
reconbot / my-git.zsh
Created November 4, 2021 04:06
My git shortcuts
View my-git.zsh
alias gb='gh pr view -w'
alias gp='git push origin HEAD'
alias gpf='git push --force-with-lease origin HEAD'
alias gpfo='git push --force-with-lease origin HEAD && gb'
alias gpo='git push origin HEAD && gb'
alias gcm='git checkout $(git_detect_main_branch)'
alias gcmp='git checkout $(git_detect_main_branch) && git pull origin $(git_detect_main_branch) --ff-only'
alias grom='git fetch && git rebase --autostash origin/$(git_detect_main_branch)'
function git_detect_main_branch() {
@reconbot
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 = ({
schema,
maximumComplexity,
estimators,
onComplete,
createError = (max, actual) => { throw new GraphQLError(`Query too complex. Value of ${actual} is over the maximum ${max}.`) },
@reconbot
reconbot / graphql-playground.tsx
Created July 1, 2021 15:22
How to get graphql playground to work on nextjs
View graphql-playground.tsx
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>(