Skip to content

Instantly share code, notes, and snippets.

View jhalbrecht's full-sized avatar
💭
Grinning; It works! XamarinForms Mqtt secure mosquitto broker connection.

Jeff Albrecht jhalbrecht

💭
Grinning; It works! XamarinForms Mqtt secure mosquitto broker connection.
View GitHub Profile
@jhalbrecht
jhalbrecht / Readme.md
Last active July 9, 2019 19:08 — forked from sarmis/foldergallery.html
Justified Image Gallery as Hugo shortcode

Forked and making some changes to better support how I'm using page resources in a Hugo Page bundle.

Usage { {< foldergallery src="imgs" >} } I changed this to;

{ {< foldergallery src="." >} } Which picks up all the files in my leaf page bundle including index.md

I want to change the "imgs" in the shortcode to something like;

{{ with .Resources.ByType "image" }}

@jhalbrecht
jhalbrecht / PirParts.yaml
Created June 12, 2019 16:01
Home assistant sonoff tasmota rf bridge pir configuratiion
# binary_sensors.yaml
- platform: template
sensors:
test_pir_00:
value_template: '{{ is_state("sensor.sonoff_rf_bridge", "EA0FDE") }}'
# delay_off: '00:05:30'
delay_off: '00:00:30'
device_class: motion
friendly_name: "PIR One"
@jhalbrecht
jhalbrecht / HomeAssistantRfButtonStuff.yaml
Created December 10, 2018 15:36
Home Assistant sensor and automation .yaml to toggle a SonOff light with a 433mhz RF Bridge w/tasmota for the buttons...
Given this topic make sensor/button unique in this working example any button on that topic will fire the automation.
tele/homeamation/sonoff02/STATE {"Time":"2018-12-10T16:30:27","Uptime":"30T22:46:46","Vcc":3.121,"POWER":"OFF","Wifi":{"AP":1,"SSId":"ADP","BSSId":"F8:32:E4:AE:00:F8","Channel":3,"RSSI":100}}
# commented lines are failed attempts
in sensors....
#
# button
#
# 12/9/2018
@jhalbrecht
jhalbrecht / mqttclient.cs
Last active November 4, 2017 00:13 — forked from mauroa/mqttclient
System.Net.Mqtt client sample
//Note that you can set more properties and also not set the port,
//in which case the MQTT default will be used
var configuration = new MqttConfiguration { Port = 55555 };
//Creation of the MQTT client
var client = await MqttClient.CreateAsync("192.168.1.29", configuration);
//MQTT connection of the client. You can pass optional args to the
//ConnectAsync method and credentials
await client.ConnectAsync(new MqttClientCredentials("testClient"));
Here is example of configuring the SPI0 pins.
First, verify cape unverisal is loaded:
[quote]
root@beaglebone:~# cat /sys/devices/platform/bone_capemgr/slots
0: PF---- -1
1: PF---- -1
2: PF---- -1
3: PF---- -1
4: P-O-L- 0 Override Board Name,00A0,Override Manuf,cape-universaln
@jhalbrecht
jhalbrecht / LinqPadBogusDemo.cs
Created February 8, 2017 22:32
Worked up a nice seed of fake data in LinqPad before implementing in my Visual Studio solution.
void Main()
{
var playlists = PlayListFaker.Generator.Generate(5).ToList();
playlists.Dump();
}
public class PlayListFaker : PlayList
{
static Random random = new Random();
public static Faker<PlayList> Generator
@jhalbrecht
jhalbrecht / J5TennisBall.js
Last active December 28, 2015 20:29 — forked from rwaldron/J5TennisBall.js
This is @rwaldron suggestion (unTested) for me to learn a bit better coding style. Removing some of Rick's "Nit's" See lines 18, 21 for my additions, and 37 for pesky error (fixed).
var j5 = require("johnny-five"),
board = new j5.Board();
board.on("ready", function () {
var ping, button, lights, ginches, lowerLimit, offset;
ping = new j5.Ping({
pin: 8,
freq: 250
});
@jhalbrecht
jhalbrecht / check_temperature_wo
Created August 17, 2013 20:30
Plugin for Nagios I wrote to monitor temperature data from sensors serving XML in homeAmation format. See: http://homeamation/azurewebsites.net
#!/bin/env python
'''
Created on Jan 21, 2012
@author: jeffa aka @jhalbrecht
'''
# jha 8/17/2013
# Prepare code for publishing.
@jhalbrecht
jhalbrecht / HeadsOrTailsToColorConverter.cs
Last active December 17, 2015 18:29
This ValueConverter expects a string of either "Heads" or "Tails" and returns Green or Red respectively or yellow as a default or unknown value. I use it in a Windows Store Application, "Decisive" to color the text result of a coin toss. I've been using a long weekend as a sprint to focus on learning VS2012 and blend design tools. Blend made it …
using System;
using Windows.UI;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Media;
namespace Decisive.Common
{
public sealed class HeadsOrTailsToColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
@jhalbrecht
jhalbrecht / SwitchUdpMessageService.cs
Created December 10, 2012 00:07
Switch statement from UdpMessageService.cs
async void OnSocketMessageReceived(DatagramSocket sender, DatagramSocketMessageReceivedEventArgs args)
{
if (_connection.Writer == null)
ConnectToRemoteSocket(args.RemoteAddress, args.RemotePort);
var reader = args.GetDataReader();
var messageType = (WireMessageType)reader.ReadInt32();
switch (messageType)
{
case WireMessageType.PlayerLeave:
if (PlayerExited != null)