Skip to content

Instantly share code, notes, and snippets.

View jogleasonjr's full-sized avatar

John Gleason jogleasonjr

View GitHub Profile
@jogleasonjr
jogleasonjr / Softmax.cs
Created October 31, 2017 17:49
C# Softmax
// Simplest C# Softmax example
// Based on the Python example here: https://en.wikipedia.org/wiki/Softmax_function
void Main()
{
var z = new[] { 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0 };
var z_exp = z.Select(Math.Exp);
// [2.72, 7.39, 20.09, 54.6, 2.72, 7.39, 20.09]
var sum_z_exp = z_exp.Sum();
// Slightly modified Adalight protocol implementation that uses FastLED
// library (http://fastled.io) for driving WS2811/WS2812 led stripe
// Was tested only with Prismatik software from Lightpack project
#include "FastLED.h"
#define NUM_LEDS 114 // Max LED count
#define LED_PIN 6 // arduino output pin
#define GROUND_PIN 10
#define BRIGHTNESS 255 // maximum brightness
@jogleasonjr
jogleasonjr / NumpadMarkdownHelpers.ahk
Created December 17, 2015 20:44
Autohotkey script to map the numpad operator keys to markdown hints
; Surround current word in BOLD e.g. this is **bold**
NumpadMult::Send ^{Left}**^{Right}**
; Surround current word in ITALIC e.g. this is *italic*
NumpadDiv::Send ^{Left}*^{Right}*
; Surround current word in CODE e.g. this is some `code`
NumpadSub::Send ^{Left}{SC029}^{Right}{SC029}
@jogleasonjr
jogleasonjr / tilde_hjkl_arrows.ahk
Created December 17, 2015 20:24
Holding the `tilde` key maps the HJKL keys to arrow keys ←↓↑→
` & h::Send {Left}
` & j::Send {Down}
` & k::Send {Up}
` & l::Send {Right}
@jogleasonjr
jogleasonjr / fsharp_dump.linq
Last active November 19, 2015 21:22
LinqPad's .Dump(string) as an F# function
<Query Kind="FSharpProgram" />
let dump (title : string) x = x.Dump(title)
let add x y = x + y
dump "add results" (add 6 4)
[1, 2, 3, 4]
|> dump "array contents"
@jogleasonjr
jogleasonjr / SlackClient.cs
Last active October 20, 2023 15:54
A simple C# class to post messages to a Slack channel. You must have the Incoming WebHooks Integration enabled. This class uses the Newtonsoft Json.NET serializer available via NuGet. Scroll down for an example test method and a LinqPad snippet. Enjoy!
using Newtonsoft.Json;
using System;
using System.Collections.Specialized;
using System.Net;
using System.Text;
//A simple C# class to post messages to a Slack channel
//Note: This class uses the Newtonsoft Json.NET serializer available via NuGet
public class SlackClient
{