Skip to content

Instantly share code, notes, and snippets.

@poohsen
poohsen / log.sh
Last active February 5, 2024 09:01
A better 'echo' for BASH script output
log () {
current_date=$(date +"%Y-%m-%d %H:%M:%S,%N")
ns=${current_date:20:9}
# turn ns to ms using rounding
rounded_millis=$(printf "%.0f" $(echo "scale=6;$ns/1000000" | bc))
msg=$1
echo "${current_date:0:20}${rounded_millis} - ${msg}"
}
@poohsen
poohsen / duck_avr.sh
Created January 15, 2024 07:47
duck avr when mycroft listens
#! /usr/bin/env python3
from mycroft_bus_client import MessageBusClient, Message
from kodijson import Kodi
from dotenv import load_dotenv
import os
import time
import threading
import re
@poohsen
poohsen / gist:faf2e6585efa7685b84cc3206a6de406
Created January 7, 2023 15:35
duck kodi volume on wakeword detection, unduck after TTS ran
#! /usr/bin/env python3
from mycroft_bus_client import MessageBusClient, Message
from kodijson import Kodi
from dotenv import load_dotenv
import os
load_dotenv()
kodi_username = os.getenv('KODI_USERNAME')
all of a sudden, at 2:00 in the night, I started getting these errors:
[2014-05-09 13:35:43,032][DEBUG][action.bulk ] [Bushmaster] [.marvel-2014.05.09][0] failed to execute bulk item (index) index {[.marvel-2014.05.09][index_stats][zToUMDvuSxS0wVAPKB236A], source[{"@timestamp":"2014-05-09T11:35:43.024Z","cluster_name":"elasticsearch","index":".marvel-2014.05.09","_source_node":{"id":"62b9fpf0TTC8D3VH8NWgFg","name":"Bushmaster","transport_address":"inet[79.99.186.108/79.99.186.108:9300]","ip":"79.99.186.108","host":"79.99.186.108","ip_port":"79.99.186.108:9300","master_node":true,"data_node":true,"master":true},"primaries":{"docs":{"count":3368,"deleted":0},"store":{"size_in_bytes":16965332,"throttle_time_in_millis":73833},"indexing":{"index_total":3369,"index_time_in_millis":7681,"index_current":0,"delete_total":0,"delete_time_in_millis":0,"delete_current":0},"get":{"total":0,"time_in_millis":0,"exists_total":0,"exists_time_in_millis":0,"missing_total":0,"missing_time_in_millis":0,"current":0},"