Skip to content

Instantly share code, notes, and snippets.

@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,
@ejfox
ejfox / 32_x_128_audio_visualizer.java
Created January 27, 2024 06:11
Processing RGB LED Matrix Visualizer (for Raspberry Pi)
import ddf.minim.*;
Minim minim;
AudioInput mic;
int rows = 128;
int cols = 64;
float scale = 4.5; // Scale factor for the size of the circles
float noiseScale = 0.012; // Scale factor for the Perlin noise
float micThreshold = -10;
float t = 0; // Noise offset
@ejfox
ejfox / OrbitalObject.vue
Created January 22, 2024 04:26
Using anime, tresjs, and canvas to make rotating annotated objects in 3D
<template>
<TresGroup :position="offsetPosition">
<!-- Line from this orbital object to the center -->
<TresMesh>
<Line2 :points="[[0, 0, 0], [-offsetPosition[0], -offsetPosition[1], -offsetPosition[2]]]" :line-width="2" color="#82dbc5" />
<TresLineBasicMaterial :color="'#ffffff'" />
</TresMesh>
<!-- Orbital Object Sphere -->
<TresMesh>
<script setup>
import { ref } from 'vue';
import { useElementBounding, useWindowSize } from '@vueuse/core';
import { useTres } from 'tresjs';
// `domElementRef` is a ref for the DOM element we want to map to the 3D scene
const domElementRef = ref(null);
// Use VueUse's useElementBounding to track the element's position and size
const { left, top, width, height } = useElementBounding(domElementRef);
@ejfox
ejfox / circle-tween.vue
Created January 10, 2024 18:38
Tween the positions of circles using vueUse's useTween composable
<script setup>
import { ref } from 'vue'
import { useTween } from '@vueuse/core'
// Let's assume each circle has an initial x and y position
const circles = ref([
{ id: 1, x: 100, y: 100 },
{ id: 2, x: 150, y: 200 },
// Add as many circles as you want
])
#!/bin/bash
# API keys for Cloudinary
export CLOUDINARY_URL=cloudinary://APIKEY@NAME
# Iterate over each passed argument
for file in "$@"
do
# Check if the file exists
if [ -f "$file" ]; then
@ejfox
ejfox / set_screenshot_folder.sh
Created January 5, 2024 17:27
Sets screenshot folder on OS X to ~/screenshots
#!/bin/bash
# Create the directory if it doesn't exist
mkdir -p ~/screenshots
# Set the default location for screenshots
defaults write com.apple.screencapture location ~/screenshots
# Apply the changes by restarting the SystemUIServer
killall SystemUIServer
@ejfox
ejfox / christmas_medley.rb
Created December 25, 2023 20:57
Sonic Pi + Midi Christmas Medley
# Defining all melodies with their durations in a dictionary-like structure
melodies = {
silent_night: {
notes: [:G, :A, :G, :E, :G, :A, :G, :E, :C, :G, :C, :G, :A, :A, :G],
durations: [0.5, 0.5, 1, 1, 0.5, 0.5, 1, 1, 0.5, 0.5, 1, 1, 0.5, 0.5, 1]
},
jingle_bells: {
notes: [:E, :E, :E, :E, :E, :E, :E, :G, :C, :D, :E, :F, :F, :F, :F, :F, :E, :E, :E, :E, :E, :D, :D, :E, :D, :G],
durations: [0.5, 0.5, 1, 0.5, 0.5, 1, 0.5, 0.5, 0.5, 1, 1, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 0.5, 0.5, 0.5, 1]
},