Code highlighting the easy way

So after relaunching this site using Umbraco and the default Bootstrap 4 theme (blog) i realised there was no <code> highlighting included in bootstrap.

After some quick Googling i came across a very useful JavaScript library called highlight.js this library is able to auto match up to 176 languages and colour code them accordingly.

This seemed pretty nifty and much easier than codiing a ton of css myself.

To implement this you just need to add 3 very small lines into the <head> if the site:

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>

Then wrap your code with the following:

<pre><code>...</code></pre>

If the auto highlighting doesn't work or you would like to use a different style you can manually set it like so:

<pre><code class="html">...</code></pre>

Or if you would like to disable code highlighting altogether:

<pre><code class="nohighlight">...</code></pre>

This is just a real basic implementation of this JavaScript library, take a look over on the project website to see about custom initialization, downloading the library and creating a custom library.

 

How to increase the Umbraco Media upload limit

If you need to increase the upload limit with Umbraco, this can easily be done if you have root access to your server.

You may have to contact your hosting provider if this is not the case.

First off, you need to update your Web.Config allow the file size you need...

Carry out a search for:

maxRequestLength

Then change the value to the file size you require in kb, for example 100MB in kb is 100000

Once you have made this change you need to update IIS to also increase the limit, there are 2 ways to do this...

First Way:

Navigate to:

cd %winsrv%\system32\inetsrv

and run this code:

appcmd.exe set config "sitename" -section:requestFiltering -requestLimits.maxAllowedContentLength:size in bytes -commitpath:apphost

Second Way:

Open Internet Information Services (IIS) Manager find your website under Sites and click on its name.

Then under IIS click on Request Filtering in this section on the right click on Edit Feature Settings

Then change the Maximum allowed content length (Bytes) in my case again 100MB is 104857600Bytes.

Click Ok and then restart your sites Application Pool

(Original Source)

Bye WordPress... Hello Umbraco

After many years fighting with Script Kiddies and people trying to break into my blog (not sure why they would) i decided to stop using the inherently unsecure WordPress.

This is down to 1. the above reason with script kiddies and 2. using a piece of software called Umbraco at work.

Umbraco is a DotNet based CMS, i have it running on IIS7 and DotNet 4.7, to find out more info just visit their site here.

It's a neat bit of kit, with a brilliant community behind it!

Everytime i have had a issue while rebuilding this site or building a client site at work has seen someone drop in and lend a hand within 15 - 20mins of my post!
Even at weekends!

It seems to be so much easier to use and work with if your a developer (I wouldn't recommend it to a novice)...

As you can see there are still some bugs with the site... One of the biggest being <code> tags not yet being supported, i am working on this and hopefully will have this working soon.

I have now added the code highlight bits, ill follow up with a post showing how i accomplished this soon.

Visual Studio update to 15.5.3 breaks donet core 2.0 solution

I came across an issue after updating my Visual Studio version to 15.5.3 which would cause my solution to throw an exception whenever it tried to access the database.

System.IO.FileLoadException: 'Could not load file or assembly 'System.Data.SqlClient, Version=4.2.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'

The fix for this is nice and easy, you just need to install the NuGet (V4.4.2) package System.Data.SqlClient.

Custom WordPress Installer for Virtualmin GPL

This WordPress installer for Virtualmin has been doing the rounds online for years, but it is slowly disappearing, so I figured I would post it here for easy access.

I have made some minimal changes so that is downloads the latest version from WordPress and checks for PHP7 and PHP5

Download here:
https://aaronsadler.uk/custompress.pl

Install it here:
/usr/libexec/webmin/virtual-server/scripts/

Then, login to Virtualmin -> Installer Scripts and there will be "Wordpress" option