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 / til311.js
Created February 9, 2015 20:07
til311 demo in bonescript
/*
Jeff Albrecht February 9, 2015
An experiment to display digits on a Texas Instruments TIL311. And practice my .js
http://www.ti.com/lit/ds/symlink/til311.pdf
Not implemented in this til311 experiment
left and right decimal points
configurable blank leading zeros
@jhalbrecht
jhalbrecht / jFirstInt32.TryParse
Created August 30, 2011 03:53
My first attempt with Int32.TryParse
private string _Angle;
public string Angle {
get {
return this._Angle;
}
set {
if (value != this._Angle) {
@jhalbrecht
jhalbrecht / ConverterRatingMultiplier.cs
Created June 8, 2012 05:57
A value converter I used for a Callisto rating
using System;
using Windows.UI.Xaml.Data;
/*
xmlns:callisto="using:Callisto.Controls"
xmlns:lm="using:yaLolFx.Models"
<Page.Resources>
<lm:ConverterRatingMultiplier x:Key="RatingMultiplier" />
</Page.Resources>
@jhalbrecht
jhalbrecht / gist:2913733
Created June 12, 2012 00:56
The Lol Fx membership
theLolFx consists of
asp.net MVC 4 web site
Windows phone 7 application
Windows 8 metro application
theLolFx allows for downloading and playing sound effect files. The popularity of the sounds can
be rated on the website. (possibly in a future clients version)
I wish to enable creation of sounds on the client applications and upload to the mvc site.
@jhalbrecht
jhalbrecht / BasicAuthWp7.cs
Created June 15, 2012 03:39
I used this code over https to do basic authentication from wp7 to mvc 4 beta with web api
// I used this article to get the headers right.
// http://cisforcoder.wordpress.com/2010/12/01/how-to-implement-basic-http-authentication-in-wcf-on-windows-phone-7/
// The commented out NetworkCredential that I had tried earlier didn't work.
// I wonder if there is a better way to do this in Mango?
//
// Would like to learn to use asp.net membership with web api from the phone and metro.
// this works for now.
private void btnTest_Click(object sender, System.Windows.RoutedEventArgs e)
{
@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)
@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 / 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 / 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 / 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