Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

To claim this, I am signing this object:

/**
* Need the existence of a .dx-companion.json file at the project root
*
* .dx-companion.json format:
* {
* "actions": [{
* "label": "action label",
* "command": "sleep 3;exit"
* }],
* "observedFiles": [{
@micoli
micoli / zigbee-report.sh
Created August 27, 2023 17:07
websocat zigbee2mqtt devices
#!/bin/bash
# example ./zigbee-report.sh 192.168.2.100
websocat ws://$1 --max-messages-rev 5 -U -B 2621440 | grep "bridge/devices" > /tmp/zigbeedevices.json
echo "Count"
cat /tmp/zigbeedevices.json | jq '.payload | {total: length}'
echo "Detailed Count"
cat /tmp/zigbeedevices.json | jq -r '.payload | group_by (.type)| map({type: .[0].type, count: length}) | reduce .[] as $line ({}; . *= {(($line.type[:1]|ascii_downcase)+($line.type[1:])):($line.count)})'
#!/usr/bin/env bash
# git-fixup (https://github.com/keis/git-fixup)
SUBDIRECTORY_OK=yes
. "$(git --exec-path)/git-sh-setup"
# Define a sed program that turns `git diff` output into a stream of filenames
# and sections within those files.
grok_diff='/^--- .*/p ;
s/^@@ -\([0-9]*\),\([0-9]*\).*/\1 \2/p'
<?php
$date1 = DateTimeImmutable::createFromFormat('Y-m-d','2012-12-01');
$date2 = DateTimeImmutable::createFromFormat('Y-m-d H:i:s','2012-12-10 12:00:00');
dd([
$date1->diff($date2)->invert, // 0
$date2->diff($date1)->invert, // 1
$date1->diff($date2)->format('%d'), // "8"
$date2->diff($date1)->format('%d'), // "8"
(int)$date2->diff($date1)->format('%R%a'), // -8
(int)$date1->diff($date2)->format('%R%a') // 8
git config --global rebase.autosquash true
[alias]
...
# fixup for a file, using the commit where it was last modified
fixup-file = "!sh -c '\
[ $(git diff --numstat $1 | wc -l) -eq 1 ] && git add $1 && \
[ $(git diff --cached --numstat $1 | wc -l) -eq 1 ] || (echo No changes staged. ; exit 1) && \
COMMIT=$(git log -n 1 --pretty=format:"%H" $1) && \
git commit --fixup=$COMMIT "
#&& \ git rebase -i --autosquash $COMMIT~1' -
EDITOR=true git rebase --autosquash --autostash -i origin/master
print "<pre>";
print_r(array_map(function($v){
return array_filter($v,function($v){
return in_array($v,["title","created_at","updated_at","source_branch","web_url"]);
},ARRAY_FILTER_USE_KEY);
},$mergeRequests));
die();
#!/bin/bash
defaults write -g InitialKeyRepeat -int 15 # normal minimum is 15 (225 ms)
defaults write -g KeyRepeat -int 2 # normal minimum is 2 (30 ms)