Skip to content

Instantly share code, notes, and snippets.

View yottatsa's full-sized avatar

Atsuko Ito yottatsa

View GitHub Profile
#!/bin/sh -e
# Author: yottatsa
su - yottatsa -c 'make backup' 2>&1 | /usr/bin/logger -t backup
if \
[ $(date -d "today" "+%m") -ne $(date -d "tomorrow" "+%m") ] || \
[ "$(date '+%a')" = "Tue" -a $(date +%d) -lt 29 -a $(date +%d) -gt 2 ]
then
(
@yottatsa
yottatsa / keylist.sh
Created March 26, 2018 10:32
Script to generate a list of participants for the Keybase-based keysigning party
#!/bin/sh
# based on https://fosdem.org/2018/keysigning/
TEAM="${1:-keysigning_fblon}"
TMPDIR="$( mktemp -d -t ksp-XXXXXXXX )"
cleanup() {
rm -rf "$TMPDIR"
}
@yottatsa
yottatsa / sunlight-and-dnd-hue.json
Created July 2, 2018 22:19
Switch on the daylight when it's going dark, and switch on the nightlight when the motion is detected in the night. Do not disturb existing scenes.
[
{
"name": "1:me/sunlight-and-dnd",
"status": "enabled",
"conditions": [
{
"address": "/sensors/39/state/status",
"operator": "eq",
"value": "0"
},
NOTIFY
HOST: 192.168.1.201:8123
CONTENT-TYPE: text/xml; charset="utf-8"
CONTENT-LENGTH: 1498
NT: upnp:event
NTS: upnp:propchange
SID: uuid:13891460-64ef-1cef-b249-d82842f5fcfb
SEQ: 0
<?xml version="1.0" encoding="utf-8"?>
@yottatsa
yottatsa / home-assistant.log
Created July 8, 2018 14:55
Broken subscription and subsequent empty status
2018-07-08 15:50:19 DEBUG (SyncWorker_15) [homeassistant.components.media_player.dlna_dmr] Adding device: <DlnaDmrDevice('uuid:13a1b0b0-6f3f-1bb2-a179-f8281933582b')>
2018-07-08 15:50:29 DEBUG (MainThread) [async_upnp_client.async_upnp_client.traffic] Sending request:
GET http://192.168.1.6:2870/dmr.xml
2018-07-08 15:50:29 DEBUG (MainThread) [homeassistant.components.media_player.dlna_dmr] <homeassistant.components.media_player.dlna_dmr.HassUpnpRequester object at 0x10b10fa90>.async_http_request(): method: GET, soap_action:
2018-07-08 15:50:29 DEBUG (MainThread) [async_upnp_client.async_upnp_client.traffic] Got response:
200
CONTENT-TYPE: text/xml; charset="utf-8"
LAST-MODIFIED: Mon, 31 Jul 2017 13:40:11 GMT
DATE: Sun, 08 Jul 2018 14:50:25 GMT
SERVER: IPI/1.0 UPnP/1.0 DLNADOC/1.50
@yottatsa
yottatsa / home-assistant.log
Created July 8, 2018 15:22
Sending new media without stopping previous raising the exception on media_player side.
2018-07-08 16:20:58 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall media_player.play_media: media_content_id=http://192.168.1.201:8123/api/tts_proxy/add04a2695f53fdeb6217601c85af6c44abe2f38_en_-_google.mp3, media_content_type=music, entity_id=['media_player.philips']>
Traceback (most recent call last):
File "/Users/yottatsa/Public/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 1021, in _event_to_service_call
await service_handler.func(service_call)
File "/Users/yottatsa/Public/homeassistant/lib/python3.6/site-packages/homeassistant/components/media_player/__init__.py", line 441, in async_service_handler
await getattr(player, method['method'])(**params)
File "/Users/yottatsa/Public/homeassistant/lib/python3.6/site-packages/homeassistant/components/media_player/dlna_dmr.py", line 641, in async_play_media
CurrentURIMetaData=meta_data)
File "/Users/yottatsa/Public/homeassistant/lib/python3.6/site-packages/async_upnp_client/async_upnp_client
2018-07-08 16:31:35 DEBUG (MainThread) [async_upnp_client.async_upnp_client.traffic] Sending request:
POST http://192.168.1.6:2870/control/AVTransport
SOAPAction: "urn:schemas-upnp-org:service:AVTransport:3#SetAVTransportURI"
Host: 192.168.1.6:2870
Content-Type: text/xml
Content-Length: 1191
<?xml version="1.0"?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
@yottatsa
yottatsa / home-assistant.log
Created July 8, 2018 16:34
Urlencoded QUERY_STRING
POST http://192.168.1.6:2870/control/AVTransport
SOAPAction: "urn:schemas-upnp-org:service:AVTransport:3#SetAVTransportURI"
Host: 192.168.1.6:2870
Content-Type: text/xml
Content-Length: 1191
<?xml version="1.0"?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
2018-07-21 12:54:14 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform dlna_dmr
Traceback (most recent call last):
File "/Users/yottatsa/Public/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 129, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File "/opt/homebrew/Cellar/python36/3.6.2+_254.20170915/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
return fut.result()
File "/opt/homebrew/Cellar/python36/3.6.2+_254.20170915/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/futures.py", line 245, in result
raise self._exception
File "/opt/homebrew/Cellar/python36/3.6.2+_254.20170915/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/tasks.py", line 180, in _step
result = coro.send(None)
@yottatsa
yottatsa / re-crypt.sh
Last active November 13, 2018 19:55
re-crypt asymmetrically encrypted files using symmetric encryption (e.g for back up)
#!/bin/sh -eu
# this is a self-verifying shell script
exec sh -eu -c "$(gpg -o - --verify "${0}")" "${0}" "$@"
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
#!/bin/sh -eu
set -o pipefail
exec 2>> "${0}.log"