Skip to content

Instantly share code, notes, and snippets.

View SilverCory's full-sized avatar
❄️
Serve chilled. Carbonated.

Cory Redmond SilverCory

❄️
Serve chilled. Carbonated.
View GitHub Profile
@SilverCory
SilverCory / firestore_values.go
Created February 22, 2024 12:24
Firestore Value Flattening and unmarshalling
package firestore_type
import "encoding/json"
type Value struct {
Value interface{}
}
func (v *Value) UnmarshalJSON(data []byte) error {
var fsPayload map[string]interface{}
@SilverCory
SilverCory / README.md
Created September 6, 2023 13:24
Golang Gin SPA serving using embedded fs

Golang Gin SPA serving using embedded fs.

Usage:

File Structure:

  • Go Project Root
    • Go files and project
    • SPA FE (in my case ui
      • spa.go
@SilverCory
SilverCory / README.md
Last active August 17, 2023 00:00
A tee logging implementation for slog golang. Log with multiple handlers.

Usage:

var logger = slog.New(
  NewTeeLogger(
    slog.NewJSONHandler(
      os.Stdout,
      &slog.HandlerOptions{
        AddSource:   false,
 Level: level,
@SilverCory
SilverCory / bike-emulator.ino
Last active June 10, 2022 12:39
Emergency Stopping Signal for ZX6R 1999 using ESP32 (Doesn't work bc too many interrupts
const int PIN_SPEED_SENSOR_OUT = 12;
const int PIN_BRAKE_LEVER_OUT = 13;
const int PIN_SLOW_TOUCH_1_IN = 4;
const int PIN_SLOW_TOUCH_2_IN = 32;
const int THRESHOLD = 30;
const int MAX_FREQ = 345;
void setup() {
@SilverCory
SilverCory / CANBusLogger.pde
Last active September 26, 2024 14:18
BMW F800GS CANBUS headlight detection for a lightbar. (double tap and the lightbar will come on). For arduino.
/*
* The aim of this is to try to detect changes in messages.
* A change in a message should correlate to an action/operation performed on the vehicle.
*/
import processing.serial.*;
import java.lang.IllegalArgumentException;
import java.lang.System;
import java.util.Map;
package main
import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
)
@SilverCory
SilverCory / MulticraftConsoleViaBash.sh
Last active August 25, 2018 02:12
So this is an old old script I wrote from years ago. This enables you to enter commands into a multicraft console and tail the log file. I don't know if it still works, I updated it and added -r to the "read"'s as well as double quotes around variables. All should still be well.
#!/bin/bash
### https://pastebin.com/4pVGcwQE
if [ -t 0 ]; then stty sane; fi
if [ "$(whoami)" != "root" ]; then echo "This needs to be run as root!" ; exit 0 ; fi
echo -n "Username: "; read -r -t 15 username_
ps -au "$username_" ; echo "--------------------------------------------------"
echo -n "PID: "; read -r -t 15 PID_
userhome=$(eval echo "~$username_")
@SilverCory
SilverCory / updateCloudflare.sh
Last active November 10, 2018 11:27
Make sure cloudflare is the only people who can view the site, as well as setting the realip.
#!/bin/bash
#
# Update cloudflare.conf with new IPs
#
cloudFlareConf="/etc/nginx/conf.d/cloudflare.conf"
cloudFlareList="/etc/nginx/conf.d/cloudflare-whitelist.conf"
IPV4=$(curl -s "https://www.cloudflare.com/ips-v4")
IPV6=$(curl -s "https://www.cloudflare.com/ips-v6")
DATE="$(date)"
@SilverCory
SilverCory / KeyGen.go
Last active June 6, 2023 05:22
Vexera Premium key generator
package main
import (
"fmt"
"math/rand"
"strconv"
"strings"
)
var validKeys = ``
@SilverCory
SilverCory / GlancePenis.go
Last active May 28, 2019 10:26
Draw a penis in glance
package main
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"net/http"
"reflect"
"strconv"