Skip to content

Instantly share code, notes, and snippets.

View danopia's full-sized avatar

Daniel Lamando danopia

View GitHub Profile
import { Server } from "https://deno.land/std@0.200.0/http/server.ts";
const port = 4505;
const handler = (request: Request) => {
const body = `Your user-agent is:\n\n${request.headers.get(
"user-agent",
) ?? "Unknown"}`;
return new Response(body, { status: 200 });
};
const server = new Server({ host: '0.0.0.0', port, handler });
const certFile = "cert.pem";
import * as ows from "https://deno.land/x/stream_observables@v1.3/mod.ts";
import { trace, SpanKind, propagation, context, TextMapGetter, ROOT_CONTEXT, SpanContext } from "https://deno.land/x/observability@v0.4.0/opentelemetry/api.js";
type KvRealtimeEvent =
| {
type: 'insert' | 'replace';
appliedAt: Date;
key: Deno.KvKey;
value: unknown;
versionstamp: string;
@danopia
danopia / best-500-albums.jsonl
Last active February 16, 2023 13:10
Extracted listing for "Best 500 Albums Of All Time" published Sept 2020
{"position":500,"title":"Funeral","artist":"Arcade Fire","year":"2004","label":"MERGE"}
{"position":499,"title":"Ask Rufus","artist":"Rufus, Chaka Khan","year":"1977","label":"ABC"}
{"position":498,"title":"Suicide","artist":"Suicide","year":"1977","label":"RED STAR"}
{"position":497,"title":"The Indestructible Beat of Soweto","artist":"Various Artists","year":"1985","label":"EARTHWORKS"}
{"position":496,"title":"Dónde Están los Ladrones","artist":"Shakira","year":"1998","label":"COLUMBIA"}
{"position":495,"title":"II","artist":"Boyz II Men","year":"1991","label":"MOTOWN"}
{"position":494,"title":"Presenting the Fabulous Ronettes","artist":"The Ronettes","year":"1964","label":"PHILLES"}
{"position":493,"title":"Here, My Dear","artist":"Marvin Gaye","year":"1978","label":"TAMLA/MOTOWN"}
{"position":492,"title":"Nick of Time","artist":"Bonnie Raitt","year":"1989","label":"CAPITOL"}
{"position":491,"title":"Fine Line","artist":"Harry Styles","year":"2019","label":"COLUMBIA"}
! 2021-11-26 lets make stuff work
! page autotranslate
@@||translate.google.com/gen204
! datadog RUM
@@||rum-http-intake.logs.datadoghq.eu^$ping
! google analytics
@@||www.google-analytics.com^
@danopia
danopia / Dockerfile
Last active October 23, 2022 12:49
Shelly IoT sensors -> Datadog custom metrics
FROM node:18-slim
WORKDIR /app
COPY package.json ./
RUN npm install
COPY index.js ./
ENTRYPOINT ["node", "."]
@danopia
danopia / terraform.ts
Created January 2, 2022 12:54
terraform json typescript
interface ChangedResource {
address: string;
module_address: string;
mode: "data" | "managed";
type: string;
name: string;
index?: number | string;
provider_name: string;
change: {
@danopia
danopia / Dockerfile
Last active March 9, 2023 16:50
ERCOT Frozen Grid 2021 - Metrics Reporters
FROM hayd/alpine-deno:1.10.1
WORKDIR /src/app
ADD deps.ts ./
RUN ["deno", "cache", "deps.ts"]
ADD *.ts ./
RUN ["deno", "cache", "mod.ts"]
ENTRYPOINT ["deno", "run", "--unstable", "--allow-net", "--allow-hrtime", "--allow-env", "--cached-only", "--no-check", "mod.ts"]
@danopia
danopia / podman run --rm -it alpine sh -i
Created February 12, 2021 18:39
installing zsh with three different package managers
/ # time apk update
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
v3.13.1-111-g435a742679 [https://dl-cdn.alpinelinux.org/alpine/v3.13/main]
v3.13.1-108-gc0a920aca7 [https://dl-cdn.alpinelinux.org/alpine/v3.13/community]
OK: 13880 distinct packages available
real 0m 0.52s
user 0m 0.25s
sys 0m 0.04s
@danopia
danopia / failed-narrow.ts
Created January 12, 2021 21:24
typescript inconsistent never behavior
// variable we want to narrow
const { channel } = {} as Record<string,string | undefined>;
// if this simpler definition is used instead, it's all ok
// const channel: undefined | string = 'hi';
// method returning never
const api = {} as { cancel(): never; };
if (!channel) api.cancel();
@danopia
danopia / cleanup-signal.ts
Last active November 18, 2020 07:46
deno cleanup signal test
const signals = [
Deno.signal(Deno.Signal.SIGINT),
Deno.signal(Deno.Signal.SIGTERM),
];
const cleaningUp = Promise.race(signals).then(() => {
signals.forEach(x => x.dispose());
});
console.log('Module running...');