Skip to content

Instantly share code, notes, and snippets.

@kelchm
kelchm / bulk-rename-entities.sh
Created April 1, 2023 11:40
hass-cli examples
#!/bin/bash
for i in $(hass-cli entity list "living_room_recessed_lights*" |awk '{print $1}' | grep -v ENTITY_ID)
do
NEW_ID=$(echo $i | sed 's/living_room_recessed_lights/living_room_fireplace_recessed_lights/')
echo "hass-cli entity rename ${i} ${NEW_ID}"
# hass-cli entity rename ${i} ${NEW_ID}
done
@kelchm
kelchm / cables-report.php
Created December 30, 2013 22:40
A simple report for racktables which displays all named cables and provides links to the relevant ports.
<?php
include ('inc/init.php');
$tabhandler['reports']['cableid'] = 'renderCableIdReport'; // register a report rendering function
$tab['reports']['cableid'] = 'Cable IDs'; // title of the report tab
function renderCableIdReport()
{
global $dbxlink;
$sql = "SELECT Link.*, porta.id as porta_id, porta.name as porta_name, objecta.id as objecta_id, objecta.name as objecta_name, portb.id as portb_id, portb.name as portb_name, objectb.id as objectb_id, objectb.name as objectb_name
❯ nrfutil settings display nrf-cgg1-stock-1.1.2_0020.hex
Bootloader DFU Settings:
* File: nrf-cgg1-stock-1.1.2_0020.hex
* Family: nRF52
* Start Address: 0x00000000
* CRC: 0x4EE9A698
* Settings Version: 0x00000001 (1)
* App Version: 0x000000FF (255)
* Bootloader Version: 0x00000000 (0)
@kelchm
kelchm / machine.js
Created May 20, 2020 15:24
Generated by XState Viz: https://xstate.js.org/viz
const hasDelinquencies = () => true;
const hasInsufficientFunds = () => false;
const generateDisqualificationStates = (name, condition) => ({
[name]: {
initial: 'evaluating',
states: {
evaluating: {
on: {
EVALUATE_DISQUALIFICATION: [
@kelchm
kelchm / machine.js
Last active May 8, 2020 21:57
Generated by XState Viz: https://xstate.js.org/viz
const hasDelinquencies = () => true;
const hasInsufficientFunds = () => false;
const financialPlanMachine = Machine({
id: 'financialPlan',
initial: 'checkingForDisqualification',
states: {
checkingForDisqualification: {
on: {
FINISH_DISQUALIFICATION: [
@kelchm
kelchm / codegen.js
Last active June 18, 2019 03:30
babel-plugin-codgen dynamic named exports troublshooting
const questionFactory = require('./questionFactory');
const generalQuestionConfig = require('./generalConfig');
const processedConfig = questionFactory('general', generalQuestionConfig);
module.exports = Object.keys(processedConfig)
.map(key => `export const ${key} = ${JSON.stringify(processedConfig[key])}`)
.join(';');
@kelchm
kelchm / docker-compose.yml
Created August 16, 2017 13:32
Consul Sample
version: '2'
services:
consul:
image: consul:latest
stdin_open: true
tty: true
ports:
- 8500/tcp
command:
- consul
<?php
class Helper {
static function getIfSet(& $var) {
if (isset($var)) {
return $var;
}
return null;
}
}
variables:
COMPOSE_FILE: "docker-compose.rancher.yml"
TRAEFIK_ENABLED: "true"
STACK_NAME: $CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG
stages:
- build
- deploy
- cleanup
@kelchm
kelchm / docker-compose.yml
Created February 24, 2017 20:08
Self-Registration of GitLab Runners within Rancher
version: '2'
services:
gitlab-runner-config:
image: gitlab/gitlab-runner:alpine
stdin_open: true
volumes:
- /etc/gitlab-runner/
tty: true
command:
- register