Skip to content

Instantly share code, notes, and snippets.

View tchellomello's full-sized avatar

Marcelo Mello tchellomello

View GitHub Profile
@tchellomello
tchellomello / select-tablesizes.sql
Created October 21, 2016 16:17
PostgreSQL table sizes
SELECT table_name, pg_size_pretty(total_bytes) AS total
, pg_size_pretty(index_bytes) AS INDEX
, pg_size_pretty(toast_bytes) AS toast
, pg_size_pretty(table_bytes) AS TABLE
FROM (
SELECT *, total_bytes-index_bytes-COALESCE(toast_bytes,0) AS table_bytes FROM (
SELECT c.oid,nspname AS table_schema, relname AS TABLE_NAME
, c.reltuples AS row_estimate
, pg_total_relation_size(c.oid) AS total_bytes
, pg_indexes_size(c.oid) AS index_bytes
@tchellomello
tchellomello / automatic_debug.diff
Created October 28, 2016 04:57
automatic_debug.diff
diff --git a/homeassistant/components/device_tracker/automatic.py b/homeassistant/components/device_tracker/automatic.py
index 27bd9c6..2d10eb8 100644
--- a/homeassistant/components/device_tracker/automatic.py
+++ b/homeassistant/components/device_tracker/automatic.py
@@ -114,12 +114,15 @@ class AutomaticDeviceScanner(object):
response = requests.get(URL_VEHICLES, headers=self._headers)
response.raise_for_status()
+ _LOGGER.debug('reponse: %s', response)
"""
Support for WUnderground weather service.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.wunderground/
"""
from datetime import timedelta
import logging
import requests
@tchellomello
tchellomello / 90-convert_grub2
Last active November 17, 2016 18:36
IBM Power hook for Satellite 6
#!/usr/bin/env python
import os
import re
TFTP_PXELINUX_ROOT_CFG="/var/lib/tftpboot/pxelinux.cfg"
TFTP_GRUB_ROOT_CFG="/var/lib/tftpboot/boot/grub2/powerpc-ieee1275"
TFTP_GRUB_CFG_PREFIX="grub.cfg-"
GRUB2_TEMPLATE="""
set default=0
set timeout=5
@tchellomello
tchellomello / wunderground.py
Last active November 25, 2016 19:19
Troubleshooting "Check WUnderground API update ('you must supply a key',)"
"""
Support for WUnderground weather service.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.wunderground/
"""
from datetime import timedelta
import logging
import requests
@tchellomello
tchellomello / amcrest.py
Last active November 24, 2016 04:10
V1.0 amcrest camera for Home Assistant
"""
This component provides basic support for Amcrest IP cameras.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/camera.amcrest/
"""
import logging
import voluptuous as vol
from amcrest import AmcrestCamera
@tchellomello
tchellomello / wunderground.py
Created November 30, 2016 08:36
Test code to support language on HA
"""
Support for WUnderground weather service.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.wunderground/
"""
from datetime import timedelta
import logging
import re
@tchellomello
tchellomello / active_queries_sat5.sh
Created November 30, 2016 22:21
Monitor active queries for Satellite 5
#!/bin/bash
export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/opt/rh/postgresql92/root/usr/bin"
PG_VERSION=$(su - postgres -c "psql -c 'select version();'" | grep "^ PostgreSQL" | cut -f 3 -d ' ' | cut -f1 -d'.')
if [ $PG_VERSION -eq 9 ]; then
echo "SELECT query,xact_start,query_start FROM pg_stat_activity GROUP BY query,xact_start,query_start;" | spacewalk-sql --select-mode -
elif [ $PG_VERSION -eq 8 ]; then
@tchellomello
tchellomello / amcrest.py
Last active January 11, 2017 22:16
HA Amcrest Sensor - Beta
"""
This component provides basic support for Amcrest IP cameras.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.amcrest/
"""
from datetime import timedelta
import logging
import voluptuous as vol
@tchellomello
tchellomello / pulp-admin.sh
Last active January 28, 2019 19:24
pulp-admin.sh
#!/bin/bash
STATE=""
for TASK in `pulp-admin tasks list | egrep '^Task Id:|^State:' | sed -e 's,^Task Id: ,,' -e 's,^State: ,,'`; do
if [ "$STATE" = "" ]; then
STATE=$TASK
else
if [ $STATE != Successful ] && [ $STATE != Cancelled ] && [ $STATE != Failed ]; then
pulp-admin tasks details --task-id=$TASK
pulp-admin tasks cancel --task-id=$TASK
fi