Skip to content

Instantly share code, notes, and snippets.

View ciaranj's full-sized avatar

Ciaran Jessup ciaranj

View GitHub Profile
@ciaranj
ciaranj / agent notification blueprint.yaml
Last active April 10, 2024 19:43
Enhanced Home Assistant Notification Blueprint
# Derived from https://gist.github.com/allenporter/e70d9eb090c7dbdd593cf526e07b4abe with extensions from the comment thread applied
blueprint:
name: Daily Conversation Agent Agenda Notification
description: |
Conversation agent generates a personalized notification based on the
upcoming calendar agenda, birthday reminders, location, and weather information in your language.
domain: automation
input:
notify_time:
name: Notification time
@ciaranj
ciaranj / calculate-contains-window.js
Created January 24, 2019 13:06
Gist to calculate the properties of an image that has been scaled/positioned through the CSS object-fit and object-position properties
function calculateContainsWindow(image) {
var imageComputedStyle = window.getComputedStyle(image);
var imageObjectFit = imageComputedStyle.getPropertyValue("object-fit");
var coordinates = {};
var imagePositions = imageComputedStyle.getPropertyValue("object-position").split(" ");
var naturalWidth = image.naturalWidth;
var naturalHeight= image.naturalHeight;
if( image.tagName === "VIDEO" ) {
naturalWidth= image.videoWidth;
@ciaranj
ciaranj / gist:9056285
Created February 17, 2014 18:32
A *working* (on Windows) UDP Multicast client & server with Node.Js v0.10.25 (I spent a *LOT* of time getting EINVAL and I still don't quite know why :/)
For my own sanity ;) Scraped from a variety of places, including: http://stackoverflow.com/questions/14130560/nodejs-udp-multicast-how-to?utm_medium=twitter&utm_source=twitterfeed
!Server
var news = [
"Borussia Dortmund wins German championship",
"Tornado warning for the Bay Area",
"More rain for the weekend",
"Android tablets take over the world",
"iPad2 sold out",
Verifying my Blockstack ID is secured with the address 1FKAVZYEV9TbLRm77y4t4Kv5KjAirKeK46 https://explorer.blockstack.org/address/1FKAVZYEV9TbLRm77y4t4Kv5KjAirKeK46
@ciaranj
ciaranj / .bashrc
Created February 14, 2013 11:21
A .bashrc suitable for use with msysgit to utilise ssh-agent to avoid repeated passphrase addition, taken verbatim from: http://mah.everybody.org/docs/ssh
#! /bin/bash
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add;
@ciaranj
ciaranj / gist:2991314
Created June 25, 2012 21:16
OpenSSH Release.sh
#!/bin/sh
cd "$(dirname "$0")" && . ../common/update-lib.sh
#check_pristine
package=openssh
version=6.0p1
url=http://mirror.bytemark.co.uk/OpenBSD/OpenSSH/portable/
@ciaranj
ciaranj / gist:1308792
Created October 24, 2011 11:14 — forked from juamei/gist:1308791
atmosphere_resource_reusage
Suspicious log entries:
2011-10-24 10:42:39.203 -> Entered ChatPollerHandler with queryString : ajax_timeout=-1&pollSeqId=10&poll=true&sessionId=86ee4d9b-a696-4d92-b1ce-d73dcb27616c&chatWindowId=35ac44a9-fb2f-434b-bae8-4fda524cb491&handle=null&participantId=ca1e9956-b419-411f-b306-10d2d20e3ff6&seq=1, EVT_RSC: 26961876
2011-10-24 10:42:39.203 -> Entered ChatPollerHandler with queryString : ajax_timeout=-1&pollSeqId=10&poll=true&sessionId=e87ede08-b7c2-4b47-8332-7050f1e3944a&chatWindowId=d3e35f7b-11ca-463a-836b-aa7e918aac59&handle=null&participantId=7b8bd5ba-bc8a-4a3a-b310-8cd97f94d933&seq=1, EVT_RSC: 26961876
Relevant code:
public void onRequest(AtmosphereResource<HttpServletRequest, HttpServletResponse> resource) throws IOException {
@ciaranj
ciaranj / gist:1234827
Created September 22, 2011 13:55
Seemingly working HTTP(s) userstream connection.
var sys= require('sys');
var OAuth= require('oauth').OAuth;
oa= new OAuth("https://twitter.com/oauth/request_token",
"https://twitter.com/oauth/access_token",
yourConsumerKey, yourConsumerSecret,
"1.0A", "http://localhost:3000/oauth/callback", "HMAC-SHA1");
var request= oa.get("https://userstream.twitter.com/2/user.json", yourAccessToken, yourTokenSecret );
request.addListener('response', function (response) {
response.setEncoding('utf8');
@ciaranj
ciaranj / gist:1193637
Created September 4, 2011 22:35
Example connect-auth using scopes to allow con-current strategy authentications.
var express= require('express')
, auth= require('./.node_modules/connect-auth')
, url= require('url');
var app = express.createServer()
, yourTwitterConsumerKey= "xxx"
, yourTwitterConsumerSecret= "yyyy"
, fbId= "asdsd"
, fbSecret= "asdsdsds"
, fbCallbackAddress= "http://somehost.com/auth/facebook_callback";
function rehash (values) {
var hash = {}
, len
, i=0;
if (!Array.isArray(values)) return hash;
len= values.length
if( len % 2 == 1) return []; //mis-matched array ?
while( i < len) { // for(i =0 ;i < len; ) {
hash[values[i++]]= values[i++];