Blog
Random information I've compiled over the years...

Posted by ignusfast on 9/21/2016 2:13:31 PM ;   Last Updated by ignusfast on 9/21/2016 2:13:31 PM

Ahhh, that was... a little painful.

Spent much of last night porting my site to Azure. The code changes were minor, even including the database switch from MariaDB to SQL Server. The painful part was actually hand-porting the Heidi export script from Maria to TSQL so I could import it into the SQL Server. Ugh. The differences in syntax were fairly minor. The hardest part was accounting for string value changes, especially with regard to line endings. Got it all sorted, though, and this is running in the Azure cloud. Not sure I could afford to do this on my own without my work MSDN subscription, though - it's not SUPER expensive, but for what is basically a hobby site, it's way too much. I might drop it to the free/cheap tiers just to see how it performs, but at that point, I might as well just run it on my own server... :)

Posted by ignusfast on 9/20/2016 11:03:39 AM

Adding additional functionality and playing with authentication

I added the ability to more easily add Blog articles. I also fixed a bug in the authentication code that was prohibiting Administrator-level users from using the site properly. Authentication is a tricky wicket. You don't want to hit the database for every single request, but you also don't want to leave your site open to an abusive user. Currently I'm using a hybrid approach, where the site uses a secure cookie to allow access for up to a day without hitting back against the database. But that time period is easy to tweak, so I'll probably drop it down to 5 minutes or so. It's not like there's enough traffic on here to make a difference! I may also at some point switch my database from MySQL to SQL Server and experiment with hosting this site in the Azure Platform-As-A-Service...

Posted by ignusfast on 9/15/2016 10:53:25 PM ;   Last Updated by ignusfast on 9/15/2016 10:53:25 PM

.Net Core and external NuGet projects...

Wow, this is a real learning experience. :) I was looking for a server-based image manipulation library, mainly to handle resize duties in the production of thumbnail images. Initially I started out with the tried-and-true ImageMagick, which has been around for a long time. Unfortunately, the Core versions don't appear to be very stable. The first batch upload I tried wound up crashing the actual process with a lovely memory corruption that actually bypassed my try-catch code and took down the whole framework. Soooooooo. I dug around online, and found a package called ImageProcessor (https://github.com/JimBobSquarePants/ImageProcessor). It's only in alpha mode, but everything I need is complete. So I went ahead and installed it using the package manager, and switched a whole 10 lines of code to use it for aspect-ratio accurate resizing. I then threw it a torture test by uploading 30 images, almost all at 4K resolutions. Not a single hitch. You can see them all in the gallery. I'll try some more oddball cases - images that are taller than they are wide, images smaller than the thumbnail size for the site (260px on the longest side), etc. But it appears to be running like a trooper. I may go ahead and expose some of the image processing functionality it offers and see what it can do. More later...

Posted by ignusfast on 9/12/2016 5:23:05 PM ;   Last Updated by ignusfast on 9/12/2016 5:23:05 PM

Playing with Responsive Design

Learning so much; HDC here in Omaha was actually really informative. There were a few lame sessions, but overall I learned a TON. In light of that, over the past weekend I did the following to this site:
  • Ported the existing framework to .Net Core MVC
  • Moved to a responsive design using Bootstrap
  • Switched the ORM from Entity Framework 5 to Dapper

Posted by ignusfast on 1/18/2016 12:46:55 AM

I really should have looked this up sooner...

Command-Line scripting in Windows has grown a lot more powerful since the last time I'd played around. For example, I was wanting to zip an entire folder of multiple files, but each as a separate archive file. The following will do just that... FOR %i IN (*.jag) DO "C:\\Program Files\\7-Zip\\7z.exe" a "%~ni.zip" "%i"

Posted by ignusfast on 9/12/2015 8:24:02 PM ;   Last Updated by ignusfast on 9/12/2015 10:13:29 PM

So, this Entity Framework thing.

I love the fact that one can combine Linq and EF in order to create complex queries and have the framework properly interpret them. Things like the following work extremely well: var query = from u in art.articles select u;
if (!String.IsNullOrEmpty(model.Heading))
query = query.Where(u => u.Heading.Contains(model.Heading));
if (!String.IsNullOrEmpty(model.Body))
query = query.Where(u => u.Body.Contains(model.Body));
if (!String.IsNullOrEmpty(model.Author))
query = query.Where(u => u.Author.Contains(model.Author));
model.Articles = query.OrderByDescending(of => of.Favorite ?? sbyte.MinValue)
.ThenByDescending(op => op.Posted)
.ThenByDescending(ou => ou.Updated).ToList();


This represents the SQL executed by the Articles class you're viewing now. In administration, I have the ability to search for articles by Heading, Body, and Author. I then sort them descending based on whether or not they're favorites (only favorites will remain on this screen), and by last Posted Date and Updated Date. EF winds up producing the following query for MySQL:

SELECT
'Project1'.'ArticleID',
'Project1'.'DocumentID',
'Project1'.'Heading',
'Project1'.'Body',
'Project1'.'Posted',
'Project1'.'Updated',
'Project1'.'Author',
'Project1'.'Favorite',
'Project1'.'UpdatedAuthor'
FROM (SELECT
CASE WHEN ('Extent1'.'Favorite' IS NULL) THEN (-128) ELSE ('Extent1'.'Favorite') END AS 'C1',
'Extent1'.'ArticleID',
'Extent1'.'Posted',
'Extent1'.'DocumentID',
'Extent1'.'Heading',
'Extent1'.'Body',
'Extent1'.'Updated',
'Extent1'.'Author',
'Extent1'.'Favorite',
'Extent1'.'UpdatedAuthor'
FROM articles AS 'Extent1'
WHERE ('Extent1'.'Body' LIKE @p__linq__0) AND ('Extent1'.'Author' LIKE @p__linq__1)) AS 'Project1'
ORDER BY
'Project1'.'C1' DESC,
'Project1'.'Posted' DESC,
'Project1'.'Updated' DESC

-- p__linq__0: '%Linq%' (Type = String, Size = 6)
-- p__linq__1: '%ignus%' (Type = String, Size = 7)

-- Executing at 9/12/2015 8:53:35 PM -07:00

-- Completed in 0 ms with result: EFMySqlDataReader

Posted by ignusfast on 9/12/2015 7:42:25 PM

Welcome!

This is my first article, and as such is lame. I mean, it's not the most lame first post ever, but it's still pretty lame, right?


Last updated: 9/10/2016 3:42:16 PM
cached=True