Skip to content

Instantly share code, notes, and snippets.

@SamVanhoutte
SamVanhoutte / cliff-states.py
Created April 26, 2022 12:41
Reinforcement learning cliff-v0 states
# function that takes the action and outputs state + reward
def make_step(step, episode_reward, cliff):
new_state, reward, done, _ = cliff.step(step)
print(f'New state {new_state} with extra award {reward} to total {episode_reward}')
cliff.render()
return episode_reward + reward
# walk the entire grid
env = gym.make('cliff-v0')
state = env.reset()
@SamVanhoutte
SamVanhoutte / DataLakeTransmitter.cs
Created December 18, 2020 07:27
Data lake file transmitter
using System;
using System.Text;
using System.Threading.Tasks;
using Azure.Storage.Files.DataLake;
using System.IO;
using System.Net;
using Azure;
using Azure.Storage;
using Azure.Storage.Files.DataLake.Models;
using Azure.Storage.Sas;
@SamVanhoutte
SamVanhoutte / TableTransmitter.cs
Last active January 2, 2020 18:37
Generic table transmitter class
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Table;
using TableStorage.Abstractions.TableEntityConverters;
using Traiders.Storage.Configuration;
REFERENCE ASSEMBLY ImageCommon;
REFERENCE ASSEMBLY FaceSdk;
REFERENCE ASSEMBLY ImageEmotion;
REFERENCE ASSEMBLY ImageTagging;
REFERENCE ASSEMBLY ImageOcr;
@imgs =
EXTRACT FileName string, ImgData byte[]
FROM @"/data/employees/{FileName:*}.jpg"
USING new Cognition.Vision.ImageExtractor();
@SamVanhoutte
SamVanhoutte / PiGlowController.cs
Last active December 15, 2015 12:36
This class can be used to control the PiGlow LED on a Windows 10 IoT Core device. This has been tested on the Raspberry PI II against the build 10586. The controller is very easy to use and to instrument from a Universal Windows App.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Devices.Enumeration;
using Windows.Devices.I2c;
namespace Codit.IoT.PIGlow
@SamVanhoutte
SamVanhoutte / RandomExtensions.cs
Created January 22, 2015 10:36
Random string generator, based on format
void Main()
{
Random rnd = new Random();
rnd.GetString("1-###-000").Dump();
}
public static class RandomExtensions
{
public static string GetString(this Random random, string format)
{
@SamVanhoutte
SamVanhoutte / EventHubCode.cs
Last active August 29, 2015 14:13
Azure Stream Analytics - blog post sample
async void Main()
{
var mf = MessagingFactory.CreateFromConnectionString("your cnx string here");
var eventHubClient = mf.CreateEventHubClient("ehname");
Random rnd = new Random();
Parallel.For(1, 11, async (deviceId) =>
{
for(int cnt = 0; cnt < 50; cnt++)
{
Console.WriteLine ("Sending event nr {0} for device {1}", cnt, deviceId);
@SamVanhoutte
SamVanhoutte / EventHub.cs
Created January 20, 2015 17:52
EventHub json serialization
async void Main()
{
var mf = MessagingFactory.CreateFromConnectionString("***");
var eventHubClient = mf.CreateEventHubClient("test");
Random rnd = new Random();
Parallel.For(1, 11, deviceId =>
{
for(int cnt = 0; cnt < 100; cnt++)
{
Console.WriteLine ("Sending event nr {1} for device {0}", cnt, deviceId);
#! /bin/bash
### BEGIN INIT INFO
# Provides: azureobd
# Required-Start: $remote_fs $syslog $network $all
# Required-Stop: $remote_fs $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start AzureOBD at boot time
# Description: Start AzureOBD at boot time.
### END INIT INFO
@SamVanhoutte
SamVanhoutte / enableping.cmd
Created April 9, 2014 06:54
Enable ping on windows machines (good for azure VPN, etc)
netsh firewall set icmpsetting 8 enable