Skip to content

Instantly share code, notes, and snippets.

View celeryclub's full-sized avatar

Steve Davis celeryclub

View GitHub Profile
celeryclub / Raspberry Pi setup
Last active May 22, 2019 14:20
Raspberry Pi setup
View Raspberry Pi setup

First, set up Raspbian.

Install prereqs.

sudo apt-get install apparmor-utils apt-transport-https avahi-daemon ca-certificates curl dbus jq network-manager socat software-properties-common

Install docker.

curl -sSL | sh

celeryclub / Raspberry Pi VPN
Last active August 16, 2021 17:27
Raspberry Pi VPN Server
View Raspberry Pi VPN
celeryclub / Raspberry Pi Music
Last active November 22, 2020 08:30
Raspberry Pi Music Server
View Raspberry Pi Music

First, install Raspbian.

Configuring your sound card

This configuration works with HiFiBerry DACs and the Sabre ES9023 chip.

If you are using WiFi, turn off WiFi Power Management.

$ sudo iwconfig wlan0 power off
View 02-parentheticals.rb
sentence = 'Sometimes (when I nest them (my parentheticals) too much (like this (and this))) they get confusing.'
def closing_paren_index( string, opening_paren_index )
depth = 1
partial = string.slice opening_paren_index + 1..-1
partial.each_char.with_index do |char, index|
if char == '('
depth += 1
elsif char == ')'
celeryclub /
Last active January 14, 2016 17:37
Element Query talk

What are Element Queries?

  • Also called container queries
  • A way to change style based on element dimensions
  • Good for reusable components
  • They don't exist

The Problem with Element Queries

  • Circular dependencies
View 01-rotation-index.rb
infile = ARGV[ 0 ]
words = File.readlines( infile )
# O(log n)
def rotation_index( array, lowest_so_far = nil, from = 0, to = nil )
lowest_so_far ||= array.first.downcase
to ||= array.size - 1
if from > to

Feature Branches

Start a branch for each new feature.

git checkout -b <branch>

Publish your branch and set up tracking.

git push -u origin 
celeryclub / Setting up headless Raspberry Pi OS on
Last active September 27, 2023 09:33
Setting up headless Raspberry Pi OS on macOS
View Setting up headless Raspberry Pi OS on

Download the latest Raspberry Pi OS Lite image from (2022-04-04 at the time of this writing).

Insert your microSD card. Use Raspberry Pi Imager to burn the image to your microSD card. Make to select "Set username and password" in the config before starting. Name the user pi and select your own password.

Ensure the disk is mounted again, then enable SSH.

$ touch /Volumes/boot/ssh
celeryclub / image.rb
Last active December 20, 2015 03:19
Example RailsAdmin configuration with a nested resource.
View image.rb
# app/models/image.rb
class Image < ActiveRecord::Base
belongs_to :term
def serializable_hash(options = nil)
hash = super
hash.delete_if { |k, v| v.blank? }