Skip to content

Instantly share code, notes, and snippets.

View rbrunt's full-sized avatar

Richard Brunt rbrunt

View GitHub Profile
@rbrunt
rbrunt / shelly_with_ha.js
Created January 3, 2025 18:37 — forked from aigarius/shelly_with_ha.js
Shelly script to revert to direct switch control if Home Assistant is not available
// Preconditions:
// Shelly connected to a manual switch and to a smart light
// Shelly set to disconnected mode and to restore power to on after power loss
// Input mode is button (might need a minor change for switch - untested)
// Shelly is added to Home Assistant
// An automation is created in Home Assistant to toggle the light when single button press is
// detected on the Shelly (other automations may also exist)
let online_status = 0;
// Change this to the URL of your Home Assistant base URL + "/api/ping"
datasources=()
for index in `http :9200/_cat/indices?h=index | grep validated`; do
datasource=`http :9200/$index/_search | jq -r '.hits.hits[0]._source.evidence_string | fromjson.sourceID'`
datasources+=($datasource)
done
evidence_index=`http :9200/_cat/indices?h=index | grep evidence-data-generic`
for datasource in "${datasources[@]}"; do
count=`http :9200/$evidence_index/_count?q=sourceID:$datasource | jq '.count'`
@rbrunt
rbrunt / gist:095a7db1a7e8ceeab0d8
Created December 18, 2014 19:55
Compute md5 checksum for all files in cwd recursively
find ./* -type f -exec md5sum {} \;>> ./check.md5
@rbrunt
rbrunt / css_resources.md
Last active August 29, 2015 14:06 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@rbrunt
rbrunt / javascript_resources.md
Last active August 29, 2015 14:06 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@rbrunt
rbrunt / python_resources.md
Last active August 29, 2015 14:06 — forked from jookyboi/python_resources.md
Python-related modules and guides.

Packages

  • lxml - Pythonic binding for the C libraries libxml2 and libxslt.
  • boto - Python interface to Amazon Web Services
  • Django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • Fabric - Library and command-line tool for streamlining the use of SSH for application deployment or systems administration task.
  • PyMongo - Tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
  • Celery - Task queue to distribute work across threads or machines.
  • pytz - pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher.

Guides

@rbrunt
rbrunt / Detectives.md
Last active August 29, 2015 14:06
Computer Naming Schemes

Detectives

  • Magnum
  • Jessica Fletcher
  • Luther
  • Rockford, Jim
  • Columbo
  • James Crockett
  • Ricardo Tubbs
  • Miami Vice
@rbrunt
rbrunt / index.html
Last active December 27, 2015 23:19
Animated SVG Logo for redesign of my website. Thinking that the animation could be used as a loading indicator... http://bl.ocks.org/rbrunt/7405475
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<style>
body {
width: 100%;
margin: 0;
/*background:#000;*/
}
#logocontainer svg {
@rbrunt
rbrunt / addDocsLink.js
Last active October 11, 2015 12:57
Adds a link to view all pdf files linked to in a page in google docs viewer
@rbrunt
rbrunt / scroller.js
Created August 9, 2012 09:32
Using #section links with scrollto jquery plugin without any messy jumpiness :)
$(document).ready(function(){
$('nav a').click(function(e){
// If a link has been clicked, scroll the page to the link's hash target:
// Links just need their href to be the hash of the section you're scrolling to e.g. #top, no class to choose them...
// This has the advantage that there is no loss in functionality from users without javascript
$.scrollTo( this.hash || 0, 300);
// Update the URL in the browser to the new anchor point
history.pushState(null, null, this.href);
// Prevents the browser actually following the link - no jumping down before scrolling :)