Skip to content

Instantly share code, notes, and snippets.

@mckeed
mckeed / pre-commit
Last active April 15, 2024 23:52
Run rubocop on only staged files in git pre-commit
#!/bin/sh
STAGED_FILES=$(git diff-index HEAD --name-only --cached)
if [[ -z $STAGED_FILES ]]
then
exit # no staged files, no need to run rubocop
fi
# Checks if any staged files have unstaged changes
# otherwise rubocop isn't running on what is actually
@mckeed
mckeed / LoadView.swift
Created August 12, 2022 20:02
SwiftUI view that calls a load function and shows a `LoadingView: UIView` until the `isLoading` binding is changed to false, then displays its contents.
import SwiftUI
typealias IsLoadingBool = Bool // To help remember which way the bool goes (false means ready to display)
protocol LoadedView {
func load() -> Binding<IsLoadingBool>
}
// LoadingView is an existing full-screen UIView in my codebase.
// This could be replaced by any custom View
@mckeed
mckeed / encrypto
Created October 15, 2015 15:45
Shell script for easy encrypting of folders using keybase (I'm not a shell script master so let me know if there's errors)
if [ -d "$2" ]; then
( set -x
tar -cz "$2" | keybase encrypt -bs $1 -o "$2".tgz.gpg
)
elif [ -f "$2" ]; then
( set -x
keybase encrypt -bs $1 $2
)
else
echo "Usage: encrypto keybaseuser path"
@mckeed
mckeed / aeon-multisensor-6.groovy
Last active May 15, 2016 19:06
Aeon Labs Multisensor 6 device handler
/**
* Copyright 2015 SmartThings
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
@mckeed
mckeed / aeon-rgbw-bulb.groovy
Created July 17, 2015 04:10
Aeon Labs RGBW LED Bulb device handler
/**
* Copyright 2015 SmartThings
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
@mckeed
mckeed / rgbw-light.groovy
Created July 17, 2015 04:09
Z-Wave RGBW Light device handler
/**
* Copyright 2015 SmartThings
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
@mckeed
mckeed / aeon-siren-with-sound-cmds.groovy
Last active October 24, 2018 01:56
Aeon Siren w/sound commands
/**
* Aeon Siren with Sound Commands + revert to default
*
* Author: SmartThings
* Date: 2014-07-15
*/
metadata {
definition (name: "Aeon Siren", namespace: "smartthings", author: "SmartThings") {
capability "Actuator"
capability "Alarm"
@mckeed
mckeed / accessory-switch.groovy
Created November 12, 2014 04:46
Z-Wave Accessory Switch SmartThings Device Type
metadata {
// Automatically generated. Make future change here.
definition (name: "Accessory Switch", namespace: "mckeed", author: "Duncan") {
capability "Switch"
capability "Switch Level"
capability "Sensor"
command "associate"
fingerprint deviceId: "0x12"
@mckeed
mckeed / ridiculously-automated-zwave-garage-door.groovy
Last active March 20, 2019 17:53
Ridiculously Automated Garage Door for GD00Z
/**
* Ridiculously Automated Garage Door
*
* Author: SmartThings
*
* Monitors arrival and departure of car(s) and
*
* 1) opens door when car arrives,
* 2) closes door after car has departed (for N minutes),
* 3) opens door when car door motion is detected,
@mckeed
mckeed / zwave-garage-door.groovy
Last active July 17, 2016 19:39
Z-Wave Garage Door Opener device type handler
/**
* Z-Wave Garage Door Opener
*
* Copyright 2014 SmartThings
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*