How I concatenate header, footer for html web development using gulp

I often like to start new sites with a mock up that is strictly html. I get html templates from sites like Theme Forest so they are already designed for me. All I do is modify it to fit the theme of my new site.

The biggest pain is that most of these html files have the header and footer in them so looking at the files one at a time look great but when I want to start my modifications, I’m looking for a way to make a change in the header or footer section once and then see it in all of my new pages.

Here’s what I’m doing to get this done today, it’s simple, easy to implement and trimmed down to just the basics to get going. I really love gulp and doing html mockups in real-time is a dream come true.

Continue reading “How I concatenate header, footer for html web development using gulp”

(solved for now) Export Template in Visual Studio 2017

If you’re like me, you like to create templates out of your Visual Studio 2017 code so you can just use those templates as your base for starting all new projects.

The reason I do this is so I don’t have to start over from scratch. If you’re doing that all the time, you are re-inventing the wheel and wasting precious cycles of your life.

Using export template in Visual Studio 2017 is amazing but as of Fall 2017, it’s broken.

export template fix for visual studio 2017
export template fix for visual studio 2017

Continue reading “(solved for now) Export Template in Visual Studio 2017”

Uppercase First Method in C#

C# method to uppercase the first letter of a passed in string.

I know that this method is out on the interwebs somewhere so if anyone knows, please share with me so I can give credit where credit is due.

I am starting to share all of my little helper methods online so I never forget 🙂

private static string UppercaseFirst(string s)
	// Check for empty string.
	if (string.IsNullOrEmpty(s))
		return string.Empty;
	// Return char and concat substring.
	return char.ToUpper(s[0]) + s.Substring(1);

How to delete the IIS ASP.NET response headers for security sake

There are some nice plugins out there like “BuiltWith” and “Web Server Notifier” and many others that allow you to see the platform that websites run on.

These tools will show what server you’re using like Apache, IIS, Nginix etc. and your security people in your company will ask you to turn off the sharing of this information.

Here’s what I do to remove that information and I use IIS so I add this section to my web config.

            <remove name="X-Powered-By" />
            <remove name="X-AspNet-Version" />
            <remove name="Server" />

dotnet command line goodness from senor hanselman

I love to keep up with all things Scott Hanselman, he’s really a golden god of the tech. I’ve been learning the new dotnet core stuff lately brushing up on my skills and came across his command line tutorial which is a great into into how you use the dotnet command line.

I’m going to shorten it up for my purposes as I’d like to reference back to it as I keep my studies up. Here’s the list of command and what they mean:

make a directory and move to the new folder

md testexample & cd testexample

create a solution file

dotnet new sln

create a class library, the -n is the name & the -o is the location

dotnet new classlib -n mylibrary -o mylibrary

create a xunit text project

dotnet new xunit -n mytests -o mytests

add the class library to the solution file

dotnet sln add mylibrary\mylibrary.csproj

add the xunit test project to the solution file

dotnet sln add mytests\mytests.csproj

add the xunit test project to the solution file

dotnet sln add mytests\mytests.csproj

move to the mytest project and add reference to class library

cd mytests
dotnet add reference ..\mylibrary\mylibrary.csproj

move up one level and restore the project which pulls down the packages it needs

cd ..
dotnet restore

move to the mytests folder and run the test. –> Scott says, Of course, I’m testing nothing yet but pretend there’s a test in the tests.cs and something it’s testing (that’s why I added a reference) in the library.cs, OK?

cd mytests & dotnet test

add a watcher to your tests so when you save code, your tests will run automagically. open up your /mytests.csproj file and add this xml snippet

 <DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />

go back up and restore again as you want to add the watcher dependencies and now you can test

cd ..
dotnet restore

add this code to your UnitTest1.cs file and hit save, you will see your tests run. one test should pass and one should fail

public void Test1()
	Assert.Equal(4, Add(2,2));

public void Test2()
	Assert.Equal(7, Add(4,2));

int Add(int x, int y) {
	return x + y;