Skip to content

Instantly share code, notes, and snippets.

@ejfox
ejfox / gist:da826d138fa344240711a5a4fb673782
Created February 10, 2024 16:21
p5_canvassketch_circles.js
View gist:da826d138fa344240711a5a4fb673782
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)
View 32_x_128_audio_visualizer.java
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
View OrbitalObject.vue
<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>
View DomElementTo3DPosition.vue
<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
View circle-tween.vue
<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
])
View screenshots-to-cloudinary.workflow
#!/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
View set_screenshot_folder.sh
#!/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
View christmas_medley.rb
# 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]
},
View csv_to_title.js
const puppeteer = require('puppeteer');
const fs = require('fs');
(async () => {
try {
// Read the CSV file
const inputCsv = fs.readFileSync('output.csv', 'utf-8');
const records = inputCsv.split('\n').map((row, index) => {
if (index === 0) return null; // Skip the header row
const [Index, Title, URL] = row.split(',');
View hv_restaurants_and_farms.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.