Skip to content

Instantly share code, notes, and snippets.

View elithrar's full-sized avatar
🌐
Helping make the Internet better.

Matt Silverlock elithrar

🌐
Helping make the Internet better.
View GitHub Profile
@elithrar
elithrar / index.ts
Created March 25, 2025 17:55
Cloudflare Agents SDK + Gemini 2.5 Pro Experimental 03-25 + prompt - https://developers.cloudflare.com/agents/
import { Agent, AgentNamespace, routeAgentRequest } from 'agents';
import { GoogleGenerativeAI, HarmCategory, HarmBlockThreshold } from '@google/generative-ai';
// Define the environment variables and bindings required by the Worker and Agent
interface Env {
// Binding for the Agent Durable Object
SECURITY_AUDIT_AGENT: AgentNamespace<SecurityAuditAgent>;
// Secret holding the Google Gemini API Key
GEMINI_API_KEY: string;
// Optional: Secret holding a GitHub API token for higher rate limits / private repos
@elithrar
elithrar / index.html
Created February 25, 2025 14:27
Claude 3.7 + building Cloudflare Agents using the agents-sdk
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Cloudflare Agent Chat</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
@elithrar
elithrar / Hypersubatomic.json
Last active February 12, 2025 02:39
USGraphics Hypersubatomic editor theme for the Zed editor (zed.dev) • https://github.com/usgraphics/hypersubatomic-vscode-theme
{
"$schema": "https://zed.dev/schema/themes/v0.1.0.json",
"name": "Hypersubatomic",
"author": "Converted from VSCode theme",
"themes": [
{
"name": "Hypersubatomic Dark",
"appearance": "dark",
"style": {
"background": "#0F111A",
@elithrar
elithrar / index.ts
Created December 6, 2024 16:45
workers.es - a (silly) example of writing Cloudflare Workers in Spanish (2024/12/6)
import { Solicitud, Respuesta, ContextoDeEjecucion, Entorno, Prometo, URL } from "./workers.es";
export default {
async obtener(solicitud: Solicitud, entorno: Entorno, contexto: ContextoDeEjecucion): Prometo<Respuesta> {
let url = new URL(solicitud.url);
let nombre = url.parametrosBusqueda.get("nombre") || "mundo";
return Respuesta.json({
mensaje: `hola ${nombre}`,
});
@elithrar
elithrar / index.ts
Last active February 12, 2025 07:42
Bluesky API + Cloudflare Workers example: https://docs.bsky.app/docs/get-started + https://developers.cloudflare.com/workers/ = 😎
import { BskyAgent } from "@atproto/api";
type Env = {
BLUESKY_APP_PASSWORD: string;
POST_TOKEN: string;
};
export default {
async fetch(request, env, ctx): Promise<Response> {
let url = new URL(request.url);
https://docs.google.com/presentation/d/1GXCaoat2CEcPu9lJ9eJDjzVW_Vuqr-Yq7kJolfOpBG0/edit?usp=sharing
@elithrar
elithrar / get-local-api.js
Last active July 16, 2023 14:44
A Scriptable powered iOS 14 widget (https://docs.scriptable.app/) using JavaScriptCore to get the current AQI from a PurpleNow sensor: https://fire.airnow.gov/
const API_URL = "https://www.purpleair.com/json?show=";
// Params: lat, lng, zoom
const MAP_URL = "https://fire.airnow.gov/"
// const CACHE_FILE = "aqi_data.json"
// Find a nearby PurpleAir sensor ID via https://fire.airnow.gov/
// Click a sensor near your location: the ID is the trailing integers
// https://www.purpleair.com/json has all sensors by location & ID.
let SENSOR_ID = args.widgetParameter || "19066"
const HEADER_COLOR = "#222222"
@elithrar
elithrar / config.yml.tmpl
Last active June 29, 2019 17:34
Generate a @circleci Config for Go for the @gorilla Toolkit - https://github.com/gorilla
version: 2.0
jobs:
# Base test configuration for Go library tests Each distinct version should
# inherit this base, and override (at least) the container image used.
"test": &test
docker:
- image: circleci/golang:latest
working_directory: /go/src/github.com/gorilla/mux
steps: &steps
@elithrar
elithrar / .travis.yml
Last active September 13, 2020 21:29
CircleCI vs. TravisCI for gorilla/mux - comparing maintainability, verbosity, DRY, etc. Ref: https://twitter.com/elithrar/status/1140342082768261120 & https://blog.questionable.services/article/building-go-projects-on-circle-ci/
language: go
matrix:
include:
- go: 1.7.x
- go: 1.8.x
- go: 1.9.x
- go: 1.10.x
- go: 1.11.x
@elithrar
elithrar / query.sql
Last active May 30, 2022 23:56
Using BigQuery to find public GitHub READMEs (readme%) with "blazing" in the contents: via https://twitter.com/peterbourgon/status/1039902928151052288
SELECT
repo_name,
path
FROM (
SELECT
id,
repo_name,
path
FROM
`bigquery-public-data.github_repos.files`