Saturday, January 21, 2017

Using Technology to Avoid Reading A Long-winded Rent Contract

If you live in the UK like I do, you have probably seen some pretty dumb clauses in rental contracts.

These 2 are my favourite so far...
"Any obligation upon the Tenant under this Agreement to do or not to do anything shall also require the Tenant not to permit or allow any licensee or visitor to do or not to do that thing."

and...

"If the Premises are vacant for a period of over two weeks, the Tenants should allow the water to run from all outlets in the Premises for one minute before consuming or otherwise using the water."


Each year, some more dumb clauses are added. What's more, the agency (Keatons) told me that they outsource their contract writing to another company, so I cant have any modifications.

So I've had enough of reading the 150+ clause contracts. I decided to use Technology to help. Since the agency uses Ecosign, the answer was simple. DIFF!!!!




So this year I did the following:
  1. Open the 2015 and 2016 contracts in Beyond Compare
  2. Disable all trivial differences (eg. whitespace)
  3. Only read the lines which are different.

There was a slight problem with this method, as the contract slipped a few clauses in the middle, so each numbered clause was out of sync beyond a certain point. But Beyond Compare is smart enough to show you that the line is actually the same, and only highlight the number of the clause. So for each line, a quick eye-ball shows that nothing else is different. So if it was the same, I didnt bother reading it.

I managed to reduce the 2hrs of painful reading down to a handful of minutes.



The moral of the story

You can probably find a way around most mundane tasks. Don't let life's bullshit slow you down.


Tuesday, May 5, 2015

Why developers who use Windows should buy a Mac


Let me say firstly, I dislike Apple as a company. I think that the fanaticism that it drives among the sheep who line up to throw away their money is ridiculous. I kind of respect their ability to do that though. But I still don’t want to be caught with an Apple logo.

Anyway, this article is about why developers who use Windows should buy a Mac.




Reasons for NOT buying a Mac

- I hate Apple
- I’m happy with Windows
- I develop on Windows, so I don’t have any use for a Mac
- The function key is in the wrong place
- I have 20 years of muscle memory, and don’t want to re-learn what the Alt/Ctrl/Apple key does.

They are fair enough reasons if you are: 
- Pig headed
- Complacent
- Want to bury your head in the sand because you don’t want to learn new technologies. 

I’m here to tell you that I used to be all of those. But then I realised that I was just being a douche. I also came to the conclusion that even though I think that I’m adaptable, I had never properly used to Mac OSX. I could probably the total time I used a Mac in terms of minutes. So how adaptable was I really?

Reasons to buy a Mac

- It will force you out of your comfort zone
- You’ll inevitably learn some Linux/Unix command line stuff, which is good for you
- You can run Windows in a VM or Bootcamp
- It will expose you to a tone of new technologies
- Frontend technologies are driven by developers using Macs. If you’re using Windows ports of these technologies, then you’re behind the curve.
- The Apple Mac Book Pro is a premium quality laptop. It is by far the best laptop I’ve ever had. Nothing else comes close.
- Every technology you learn will help you learn new ones in the future. 
- Learning to use a Mac will help keep your mind flexible



That all said, there’s ways to make the transition easier. Before I even got the Mac, I spent a month watching Youtube tutorials for Mac newbies. I also Googled for Mac equivalents of everything I do in Windows - keystrokes, applications, optimisations, customisations, personalising etc. Once you’re mentally prepared for the learning curve, it’s not as bad as you dreaded. It’s actually just learning. If you don’t want to learn new things, then why are you a developer? You’re probably still using Cold Fusion, Classic ASP, or WebForms in VB.Net. ***I just threw up a little in my mouth***

To Summarise

So whether you’re an Apple hater, complacent, or just afraid of change, I’m going to say this… Get over it, and stop being a dick. If you want to be any good at your job, then you need to play with all types of technologies - even ones you hate! 



ps. Yes the first thing I did was put a sticker over the Apple logo. Yes I did that before I even powered it on the first time.



Thursday, March 21, 2013

How to delete dot net temporary files


Sometimes you need to delete your .net temporary files. Here is a quick little batch file to help you do it. Just double-click!

set net2_32="C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\*"
set net2_64="C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\*"
set net4_32="C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\*"
set net4_64="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\*"

REM stop iis
net stop w3svc

REM delete .net temp files
FOR /D %%i IN (%net2_32%) DO RD /S /Q "%%i" DEL /Q /F %net2_32%
FOR /D %%i IN (%net2_64%) DO RD /S /Q "%%i" DEL /Q /F %net2_64%
FOR /D %%i IN (%net4_32%) DO RD /S /Q "%%i" DEL /Q /F %net4_32%
FOR /D %%i IN (%net4_64%) DO RD /S /Q "%%i" DEL /Q /F %net4_64%

REM start iis
net start w3svc



Enjoy!

Sunday, January 20, 2013

50 Ways to Avoid, Find and Fix ASP.NET Performance Issues

I contributed to a free book that got launched last week. It's a book about quick tips and tricks for performance:

50 Ways to Avoid, Find and Fix ASP.NET Performance Issues

My tip:
"Projects that use multiple levels of cache often demonstrate a misunderstanding of why caching is required in the first place. Caching is not synonymous with performance. Your code should already be efficient. Caching should only be used as a last resort, after you’ve made all possible (and sensible) code optimizations."
It sounds obvious doesn't it. But how many projects have you come across where caching was hiding inherent performance problems?


Anyway, the book is part of a marketing campaign for Red Gate Performance Profiler. So even though it is free, you may be contacted by Red Gate via email. There's no such thing as a free lunch now is there.

In any case, if you're a .net programmer then you should definitely have a read. It gives you 50 quick bits of useful knowledge. Most of which, you should definitely be aware of if you're a .net programmer.

Get it here: http://www.red-gate.com/products/dotnet-development/ants-performance-profiler/entrypage/avoid-find-fix-asp-problems







Friday, January 18, 2013

Phishing - You're doing it wrong!

I found this email in my spam box yesterday:

This email is from the fbi. We have an information for you regarding the person you are transacting with online. So we advise you to pause any transaction now and get back to us through this email below for further information.
Contact *******  ****** of the fbi secrete service on **********@hotmail.com


There are so many things wrong with this email. But the first thing that stuck out to me was the Hotmail address. Seriously! Why would the FBI use a Hotmail address? 

Phishing... You're doing it wrong!



Note: I blocked details because it looked like a hacked personal account.



Thursday, January 3, 2013

Dead-Simple Minification and Combination of CSS and JS files

In this post I'm going to give a quick example of how to compress and combine CSS and JS files in a build step, and to link these up in your .net application using razor. It's so damn easy that there's no reason why your next project shouldnt use it. I'm going to assume that you already know about MSBuild.

A special note: Since we're dealing with combining files, it is worth noting that your CSS needs to be done right (of course!). If you have overriding styles for certain pages, you'll need to make sure that your CSS targeting is more specific otherwise your pages might look strange.

Lets begin....


First, get YUI: http://yuicompressor.codeplex.com/documentation

I put YUI under a root tools folder: \Tools\YUI\


MSBuild

The following file will compress all files under \css and \scripts folders, into single files: minified.css and minified.js (respectively). See the properties MinifyCssOutput and MinifyJSOutput if you want to change these file names. You can exclude files using the properties MinifyJsExclusions and MinifyCssExclusions.

The following code should be self explanatory:

 <?xml version="1.0" encoding="utf-8"?>  
 <Project DefaultTargets="RunAll" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">  
   <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>  
   <UsingTask TaskName="CssCompressorTask" AssemblyFile="..\..\Tools\YUI\Yahoo.Yui.Compressor.Build.MsBuild.dll" />  
   <UsingTask TaskName="JavaScriptCompressorTask" AssemblyFile="..\..\Tools\YUI\Yahoo.Yui.Compressor.Build.MsBuild.dll" />  
   
   <!-- Settings -->  
   <PropertyGroup>  
        
     <!-- Define output files -->  
     <MinifyCssOutput>$(TargetPath)Css\Minified.css</MinifyCssOutput>  
     <MinifyJsOutput>$(TargetPath)Scripts\Minified.js</MinifyJsOutput>  
   
     <!-- Define files to exclude-->  
     <MinifyJsExclusions>$(TargetPath)scripts\jquery-1.8.2.min.js;$(TargetPath)scripts\somefile.js</MinifyJsExclusions>  
     <MinifyCssExclusions>$(TargetPath)Css\SomeFolder\*.css;$(TargetPath)scripts\somefile.css</MinifyCssExclusions>  
   </PropertyGroup>  
   
   <Target Name="RunAll">  
     <Message Text="RunAll"/>  
   
     <!-- Ensure output files do not already exist -->  
     <Delete Files="$(MinifyCssOutput)" />  
     <Delete Files="$(MinifyJsOutput)" />  
       
     <CallTarget Targets="Minify"/>  
   </Target>  
   
   <Target Name="Minify">  
     <Message text="Compressing JavaScript and CSS files"/>  
       
     <!-- Define files to include -->  
     <CreateItem Include="$(TargetPath)Scripts\**\*.js" Exclude="$(MinifyJsExclusions)" >  
       <Output TaskParameter="Include" ItemName="JsFiles"/>  
     </CreateItem>  
     <CreateItem Include="$(TargetPath)Css\**\*.css" Exclude="$(MinifyCssExclusions)">  
       <Output TaskParameter="Include" ItemName="CssFiles"/>  
     </CreateItem>  
   
     <!-- Do compression -->  
     <CssCompressorTask  
        SourceFiles="@(CssFiles)"  
        DeleteSourceFiles="false"  
        OutputFile="$(MinifyCssOutput)"  
        CompressionType="Standard"  
        LoggingType="Info"  
        PreserveComments="false"  
        LineBreakPosition="-1"  
     />  
   
     <JavaScriptCompressorTask  
         SourceFiles="@(JsFiles)"  
        DeleteSourceFiles="false"  
        OutputFile="$(MinifyJsOutput)"  
        CompressionType="Standard"  
        LoggingType="Info"  
        LineBreakPosition="-1"  
     />  
   </Target>  
 </Project>  
   


The file can be called from your main MSBuild file using:
 <MSBuild Projects="$(MSBuildStartupDirectory)Build\Minify.msbuild"/>  


Note: My MSBuild transform files are in a root build folder: \Build\Transforms\, and my YUI files are under \Tools\YUI\, so you'll notice that my AssemblyFile attributes start with ..\..\Tools\YUI. Change this and any other paths to fit your folder structure.



Modifying your layouts

All you need to do is add the following razor code to your layouts...

Put this in your <head>
 @if (HttpContext.Current.IsDebuggingEnabled)  
 {   
      @*put your css files here*@  
      <link href="/css/layout.css" rel="stylesheet" type="text/css" />  
      <link href="/css/someother.css" rel="stylesheet" type="text/css" />  
}   
 else  
 {  
      <link href="/css/minified.css" rel="stylesheet" type="text/css" />  
 }  


Put this in where your javascript files are. I like to put it at the end of <body>. Note: I put jQuery in the <head>. I think this is useful but some may disagree.

 @if (HttpContext.Current.IsDebuggingEnabled)  
 {   
      @*put your js files here*@  
      <script src="/scripts/site.main.js" type="text/javascript"></script>  
      <script src="/scripts/someother.js" type="text/javascript"></script>  
}   
 else  
 {  
      <script src="/scripts/minified.js" type="text/javascript"></script>  
 }  


You probably already noticed that when your application is in debug mode, then all the files will be rendered, otherwise only the minified file is rendered.

If you have nested layouts, that's fine. You can have the "if" statement at all levels, just don't include the "else" part in the child layouts.


Conclusion
Minification and combination of CSS and JS files is dead simple! Do it!

Enjoy!



Sunday, October 28, 2012

This is Automation Sparta - Wildcard DNS

This post is the 3rd in a set of posts outlining Automation Sparta - a No Configuration setup for Web Development.

In this post I'll talk about the power of wildcard DNS and how you can use it to reduce configuration time in your web deployment.

In web development there are typically at least 3 environments (servers) in your Project Universe. Dev, Staging (QA), Live (Production). To test a web application we obviously need a domain to hit for each environment.

Some agencies use:
something-dev.yourcompany.com
something-staging.yourcompany.com
something-live.yourcompany.com

Some use:
something.yourcompanydev.com
something.yourcompanystaging.com
something.yourcompanylive.com

Others use:
something.dev.yourcompany.com
something.staging.yourcompany.com
something.live.yourcompany.com

Note: "something" is typically be a project code or project name.

Actually, to be honest, I've never seen an agency that has it's own Live domain. They typically wait until the client tells them what they want the live domain to be. This means that they often get as far as Staging in  deployment. They never reach a deployment to the Live environment until very late in the development cycle. This is a horrible horrible horrible practice! Anyway, let's pretend that all agencies have the good practice of testing their new websites on the live server even before the client tells them the desired domain...

If you take a look at the 2nd and 3rd example, you can see that for each project (web application) the only part of the domain that will change will be the prefix. This is where wildcard DNS can be applied. 

All you need to do is register the following wildcards with your DNS provider:

*.dev.yourcompany.com
*.staging.yourcompany.com
*.live.yourcompany.com

Just make sure that each wildcard points to the respective server. Now any prefix can be used for each environment. For example. thisissomethingrandom.dev.yourcompany.com will automatically point to your development environment.

The benefit of this is obvious. It removes the need for configuration of DNS for each project. You can just deploy your site to the respective server. All you need to do is create an IIS site. And this can be automated! This also means that you can deploy to your Live server early in the development process without having to wait for the client to register a domain (which seems to normally happen late in the game). These are 2 crucial components to a "no configuration" setup.
As an added bonus, you'll also notice that many software licenses are valid for sub-domains. This means that you can use the same license file for each environment. Of course you may still need a new license for the actual live domain. But at least you can still test your site on the live server before the real domain is registered/available.


Anyway, if your DNS provider does not support wildcard DNS then you definitely consider changing providers. Wildcard DNS is a massive time saver. It is just another DNS entry. It shouldn't cost you anything extra. For more information about wildcard DNS click here.