Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View bhollis's full-sized avatar

Ben Hollis bhollis

View GitHub Profile
@bhollis
bhollis / GlowBeast.pde
Created February 15, 2023 02:52
GlowBeast arduino code - breathing glow effect
// Just for reference
//int static_pin = 11;
//int dynamic_pins[] = {3, 5, 6, 9, 10};
// I'm using parallel arrays to hold my object info here - each column is
// an LED.
// CONSTANTS
int pwm_pins[] = { 3, 5, 6, 9, 10, 11 };
float base_speeds[] = { 1, 1, 1, 1, 1, .5 }; // in deg/cycle
title: Test Wishlist
dimwishlist:item=3335343363
@bhollis
bhollis / upgrade-v4.diff
Created December 29, 2015 01:52
Upgrade to Middleman v4
commit d6b0db2c98cfbee1b3738fa042c89cb0b81fb661
Author: Ben Hollis <ben@benhollis.net>
Date: Mon Dec 28 17:50:43 2015 -0800
Upgrade to Middleman v4
diff --git a/Gemfile b/Gemfile
index 88f7592..990881c 100644
--- a/Gemfile
+++ b/Gemfile
@bhollis
bhollis / README.md
Created May 9, 2015 17:08
Simple script for copying iCloud Photos / Photostream photos out of the Photos library into a separate folder for import into Lightroom

Copy photos out of Photos App into Lightroom

This is a simple way to get your iCloud Photos / photostream photos out of the Photos app and into Lightroom. Photos get synced from your phone into your Photos library automatically, and this script periodically copies them out into an "import" folder where Lightroom's auto import feature can take over.

To install, copy copy-out-photos into ~/bin and net.benhollis.CopyPhotos.plist into ~/Library/LaunchAgents. Customize copy-out-photos to point to where your Photos library is and where your Lightroom import folder is. Then run these commands:

chmod a+x ~/bin/copy-out-photos
launchctl load ~/Library/LaunchAgents/net.benhollis.CopyPhotos.plist
@bhollis
bhollis / webaudio.js.coffee
Last active September 6, 2022 11:35
A simple interface for playing raw audio samples via the Web Audio API. Meant to mimic the API from dynamicaudio.js.
# The WebAudio object can be used to write raw stereo sound samples.
#
# It has one property, "supported" which returns whether the Web Audio API
# is supported, and one method, "writeStereo" which will play sound samples.
class WebAudio
constructor: ->
if window.AudioContext? || window.webKitAudioContext?
@context = new (window.AudioContext ? window.webKitAudioContext)
@supported = true
else
@bhollis
bhollis / dedup-imovie-library
Last active February 25, 2021 21:07
When you import movies into iMovie 10 libraries, the file is always copied, wasting space and hindering editability. This script replaces the copy with a hardlink, reclaiming disk space.
#!/usr/bin/env ruby
# Usage: dedup-imovie-library LIBRARY ORIGINALS
#
# Goes through an iMovie 10 library and replaces all the "Original Media" with
# hardlinks to the actual original media, in order to conserve disk space. Note
# that because they're hardlinks, if you copy the originals and the iMovie event
# to a new disk, you'll end up with two copies again and will have to re-run this
# tool.
#
@bhollis
bhollis / blog.js.coffee
Last active July 17, 2021 08:05
A simple, made-up example of the code for a simple AngularJS blog viewer as a more detailed exploration of http://benhollis.net/blog/2014/01/17/cleanly-declaring-angularjs-services-with-coffeescript/ . Yes, I know about `$resource`, but I prefer not to use it.
app = angular.module 'BlogExample', []
# Simple controller that loads all blog posts
app.controller 'BlogCtrl', ['$scope', 'Blog', ($scope, Blog) ->
# Get all the blog posts
Blog.all().then (posts) ->
$scope.posts = posts
# Extend the $scope with our own properties, all in one big block
# I like this because it looks like declaring a class.
@bhollis
bhollis / checkerboard.js.coffee
Created November 28, 2013 02:31
Three.js snippet for creating a checkerboard plane. Good for use as a floor in demos.
# Build a checkerboard colored square plane with "segments" number of tiles per side.
# Using three.js v62
checkerboard = (segments=8) ->
geometry = new THREE.PlaneGeometry(100, 100, segments, segments)
materialEven = new THREE.MeshBasicMaterial(color: 0xccccfc)
materialOdd = new THREE.MeshBasicMaterial(color: 0x444464)
materials = [materialEven, materialOdd]
for x in [0...segments]
for y in [0...segments]
@bhollis
bhollis / imovie-event
Created September 1, 2013 20:20
I hate how iMovie wants to move your files into its own directory structure, which is slow and wasteful. This script creates iMovie events as hardlinks to my own directory structure. Hardlinks are requires so that iMovie will let you mark favorites/rejected.
#!/usr/bin/env ruby
# Usage: imovie-event SRC [EVENT NAME]
#
# Creates an iMovie event for all the .MOV files at "SRC".
#
# For me, the iMovie Events folder and some other rules are hardcoded.
require 'fileutils'
@bhollis
bhollis / deepmv
Created August 31, 2013 03:43
Simple script for moving files to another directory while preserving their folder structure.
#!/usr/bin/env ruby
# Usage: deepmv '**/*.rb' ../other
#
# Moves files under the current directory matching a glob
# to another directory, preserving directory structure.
require 'fileutils'
glob = ARGV.shift