Nancy framework TinyIoc magic

July 2nd, 2015

Been using the Nancy framework with mono, replacing some ASP.NET garbage left over from the dawn of time. I really like it and it works great, but the TinyIoc framework has been driving me totally nuts. What it does it does magically, but that whole “magic injection” thing is a nightmare the second you need to change one of the default behaviors and… nothing happens. Code compiles, runs without errors, but there’s no change.

Magic. Magic never changes.

I’m particularly impressed at how complex, powerful, and completely baffling and undocumented the request lifecycle is. There are a half-dozen functions that register different things, but all I want to do is use the same object to handle every request. The one thing I can’t figure out how to do is use the same object for every request. I’ve found several examples describing how this should work, but none of them worked for me. And, strangely, it seems to be creating the same object four times per request. This can’t be efficient.

I think the problem is that the people designing it are still thinking in terms of ASP.NET. That piece of junk will hold us back forever if we don’t shake free of its influence.

There’s another warning sign all through the forums. Any time someboyd has a question about how do solve a specific problem, he is immediately told that he needs to rethink his architecture. As a person porting an existing code base, who is trying to work around its current structure and limitations, this makes me question my decision to use Nancy. Responses like this are a sign that you’re dealing with people who do not actually have jobs.

And another thing…

Also, the “easy response syntax” that lets you return, say the number 404 to indicate that you want to send back a 404 result is nice, but this means there’s no “easy” way to return 404 with a custom error message. For example, if you want to return status 400 “Invalid request: the ‘count’ parameter is required’, you can either return the text with a 200, or 400 with no text, but not both. If you want to return both, you can easily return a Response object, which, er, is documented in the source code. There are a lot of very cool Response objects and it’s easy–if you wrote the framework or have the source code on disk.

I think I’m falling in love with Nancy, but I always have to guess what will make her happy. Somehow very familiar.

Ameinias server ala Docker

June 27th, 2015

Ameinias 3.0.4 is now available for docker hosts, with docker images for ices2 and icecast2, making it a complete web-based audio playback “solution”. Whee. It’s now running on my dedicated jukebox machine at the house and that’s awesome.

All you need is a docker host, three run scripts, and a huge load of audio files to play.

My install is pretty simple. mp3 files are on a network share as /var/mp3, and I store the config files in /var/ameinias:

mkdir /var/ameinias
docker run -d --restart=always \
    --name ameinias \
    -p 80:7076 \
    -v /var/ameinias:/adata \
    -v /var/mp3:/mp3 \
    tekhedd/ameinias:3.0.4

# There is no tagged version for the icecast/ices builds
# because the builds retrieve the 'latest' version of the tools
docker run -d --restart=always \
    --name ameinias-icecast2 \
    --volumes-from ameinias \
    -p 8000:8000 \
    tekhedd/ameinias-icecast2:latest

docker run -d --restart=always \
    --name ameinias-ices2 \
    --link ameinias-icecast2:icecastserver \
    --volumes-from ameinias \
    tekhedd/ameinias-ices2

You change the passwords in /var/ameinias/ices2.xml and icecast.xml, and you’re good to go. Well, the permissions might be wrong and you might have to look at the stdout to see what’s up,.. but if you’re looking for a docker-based player you know what to do.

Autoplaying videos on Twitter…

June 25th, 2015

Well, it’s official, Twitter is now lame. Where to next? I mean, is there anything cool that hasn’t been bought by Facebook yet?