Skip to content

Instantly share code, notes, and snippets.

View triplepoint's full-sized avatar

Jonathan Hanson triplepoint

  • Saildrone, Inc.
  • Oakland, CA
  • 15:02 (UTC -08:00)
View GitHub Profile
@triplepoint
triplepoint / wake-up-light-alarm-with-sunrise-effect.yaml
Last active October 26, 2024 08:51 — forked from sbyx/wake-up-light-alarm-with-sunrise-effect.yaml
Home Assistant Blueprint: Wake-up light alarm with sunrise effect
blueprint:
name: Wake-up light alarm with sunrise effect
description:
"A wake-up light alarm with a brightness and color temperature sunrise
effect. Note: not manually executable!"
domain: automation
input:
light_entity:
name: Wake-up light entity
description:
@triplepoint
triplepoint / Vagrantfile
Created October 20, 2019 23:32
A Vagrantfile, with instructions, for dealing with Arduino not functioning on MacOS Catalina.
###
# See: https://code-chronicle.blogspot.com/2014/08/connect-usb-device-through-vagrant.html
# See: https://docs.oracle.com/cd/E97728_01/E97727/html/vboxmanage-usbfilter.html
# Assuming MacOS as the host OS, with Homebrew already installed:
# Install Vagrant and Virtualbox with Homebrew:
# brew cask install vagrant virtualbox virtualbox-extension-pack
#
# After installing Vagrant and Virtualbox, on the host machine,
# do:
# VBoxManage list usbhost
@triplepoint
triplepoint / _sshd_port_juggling.yml
Last active January 19, 2024 21:12
Ansible - fall back to a default ssh port if the configured ssh port fails
---
# This task list is intended to be imported by playbooks, before any
# other tasks are performed. It lets us determine whether the configured SSH
# port is available, and lets us fall back to the default port if necessary.
#
# The use case here is when a role in the playbook is configured to change the
# sshd port, but the first time the role is executed the host is still
# listening on the default port. With this check in place, we can fall back
# to the default port on the first run, and then on subsequent runs use the
# configured port.
@triplepoint
triplepoint / _python_2_check.yml
Last active September 28, 2018 21:08
Python 2 Check, importable Ansible playbook snippet to ensure Python 2 is available (for instance, on an Ubuntu xenial target)
---
# This task list is intended to be imported by playbooks, before any
# other tasks are performed. It lets us install Python 2 (needed by Ansible)
# before Ansible tries to call anything that would use it.
#
# Execute these tasks as the first thing in a playbook like so:
# - hosts: some-host-group
# gather_facts: false
# tasks:
# - import_tasks: _python_2_check.yml
@triplepoint
triplepoint / add_prefix_to_xyz_tags.sh
Last active February 26, 2016 22:39
How to remove tags of the form 'X.Y.Z',
#! /usr/bin/env bash
set -e
# The prefix 'namespace' in tags of the form 'some_prefix/x.y.z'
PROJECT_PREFIX="some_prefix"
# Get all the current tags on the repository
TAGS=`git tag`
### ADD PREFIXES TO ALL THE 'X.Y.Z' TAGS
@triplepoint
triplepoint / use_it_like.sh
Created February 7, 2016 22:24
Bash function to only install Vagrant plugins if they're not already installed.
# This would install vagrant-aws, if it's not already installed
# And do nothing if it was already installed.
vagrant_plugin_install vagrant-aws
@triplepoint
triplepoint / rust_demo.rs
Created January 2, 2016 22:23
Short rust pattern-matching demonstration.
fn main() {
//let some_value: Result<i32, &'static str> = Ok(12);
//let some_value: Result<i32, &'static str> = Err("METAL!");
let some_value: Result<i32, &'static str> = Err("There was an error");
match some_value {
Ok(value) => println!("got a value: {}", value),
Err("METAL!") => println!("a specific metal error occured"),
Err(x) => println!("an unknown error occurred: {}", x),
}
@triplepoint
triplepoint / dependency_injection_demo.php
Last active July 24, 2019 12:06
Simple demonstration of dependency injection with a container in PHP.
<?php
// --- Library classes that provide behaviors ---
/**
* In these examples:
* - The Controller needs a view renderer
* - The view renderer needs a Database and a Logger
*
* Note, that the interfaces aren't being defined here, just assume they're what you'd expect.
*/
@triplepoint
triplepoint / php_multibyte_demo.php
Last active October 13, 2015 00:08
PHP multibyte string demonstration
<?php
/**
* The point of this demonstration is to show how easily multibyte strings can be mangled in PHP.
*
* A random 50-character multibyte string is generated, and then several string functions defined in
* $commands are eval()'ed and the output is shown.
*
* The point to notice is that the non-mb_* commands will have inaccurate or mangling behavior with
* multibyte strings. Also important to note is that if the mb_* functions' encoding doesn't match the
* encoding of the string, they will still likely have unintended behavior.