Skip to content

Instantly share code, notes, and snippets.

View platy's full-sized avatar
🐟

Mike Bush platy

🐟
View GitHub Profile
@stonehippo
stonehippo / docker_usb_guest_osx.md
Last active May 27, 2024 23:36
Getting a USB device to show up in a Docker container on OS X

Getting a USB device to show up in a Docker container on OS X

Some background

I was trying to get the Arduino IDE to work inside a Docker container on OS X. I was able to get the IDE working (see Getting X11 GUI applications to work on OS X with Docker), but I could not figure out how to make the USB port for the Arduino visible.

The solution

I first tried to directly map hardware serial port into the Docker container, doing something like this:

@Aatch
Aatch / borrow-example.rs
Last active July 5, 2023 04:22 — forked from kolmodin/rust-json.rs
An example and explanation of how to use lifetimes and borrowing to avoid copying, while maintaining safety.
extern mod extra;
use extra::json::*;
/*
* This function manages to do absolutely no copying, which is pretty cool.
*
* "What are all those `'r`s?" you ask. Well, they're liftime parameters. They
* indicate how long something lasts (before it's freed). They can't change how
* long something lives for, they only allow you to tell the compiler stuff it
module Acts
module Cacheable
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def acts_as_cacheable(key, options = {})
extend Acts::Cacheable::SingletonMethods
find(:all, options).each{|instance| cached_objects[instance.send(key).to_s] = instance}