This file contains 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 dspy | |
from typing import Dict | |
class PortlandOracle(dspy.Signature): | |
"""Answer questions about Portland restaurants.""" | |
question: str = dspy.InputField() | |
answer: str = dspy.OutputField() | |
def forward(self, question): |
This file contains 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 { randomBytes as csprngRandomBytes, scrypt, timingSafeEqual } from 'crypto'; | |
import { promisify } from 'util'; | |
const scryptAsync = promisify(scrypt); | |
/** | |
* Hashes a string using the scrypt algorithm. | |
* | |
* @param value - The value to hash. | |
* @returns A promise that resolves to the hashed value in the format `base64(salt):base64(derivedKey)`. |
This file contains 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 { hash, verify, Options, Algorithm } from '@node-rs/argon2'; | |
/** | |
* Hashes a string using the Argon2id algorithm. | |
* Argon2 is a memory-hard function that requires a large amount of memory to compute. | |
* The 'id' variant mixes resistance against both GPU cracking and side-channel attacks. | |
* A generated salt value adds resistance against pre-computed rainbow table attacks. | |
* The configuration options are included in argon2 hashes to simplify verification. | |
* | |
* @param value - The value to hash. |
This file contains 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
#!/bin/bash | |
OUTFILE="otp-hashes.csv" | |
function gen_hash() { | |
otp=$1; | |
hash=$(echo -n $otp | sha256sum | awk '{print $1}'); | |
echo "$otp,$hash" >> $OUTFILE; | |
} |
This file contains 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
#!/bin/bash | |
curl \ | |
--header "Authorization: Bearer $TFC_TOKEN" \ | |
--header "Content-Type: application/vnd.api+json" \ | |
"https://app.terraform.io/api/v2/account/details" |
This file contains 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
#!/bin/bash | |
# Connect a TFC workspace to a Github VCS provider using the TFC API. | |
INFILE_WORKSPACES="tfc-workspace-name-list.txt" | |
function check_env() { | |
var_name="$1" | |
var_value="$2" |
This file contains 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
#!/bin/bash | |
# Script to pull details on all TFC workspaces and then focus on VCS configs. | |
# Note: jq is used to parse JSON, you need to install it if not already available | |
# Variables - Replace with your actual values | |
if [ -z $TFC_API_TOKEN ]; then | |
echo "Missing TFC_API_TOKEN environment variable"; | |
exit 1; | |
fi |
This file contains 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
#!/bin/bash | |
# List `rds.force_ssl` RDS DB Parameter Group values for all DBs in the account. | |
# Dump the results to CSV. | |
OUTFILE="rds-force-ssl.$(date +%s).csv" | |
# Get all RDS parameter group names | |
parameter_groups=$(aws rds describe-db-parameter-groups --query "DBParameterGroups[].DBParameterGroupName" --output text) |
This file contains 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
#!/bin/bash | |
# Example of using the 'age' file encryption tool to securely exchange | |
# a large sensitive file between two parties over a hostile network. | |
# https://age-encryption.org/ | |
# https://github.com/FiloSottile/age | |
# https://htmlpreview.github.io/?https://github.com/FiloSottile/age/blob/main/doc/age.1.html | |
############################################################### |
This file contains 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
#!/usr/bin/env bash | |
# Get a Github access token as a Github App in pure bash. | |
# 1. Generate a JWT (CLIENT_ID and PEM) | |
# 2. Obtain the access token (JWT and INSTALLATION_ID) | |
# | |
# https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app#example-using-bash-to-generate-a-jwt | |
set -o pipefail |
NewerOlder