Skip to content

Instantly share code, notes, and snippets.

View blinkinglight's full-sized avatar

M blinkinglight

View GitHub Profile
@blinkinglight
blinkinglight / index.html
Last active July 25, 2025 05:57
fancy file uploader vanilla js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="script.js" defer type="module"></script>
</head>
<body>
@blinkinglight
blinkinglight / main.go
Last active June 17, 2025 17:09
bee in action
router.Get("/stream/{id}", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
id := chi.URLParam(r, "id")
sse := datastar.NewSSE(w, r)
_ = sse
ctx := bee.WithJetStream(r.Context(), js)
ctx = bee.WithNats(ctx, nc)
agg := &Aggregate{}
package replayhandler
import (
"context"
"fmt"
"log"
"time"
"github.com/ituoga/iot/gen"
"github.com/nats-io/nats.go"
package main
import (
"io"
"os/exec"
"github.com/nats-io/nats.go"
)
type NWriter struct {
@blinkinglight
blinkinglight / main.go
Last active March 16, 2025 13:27
something with events
package main
import (
"context"
"fmt"
"log"
"strings"
"time"
"github.com/ituoga/the-system/pkg/tools"
#include <TimerOne.h>
const int encoderPinA = 2; // Connected to interrupt 0 (pin 2)
const int encoderPinB = 3; // Connected to interrupt 1 (pin 3)
const int stepPin = 9;
const int dirPin = 8;
// Variables to track encoder state
volatile int32_t encoderPositionX = 0;
volatile int32_t encoderPositionY = 0;
volatile int32_t encoderPositionZ = 0;
volatile bool lastEncodedState = false;
<html>
<head>
<meta name="theme-color" content="#0d085c"/>
<link rel="manifest" href="/manifest.json"/>
</head>
from flask import Flask, Response
import time
app = Flask(__name__)
def root_dir(): # pragma: no cover
return os.path.abspath(os.path.dirname(__file__))
<script>
class MyArray extends HTMLElement {
constructor() {
super();
this.store = {};
const template = document.createElement("template");
const id = Math.random().toString(36).substr(2, 9);
template.innerHTML = `<div id="input-${id}">hi</div>`;
this.shadow = this.attachShadow({ mode: "open" });
this.shadow.appendChild(template.content.cloneNode(true));
class MyCustomElement extends HTMLElement {
constructor() {
super();
const template = document.createElement('template');
template.id = 'pool-calculator-template';
template.innerHTML = `
<input type="text" id="input"/>
`;
// this.appendChild(template);