Skip to content

Instantly share code, notes, and snippets.

View ginjo's full-sized avatar

William Richardson ginjo

View GitHub Profile
@ginjo
ginjo / croncpp_esphome_schedules.h
Last active September 12, 2024 22:23
C++ class to add dynamic editable cron schedules to esphome
#pragma once
#include <croncpp.h>
#include <iostream>
#include <string>
#include <regex>
#include <vector>
#include <map>
#include <algorithm>
#include <Preferences.h>
@ginjo
ginjo / basic_ha_zwave_docker_setup.md
Created February 15, 2024 04:37
Home Assistant, Docker, zwave-js-ui, ser2net

Home Assistant running in Docker, using zwave-js-ui and ser2net to access zwave USB stick over TCP.

Basic setup for HomeAssistant using zwave-js-ui for z-wave, and ser2net to host the z-wave usb stick on TCP port. We use ser2net, because USB device passthru doesn't work on Docker Mac, Docker Windows, or Swarm-mode (even on Linux).

This system is running on a Raspberry Pi 3 B+, however I also had it running on a Mac (Mojave) using 'nix' package manager to install ser2net.

Some paths and device names are specific to my setup.

@ginjo
ginjo / stripe_test_webhook.sh
Last active July 19, 2023 23:26
Wrapper script for stripe-cli trigger function, opens sender and receiver in split-pane screen sessions.
#!/bin/bash
# Launches two stripe-cli docker containers, each in its own 'screen' session,
# to test stripe webhook events against a local http server.
#
# * Launches one container for the listener/forwarder.
# * Launches one container to trigger the test webhook event.
#
# NOTE: The stripe-cli 'trigger' function will create a lot of data in your
# stripe account's test environment. The only way to remove that data is manual one-by-one
@ginjo
ginjo / vue3-bulma-reusable-tabs.html
Last active January 30, 2023 22:47
Example of a reusable html tabs vuejs-3 component with bulma css
<!DOCTYPE html>
<html>
<head>
<!--
This is an example of a reusable html tabs vuejs-3 component.
You can set this up once in your project and create as many
tabbed interfaces as you like, with no extra code.
This example was taken from https://github.com/mattmaribojoc/learn-vue-tab
@ginjo
ginjo / json_rpc_object.gemspec
Last active June 11, 2023 00:02
A Ruby class to create and manage JSON-RPC data structures
# frozen_string_literal: true
# This gemspec currently describes a gem hosted on Github as a Gist only.
# See https://bundler.io/guides/git.html
require_relative "json_rpc_object_version.rb"
Gem::Specification.new do |spec|
spec.name = "json_rpc_object"
spec.version = JsonRpcObject::VERSION
@ginjo
ginjo / Gemfile
Last active November 12, 2023 08:48
Wrappers for Bunny Gem (rabbitmq) providing 1. Multiple consumer threads, 2. Simple setup of RPC call/callback publishers and consumers.
source "https://rubygems.org"
gem 'json_rpc_object', gist:'5b128c655e79e1b4e0e10c27a5098177'
#gem 'connection_pool'
#gem 'json_rpc_object', path:'../JsonRpcRuby'
# Declare your gem's dependencies in foo.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
@ginjo
ginjo / convert_rpp_to_yaml.sh
Last active August 17, 2022 11:23
Convert Reaper file (.rpp) to YAML
### Converts Reaper data file (.rpp) to YAML, using Awk.
### All scalar values will be enclosed in single quotes.
###
### Usage: (with standard input) cat <reaper-data-file.rpp> | <this-script-file>
### (with filename as first arg) <this-script-file> <reaper-data-file.rpp>
###
### Returns: formatted YAML document
###
### Example usage with yq (shell-based yaml parser):
###
@ginjo
ginjo / omniauth-slack-integration.md
Last active February 20, 2024 21:50
OmniAuth::Slack OAuth2 Cycle Description and Integration Notes

OmniAuth::Slack OAuth2 Cycle Description and Integration Notes

This document was written for the ginjo-omniauth-slack ruby gem. It attempts to clarify the OAuth2 authorization cycle and how that cycle is implemented in your appliation with the ginjo-omniauth-slack gem.

OAuth2

The OAuth2 cycle is a three-way dance between the user's browser, the OAuth2 provider (Slack API), and the application server (your Slack App). It should work this way for any OAuth2 provider, including Slack.

  1. The user/browser makes a request to https://slack.com/oauth/authorize, passing the application's client-id, requested-scopes, and optionally state, team-id, and redirect-uri. Slack then runs the user through the authorization dialogs.
### This is an OmniAuth::AuthHash object from the ginjo fork of omniauth-slack.
### This AuthHash represents a workspace token with a number of identity and non-identity scopes.
--- !ruby/hash:OmniAuth::AuthHash
provider: slack
uid: U0BCC482X-T0BCJPFAM
info: !ruby/hash:OmniAuth::AuthHash::InfoHash
name: Bill
email: xxx@mac.com
user_id: U0BCC482X
@ginjo
ginjo / auth_hash.yml
Created July 27, 2018 02:10
Slack workspace token OmniAuth::AuthHash object from ginjo fork of omniauth-slack gem, from non-admin user of "new" Slack app
--- !ruby/hash:OmniAuth::AuthHash
provider: slack
uid: U281GAVT5-T0BCJPFAM
info: !ruby/hash:OmniAuth::AuthHash::InfoHash
name: Bill Richards
email: myemail@gmail.com
user_id: U281GAVT5
team_name: WbrSandbox
team_id: T0BCJPFAM
image: