When using saml2aws to assume AWS roles from a single-sign-on account, you'll need to get new credentials every workday (if not hourly). And users who use multiple accounts need to manage multiple sessions. It becomes hard to track which sessions you have active, and which sessions are expired.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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...'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as Base64 from 'https://deno.land/std@0.76.0/encoding/base64.ts'; | |
| async function toDataUrl(resp: Response): Promise<string> { | |
| const contentType = resp.headers.get('content-type') ?? 'application/octet-stream'; | |
| const buffer = await resp.arrayBuffer(); | |
| return `data:${contentType};base64,`+Base64.encode(buffer); | |
| } | |
| const gifUrl = 'https://matthews.sites.wfu.edu/misc/jpg_vs_gif/testImage.gif'; | |
| console.log(await fetch(gifUrl).then(toDataUrl)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // In a Unix pipe, accepts 'tableized' input with many spaces between fields, | |
| // and outputs the data as a traditional CSV. | |
| // Does not handle input where fields contain their own spaces. | |
| import { BufReader, BufWriter } from "https://deno.land/std@0.68.0/io/bufio.ts"; | |
| import { TextProtoReader } from "https://deno.land/std@0.68.0/textproto/mod.ts"; | |
| const input = new TextProtoReader(new BufReader(Deno.stdin)); | |
| while (true) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const commands = [ | |
| { | |
| name: 'coinbase', | |
| args: | |
| script: 'https://......../command.js', | |
| allow: { | |
| net: ['api.coinbase.com'], | |
| }, | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default fetch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "log" | |
| // "time" | |
| "github.com/google/nftables" | |
| nftexpr "github.com/google/nftables/expr" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Kubernetes from './kubernetes.js' | |
| const kubectl = new Kubernetes({namespace: process.env.KUBE_NAMESPACE}); | |
| const logMinutes = 30; | |
| (async () => { | |
| // Tally IP addresses that hit us | |
| const ipHits = new Map; | |
| for (const pod of await kubectl.listPods({app: process.env.KUBE_APP_LABEL})) { | |
| console.log(`Checking ${logMinutes}m of`, pod.metadata.name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM golang:1.14 AS build-go | |
| WORKDIR /src | |
| # cache deps | |
| ADD go.* /src/ | |
| RUN go mod download | |
| # build module | |
| ADD * /src/ | |
| RUN go build -o /bin/hello-sts | |
| # pack into minimal image |