Category Archives: Sandbox

Continuing to read about functional programming

Functional programming techniques are becoming more mainstream (and more generally useful) and I’ve been doing some reading to come up to speed.

I’ve just ordered a book on Haskell. Haskell seems to be the functional programming equivalent to SmallTalk for object oriented design…a pure functional language.

 

I’ve also ordered a book on functional programming in C#. While C# isn’t a purely functional language, I am far more likely to build things in C#. I’m expecting the combination of these two books to give me a decent combination of theory and useful practice.

Javascript is really where I first began running into functional approaches. I’m still working on getting my javascript up to where I’d like it to be. The javascript world is currently pretty hard to keep up with as things continue changing at a frantic rate. I’m expecting to spend a weekend soon adding a self hosted web UI to one of my ongoing sandbox projects…probably something Angular 2 with a C# back end, but we’ll see…

Continue reading Continuing to read about functional programming

Hmm…and Kestrel in .NET Core

Ok..and Kestrel seems to be the .NET Core alternative to the OWIN stuff under .NET classic.

Yet another option…in my case the OWIN side is likely more interesting as I’m almost certainly going to be doing things that need interop or similar windows-centric functionality. Interesting as a Linux facing option though. May also be lower overhead in cases where a particular micro-service doesn’t need access to native capabilities.

I am also expecting to need some sort of SSL certificate to enable TLS on these links (don’t need the full commercial cert probably as these are likely going to be expose by IP address and not on the open web). I need to understand what is needed to deploy TLS, ideally with cert verification on both ends using certs I’ve created myself and that don’t correspond to a particular URL.

In this case I’m looking to ensure no MITM attacks and to encrypt the traffic but not to ensure much more than that. I don’t want further authentication to leak and I want to protect the connection (for example for a web UI on a small ‘appliance’ that may at times be exposed to an open internet connection).

Mostly saving these to read/watch in more detail later. Options on top of options here…

C#: Self Hosting Web UI or WPF?

I continue to bounce back and forth between self-hosted web UI and WPF UI for implementing simple user interactions.

WPF is likely to be easier to build the right sort of thing with but is a bit less flexible and more ‘backward looking’. Web interfaces require a self-hosting solution if they’re going to be stand-alone and cross more lines of language and environment.

On balance the web UI path is better as a learning experience and aside from a few corner-cases (OpenGL say) likely to  result in a better user experience in the long run.

I’m still looking for the right self-hosting solution and UI framework solution. I’m going to have to settle on one shortly so that I can being experimenting in the ninecrows sandbox and getting a feel for the technology.

Current links of interest on the self-hosting front:

There also seem to be some hard choices between versions of the framework…classic and core in particular.

More to learn as things move forward. I expect I’ll wind up doing things with both/all before I’m done as they have different strengths. The sorts of things a WPF/WinForms/MFC UI can do in terms of digging into the system and being screen real-estate aware along make them of great interest.

Did a Little More Research on Interop During Lunch

I did a bit more research on interop topics during lunch today. I’m going to try to write up some samples using interop to work with the file information and volume information APIs that aren’t available in C# tonight.

If all goes well, I should have something to push up to github as a set of code samples. I don’t expect this to be a finished product, but should be interesting in any case.

I also want to fix the Wix issues with my service sample and get that pushed with a working installer. Probably won’t get the guts finished but should be able to install and uninstall the thing without dev tools.

Windows services with single page web apps

I’m getting things going on some sandbox software projects that have been sitting on the shelf for some time. Perhaps a bit spread out but should be interesting.

I want to be able to put together free-standing service applications that expose both RESTful programmatic control and single page interactive GUIs without involving an external web server.

Looking like C# and either OWIN or .NET core as the sweet spot here. Need to choose a javascript library for the client side bits…Angular2 seems interesting but may be more involved for first attempts than I want.

I’ve also signed up for several of the sale Udemy courses…started out with an impulse buy of the Unreal Engine Programming course and an associated Blender course. Added in some Angular, Node and web programming stuff. Probably more in there than I’ll have time to get to,  but at $10 each I can deal.

Definitely need to come up to speed more on the various web programming environments and tools as they’re looking like the right way to do UI at this point. Leaves me with ASP.NET, Node and Apache with PHP, Javascript, C# and Typescript on the plate 🙂 Each of these shows up somewhere in my environments of interest. Should be fun…

Web Implementation Options for SandBox Projects

Looking at some sandbox projects that need web interfaces.

Winding up with a big split here

  • PHP/Apache (LAMP) for real site work.
    Anything that needs to run up here on my hosting will be something LAMP-like. Code needs to be PHP (at least locally) with back end persistence in MySQL.
    Front end should be more flexible. As long as the back ends can provide what the browser side code needs all should be good.
  • IIS/ASP.NET looks like the easiest choice (with .net core MVC as the tool set) for windows integrated work. I have a few things that want to run locally on a system but present a web interface externally. These tools should provide lots of ‘traction’ with close windows integration. Probably an Angular front end and perhaps a full service on the back-end.
  • Node.js shows up in many places. It provides a fast to deploy web server that is flexible and easy to code for. It is on my list in part because it has been showing up in places that are interesting and it part because it promises to support light-weight tasks where IIS would seem like over-kill.

For the front ends there are a huge number of choices out there. Of the ones I’ve seen

  • Angular 2 seems to be pretty capable and well respected. I expect to do at least some work with Angular and if it proves easy to work with I may focus on it.
  • Bootstrap is older (I think) but appears to provide a similar set of tools and infrastructure. If I run into issues with Angular, I may give this a try for something small and see how well it works.

I am also looking at free-standing, light weight web server options that run in C#. This is primarily aimed at RESTful interfaces to back-end code. OWIN and Katana seem to promise something like this while on the C++ side (and I expect C++ will show up now and then) microhttpd looks promising (with GPL restrictions, but these are sandbox projects).

Currently doing quite a bit of reading. Soon I’ve got to kick off from reading and get to some doing. Not sure what I’ll tackle first but I will probably try to list the things I’d like to kick around before I pick one…stay tuned.

 

A Little bit of python…

Someone at work asked about shuffling cards in software (or similar type problems) so I write a small bit of python for them. Python isn’t a language that I’ve had much need for in the past but it was the language they are familiar with:

#! /usr/bin/env python3
import random

# Cards in each suit
cards = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King']

# Suits of cards
suits = ['Clubs', 'Hearts', 'Diamonds', 'Spades']

# Start with an empty deck and fill it with on card of each type in each suit
deck = []
for card in cards:
 for suit in suits:
 deck.append(card + " of " + suit)

# Make sure we got the right number of cards in the deck
decksize = len(deck)
print (str(decksize) + " cards in a deck")

# Shuffle the cards by walking through each location and swapping it with a
# randomly chosen location in the deck.
for item in range(0, decksize):
 dest = random.randint(0, decksize - 1)
 # Swap by saving the contents of the destination spot, copying the source
 # spot there and then placing our saved card in the source location.
 temp = deck[dest]
 deck[dest] = deck[item]
 deck[item] = temp
 
print(deck);

Classic bit of swap based shuffle.

I was a bit surprised to see that python has split into two largely incompatible languages with the transition from 2.x to 3.x being drawn out and there seems to be some question whether there will ever be a full transition.

It does appear that with a bit of care it is possible to have both versions on one system with distinct names. Makes things workable if not exactly pleasant.

JSON options in C#…too many options

I’m getting back to sandbox projects on the home front (plenty that got shelved when things got busy) and have been looking at JSON handling in C#.

So far a quick scan of what is out there leaves me with the impression that there are many choices and no clearly dominant one.

So far the open source http://www.newtonsoft.com/json seems to be the best choice. I think I’m going that way for the time being and will look into other options down the road.

Thinking that MongoDB may be a good back end for the data storage I need for the current work at hand. JSON-centric as well so likely a good overall match.

 

Dead Computer, Live Computer

Looks like the spare core-2 machine is likely down for the count. Even with the motherboard completely out of the chassis with nothing but the power supply and the power switch plugged in it seems to immediately shut down the power supply. I may give it one more shot on the possibility that it just doesn’t start properly without at least memory and video but I’m not hopeful.

I’ve started an install of Ubuntu 16.10 on ‘madhatter’ my back basement lab bench machine. This should do nicely for now. I’ll probably wind up buying some low-ish end hardware to replace the dead machine when the back lab bench area gets set up with a 3D printer. Until then this provides a decent Intel based linux machine that should meet my needs.

Once the base install is complete I need to get

  • xrdp installed for easy remote UI access
  • SSH installed (if not there out of the box) and configured for secure command line stuff.
  • tightvnc installed mostly to see if it works better than the free version of realvnc that came pre-installed on the RPi
  • samba to make files available to my windows boxes and hopefully set up for cleaner network visibility.

Hoping that this one goes smoothly. Disappointing the number of machines that have gone flaky recently.


Ubuntu install appeared to succeed. The machine was waiting at a ‘press enter to restart’ prompt when I checked on it this morning.

It is running on a WD ‘green’ drive so may be a bit slow booting. When I left it was still showing just a black screen (after dropping through a ‘how should I boot’ screen) so I’ll see tonight whether this system loaded up successfully. The machine seems ok overall as the windows 10 boot disk works fine.

I did start downloads of the Ubuntu 16 and 14 LTS releases to try tonight if the 16.10 image fails. Hoping there isn’t some incompatibility with core-2 era computers in newer Linux builds.

Time to Define Tables

I’ve worked with databases on and off for a long time but in general I’ve been accessing previously defined data tables or had very simple needs (DynamoDB kind of forces that).

I’m at the point in my sandbox work that I’m about to define a substantially more complex schema than I’ve used for anything in the past. Finding that my command of SQL DDL and the various bits involved in creating MySQL users and setting permissions is taking some doing.

I still can’t seem to get a database on a remote system (boojum, myimg_20161229_133853 little test machine). I am not getting a ‘no connection’ response but an authorization failure so I expect that the identit(ies) I created on the NUC aren’t quite right Always details to be dealt with…

I am finding that tables proliferate. Everything needs a unique ID (and auto increment columns help enormously here). Any sort of one to many relationship (keywords, validation) winds up with a new table containing the source object key and the targets. In the past I’ve used the DB as an index for more complex storage (DICOM-3 pretty much forces this with its many 1..n fields, DynamoDB encourages this as well with bulk information in S3).

In the current case I really want to keep everything in the DB rather than spilling items overboard. If I get to thumbnails I’ll see how the BLOB types work. For now I expect that I’ll be ok with the 64K per row limit on MySQL InnoDB tables. I expect that BLOB and TEXT aren’t stored in their respective tables so they should permit ‘stretch’ operations.

Current working notes are a bit chaotic 🙂

DB Initial Sketch
Chaos in the Schema

I am sticking with the MariaDB fork of MySQL to avoid Oracle entanglements. Once the basic database definitions are in place I expect to code the front end in C# as I need to polish up that language and environment a bit at the moment. Not sure whether I’ll go with WPF or some sort of web interface for the UI yet. Got to get the innards a bit better defined first.

Looks like I was just messing up my command line for remote mysql access. Once I got things straightened out, I can talk to the database instance on boojum from chaos. Should make things a bit cleaner as I can keep the data in one spot and access it from any system in the house. Now I just have to finish with the create table statements and see if they build what I need. Short digression into users and permissions first (and probably a quick look at alter table) to see what I should be doing for remote access.