Introducing Unique.exe

Download: Unique.exe 1.0

Unique.exe is a small .Net utility that I wrote to dump only the unique lines of a text file. I found this useful when combining a few lists of user names and needed to retrieve only the unique ones. It additionally sorts the lines (forward and reverse) and outputs to stdout or a file.

I haven’t done any performance tuning (it’s 143 lines long) but I would expect it to work reasonably quickly with all but very large files. (Source and release exe included.)

Newtonsoft.Json And Web Deploy Package

I recently encountered an ASP.Net deployment error with a Web Deploy package that had me banging my head against the wall and none of the online solutions worked. I learned a few valuable tidbits that any new .net web developer should find useful.

Continue reading

Dynamically Updated JavaScript Image Randomizer

My solution for a dynamically updating image randomizer in JavaScript

My latest focus is mastering web development, specifically ASP.Net MVC with Bootstrap and jQuery. There’s a huge amount of information to learn but none of it is particularly difficult. About the most foreign part for me has been dealing with JavaScript scope and context.

Example. I have a single page application (SPA) that is going to host an image. Every time the page updates I want to display a different image from a list at random. It’s easy to find examples on how to do this. However, the examples only work on a full page load or only for one location. Since this is a SPA there’s rarely a page load (I’m extensively using AJAX against my Web API) and I plan on more than one image list.

Here’s my solution. This was initially based on the “Chicken Dinner” plugin from http://chickendinner.sosweetcreative.com/
Continue reading

Vibratium 1.3

The Vibratium 1.3 update is now available.

Rotate2_Red

This is includes numerous changes, the most noticeable of which is the object list/editor on the left and the introduction of the RotatePoint.

1. The object list now uses one editor control for all objects. You can manually click the objects in the list or use Page Up, Page Down, Home, and End to navigate.
2. I’ve added the new Rotate Point type. This uses two points. The first point is the center of the area where the rotation will be displayed and the second point defines the center point of the source of the rotated image. By default these are the same unless you select the (X2,Y2) button to separate them. (The radius is currently fixed at 128 pixels.)
3. The source point will be displayed as a reticle without the circle around it.
4. Use the dropdown box to choose which type you want to add to the list.
5. The majority of the changes are refactoring/rearchitecting the render engine code and making it more extensible for future object types as this moves away from being a research project.

I spent a fair amount of work this release in moving to an MVC pattern with the UI in the hopes of making this a Win10 app to put in the store soon. Due to the buffer caching for performance reasons it’s still a memory hog.

I have a lot of ideas for new object types and effects but let me know if there are any in particular you’d like to see.

More info and download instructions here –
https://www.georgepotts.com/apps/vibratium/

Application Error 1005 Loading SSE DLL

While I was testing my latest release (1.2) of Vibratium I encountered a puzzling error. It took me a while to track this one down. Hopefully someone else can learn from this.

TL;DR: solution is at the end.

Problem:

Vibratium worked fine on my dev box, but on my laptop as soon as I added a Render Object the application would crash.

In the Application event log I got Application Error 1005:

“Windows cannot access the file for one of the following reasons: there is a problem with the network connection, the disk that the file is stored on, or the storage drivers installed on this computer; or the disk is missing. Windows closed the program Vibratium because of this error.”

Continue reading

Vibratium 1.2 Update

The Vibratium 1.2 update is now available.

This is primarily a performance update with a few changes visible to users.

1. The crosshairs button is labeled and indicates if it is active.
2. The app will now attempt to choose a ‘best’ drawing size to accommodate your screen size.
3. The project format is now XML. Unfortunately old projects will be unusable with newer versions of the app. If you want to keep them then open them in your current version and copy down the settings by hand. This should be a one-time breaking change, so it’s better to do it now with fewer users.
4. There is now only one file to copy – Vibratium.exe – and it’s smaller than previous versions. You can safely delete the old binary files (*.exe, *.dll).
5. You can control the individual gamma channels.
6. Frame rate, render time, and screen drawing times are now displayed in the status bar.
7. Memory usage is much more stable and smaller now.
8. SSE 4.1 support is detected upon startup. If the processor doesn’t support it a message will be displayed and the app will exit gracefully

More info and download instructions here –
https://www.georgepotts.com/apps/vibratium/

Vibratium 1.1 Update

Vibratium 1.1 update is now available.

This is a minor update that adds crosshairs to locate the centers of the render objects and eliminates a couple of extra files.  More info and download instructions here –

https://www.georgepotts.com/apps/vibratium/

Handling IDisposable Objects in a Generic List

I wanted to have more precise control over the lifetime of objects I was keeping in a list rather than wait for the GC. I came up with the code below which adds a few extension methods for handling IDisposable objects in a generic list. This was more elegant than adding a helper class.

I only implemented what I needed for the current project but these are very straightforward to do.

Sample code below.

using System;
using System.Collections.Generic;

namespace MyExtensions
{
    public static class Extensions
    {
        /// Remove tail, starting at index.
        public static void RemoveTail<T>(this List<T> list, int index)
        {
            if (index >= list.Count) { return; }

            if (typeof(IDisposable).IsAssignableFrom(typeof(T)))
            {
                List<T> temp = list.GetRange(index, list.Count - index);
                ClearAndDispose(temp);
            }
            list.RemoveRange(index, list.Count - index);
        }
        public static void ClearAndDispose<T>(this List<T> list)
        {
            if (typeof(IDisposable).IsAssignableFrom(typeof(T)))
            {
                foreach (T obj in list)
                {
                    IDisposable iFace = (IDisposable)obj;
                    iFace.Dispose();
                }
            }
            list.Clear();
        }
    } //*** Extensions
} //*** namespace

Usage is simple.

using MyExtensions;
...

var myList = new List<HugeObject>();
...

myList.RemoveTail(idx);
...

myList.ClearAndDispose();

Escher Version 0.2

Escher Version 0.2 is up.

This version fixes the flicker issue, adds undo, fill/no-fill enclosed shapes, and drawing crosshairs.

Escher is a free, fun multi-shape drawing program for doodling, like a cross between MSPaint and a kaleidoscope.

More details here:  https://www.georgepotts.com/apps/escher/

Example:
FlyingTriangles

SSELibrary 0.2 Available

SSELibrary 0.2 available for download. This version includes a much larger library of functions (149) with nearly full coverage of 8-bit operations, as well as enhanced CPU feature detection.

Details here: https://www.georgepotts.com/apps/sse-library/