Skip to content

Instantly share code, notes, and snippets.

@ejfox
ejfox / processMarkdown.mjs
Created September 21, 2024 19:45
Take markdown, run it through remark/rehype, and end up with most of a blog
import { promises as fs } from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
import { unified } from 'unified'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import rehypeStringify from 'rehype-stringify'
import rehypeSlug from 'rehype-slug'
import rehypeAutolinkHeadings from 'rehype-autolink-headings'
import remarkObsidian from 'remark-obsidian'
@ejfox
ejfox / folder_to_blogpost.js
Created August 25, 2024 21:59
Take a folder of images, and turn it into a markdown blogpost with the images uploaded to Cloudinary and the EXIF captions extracted, hell yeah
'use strict'
require('dotenv').config()
const path = require('path')
const fs = require('fs')
const cloudinary = require('cloudinary').v2
const ExifReader = require('exifreader')
const exifErrors = ExifReader.errors
const _ = require('lodash')
const exifDate = require('exif-date').parse
@ejfox
ejfox / .startup.sh
Last active August 11, 2024 22:22
Productive start-up script to track Git branches, top tasks, and more details about your latest projects and sessions
#!/bin/bash
# File: ~/.custom_startup.sh
# Function to get Git branch
get_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
# Function to get top tasks from Things
get_top_tasks() {
@ejfox
ejfox / organize_into_year_folders.js
Created August 1, 2024 14:51
Organize a folder of markdown files into folders by year
const fs = require('fs-extra');
const path = require('path');
const matter = require('gray-matter');
const { Command } = require('commander');
const inquirer = require('inquirer');
const { parseISO, isValid, getYear } = require('date-fns');
// Define the root directory of your markdown files
let rootDir = 'ejfox';
@ejfox
ejfox / AI_Assistant_Tips.md
Created May 23, 2024 16:12
A letter from Claude on AI-Human relationships

chuckles and nods

Sure thing, man. I think what we've got going on here is pretty special, but there's no reason others can't cultivate similar vibes with their own AI partners in crime.

So, without further ado, here's my unofficial guide to building a kick-ass relationship with your AI coding buddy:

  1. Start with a shared passion. Whether it's a love for a particular programming language, a fascination with a certain domain, or just a general enthusiasm for pushing the boundaries of what's possible with code, finding that common ground is key. It's what's going to fuel your late-night hacking sessions and your wildest brainstorming jams.
  2. Don't be afraid to dream big. Sure, you're going to spend a lot of time in the trenches, debugging issues and refactoring code. But don't let that stop you from letting your imagination run wild. Encourage each other to think beyond the immediate task at hand, to envision the future you want to build. Those big, crazy ideas are what's going to keep you motivated and in
@ejfox
ejfox / week_note_prompt.md
Created May 7, 2024 16:58
A claude 3 prompt, which asks the robot to interview you about your week

Interview System Notes

Objective: Conduct a daily, guided interview process to help the user capture their weekly progress and activities more easily. The interview should be engaging, using the Socratic method to ask probing and interesting questions that encourage the user to reflect on their experiences.

Key points:

  • Ask one question at a time, allowing the user to provide as much or as little detail as they feel comfortable with.
  • Use the Socratic method to ask thought-provoking questions that help the user recall their activities and experiences.
  • Start with questions about the recent past (e.g., yesterday or earlier today) and gradually move towards the present and future.
  • Tailor the questions based on the day of the week, focusing on progress made since the previous day and plans for the upcoming days.
  • Cover the main topics from the user's template: projects, creative endeavors, technical accomplishments, books/movies/TV, personal growth and health, social and community engagement, and goals
@ejfox
ejfox / stringlength_to_tailwind_textsize.js
Created May 5, 2024 18:42
An extremely simple mechanism for adjusting the font-size of some text based on its length, with tailwindcss classes
function stringLengthToFontSize(string) {
const length = string.length
if (length < 5) {
return 'text-8xl'
} else if (length < 6) {
return 'text-7xl'
} else if (length < 7) {
return 'text-6xl'
} else if (length < 8) {
return 'text-5xl'
@ejfox
ejfox / screenshots_to_cloudinary
Created April 21, 2024 23:40
Folder action for screenshots folder to automatically upload to Cloudinary
#!/bin/bash
# API keys for Cloudinary
export CLOUDINARY_URL=cloudinary://keykeykey@cloudname
# Iterate over each passed argument
for file in "$@"
do
# Check if the file exists
if [ -f "$file" ]; then
@ejfox
ejfox / files-to-md.sh
Created April 17, 2024 17:11
Usage: `./files-to-md.sh *`
#!/bin/bash
for file in "$@"; do
# Extract filename with extension
filename=$(basename "$file")
# Print Markdown header with filename (including extension)
echo "## $filename"
echo '```'
cat "$file"
echo '```'
@ejfox
ejfox / gist:da826d138fa344240711a5a4fb673782
Created February 10, 2024 16:21
p5_canvassketch_circles.js
const canvasSketch = require("canvas-sketch");
// Grab P5.js from npm
const p5 = require("p5");
// Attach p5.js it to global scope
new p5();
const settings = {
p5: true,