Skip to content

Instantly share code, notes, and snippets.

View jameshfisher's full-sized avatar
🥣
Building at Granola.ai

Jim Fisher jameshfisher

🥣
Building at Granola.ai
View GitHub Profile
@jameshfisher
jameshfisher / digital_ocean_spaces.js
Created November 15, 2021 11:18
Using Digital Ocean Spaces with S3 client in NodeJS
import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3';
const s3AccessKeyId = "Y64W56U7IE85W46JH"; // Generate key at https://cloud.digitalocean.com/account/api/tokens
const s3SecretAccessKey = "y546wu7ie5u435y/7uei564sy5u6w57";
const s3Bucket = "foo"; // Assumes your Space is https://cloud.digitalocean.com/spaces/foo
const s3Region = "nyc3"; // Get this from "Endpoint" at https://cloud.digitalocean.com/spaces/foo/settings
const s3Endpoint = "https://nyc3.digitaloceanspaces.com"; // From "Endpoint" at https://cloud.digitalocean.com/spaces/foo/settings, prepend 'https://'
const s3Client = new S3Client({
@jameshfisher
jameshfisher / rename.sh
Created April 3, 2023 16:53
Shell function to rename file with filename editor
rename() {
[ "$#" -ne 1 ] && echo "Usage: rename <file_path>" && return 1
local temp_file=$(mktemp)
echo "$1" > "$temp_file"
"${EDITOR:-vi}" "$temp_file"
local new_path=$(cat "$temp_file")
mv "$1" "$new_path"
echo "$new_path"
rm "$temp_file"
}