Corn Maze Sunday

Img_0005

You know it's Fall in Pennsylvania when it's opening weekend of the corn maze.
Posted
 

Moving Your Django Blog? Don't Forget the Redirects

My weekend project is to convert my old company website (koberleinstudios.com) into my personal site (markkoberlein.com).  A while ago I posted about doing this along with changing the company name to Code.Paint.  Well, it's finally happening. More about Code.Paint later, but I wanted to share something that's pretty important when you are moving a website or blog to a new domain.

When you are moving a blog or website to a new domain and the content (URLs) doesn't change, you need to make sure that you add redirects for the old domain name.  

For example, because I'm moving koberleinstudios.com to markkoberlein.com I need to move the blog which used to default to markkoberlein.com and move it to blog.markkoberlein.com.  Once I do this I need to make sure that if someone tries to view the http://markkoberlein.com/jamochatini-recipe blog post they are redirected to http://blog.markkoberlein.com/jamochatini-recipe.

This is very important SEO because all the links that Google knows about are going to your old domain until you tell Google that they have changed. If you don't have redirects in place than the user may receive an HTTP 404 error which is bad for usability. 

In Django, this is easily accomplished by using the HttpResponsePermanentRedirect in the urls.py file.  

#code from urls.py

from django.http import HttpResponsePermanentRedirect

urlpatterns = patterns('',
        ('^jamochatini-recipe$',lambda request: HttpResponsePermanentRedirect('http://blog.markkoberlein.com/jamochatini-recipe')),
)

The HttpResponsePermanentRedirect is really nice because it will do permanent redirect (HTTP status code 301) which will tell search engines that the page has been moved and they should update the link on their end. 

Posted
 

Jamochatini Recipe

Jamochatini

This one goes out to my sister Annette because I'm sure she would appreciate it.  I created a simple drink called the Jamochatini because it reminds me of the Jamocha shake from Arby's.  Now, I don't claim this to be original because I know there are a lot of coffee flavored vodka drinks with liqueurs but I do believe that this is pretty tasty because of the espresso flavored vodka.

Here is what you need. 
  • 2 shots of Tenure Espresso XX (straight from the freezer or shaken)
  • 1 shot of milk
  • A little drizzle of chocolate syrup
The Tenure Espresso vodka is a good midrange Polish vodka that is distilled with espresso beans.  It has a great espresso flavor but I wouldn't recommend drinking it as a shot because it's also pretty sweet.  The shot of milk will help cut the sweetness.  You should only add a little bit of chocolate syrup but like I said the vodka is already sweet so don't use too much. I would drizzle a little bit in the glass before you pour the vodka and milk in.

Posted
 

Time To Upgrade Your Rounded Corners to CSS 3 Because of the IE 9 Beta #in

There were issues with implementing rounded corners with CSS in Internet Explorer 7 and 8. Webkit (Safari, Chrome) and Mozilla (Firefox) browsers could easily display them by using their vendor specific properties (-moz-border-radius, -webkit-border-radius). 

Now with the IE 9 Beta Microsoft shows that they are embracing the CSS 3 standard by using the border-radius property. Hopefully, the webkit and mozilla browsers will follow suit and use border-radius so that we can have two less vendor specific properties to worry about. 

Quick little snippet to turn any anchor tag into a rounded link:
<style>
  a {
     background-color: #4652cc;
     border: 1px solid #4652cc;
     color:#ffffff;
     padding:4px;
     font-size:93%;
     text-decoration:none;
     
     -moz-border-radius: 5px; 
     -webkit-border-radius: 5px;
     border-radius:5px;
  }
</style>

My Rounded Link

Remember you can take this further by adding a small gradient image that repeats to the background of your link to make it look even more like a button with a little depth. 
Posted
 

Removed the bootcamp partition, 8gigs on a Macbook i7 does the trick for Visual Studio performance on VMware Fusion with Win7

I have never been a fan of the dual boot but I tried it on my new Macbook because I spend 75% of time on Windows with Visual Studio.  You might be wondering why did I get a Macbook then.  Good question, I tried to avoid it because of the cost but the allure of developing iPhone/iPad apps for the business drew me in. 

I was worried about the speed of Visual Studio in a VMware Fusion Windows 7 VM on and I was right because the stock 4GB of memory in the Macbook doesn't do the job.  I dual booted for a few days with Bootcamp but Windows 7 doesn't work as smooth on a Mac and I also feel like I'm wasting hard drive space having 2 partitions with a lot of duplicate data between the two.

One other downsize to dual booting Windows 7 on a Macbook is that when you are using Windows you are going to get about half the battery life than you normally would. This is due to the Windows drivers that Apple provides for the hardware. 

I upgraded to 8GB with memory from Amazon for $200.  Pretty good deal considering that Apple would charge you $400. 

After the upgrade and designating 4GB and 4 processor cores to the Win7 VM I'm getting near native speeds for Visual Studio.

Posted
 

If You Manage ASP.NET Apps Make Sure You Apply This Workaround For The Latest Security Vulnerability

On Friday, a pretty big security vulnerability was disclosed that affects all ASP.NET applications and websites if the customErrors is set to Off or RemoteOnly in the web.config and you are not redirecting to a static error page for all your errors.

Scott Guthrie has a good post about this issue and the following workaround:

Enabling the Workaround on ASP.NET V1.0 to V3.5

If you are using ASP.NET 1.0, ASP.NET 1.1, ASP.NET 2.0, or ASP.NET 3.5 then you should follow the below steps to enable <customErrors> and map all errors to a single error page:

1) Edit your ASP.NET Application’s root Web.Config file.  If the file doesn’t exist, then create one in the root directory of the application.

2) Create or modify the <customErrors> section of the web.config file to have the below settings:

<configuration>        

   <system.web>

      <customErrors mode="On" defaultRedirect="~/error.html" />

   </system.web>        

</configuration>

3) You can then add an error.html file to your application that contains an appropriate error page of your choosing (containing whatever content you like).  This file will be displayed anytime an error occurs within the web application.

Notes: The important things to note above is that customErrors is set to “on”, and that all errors are handled by the defaultRedirect error page.  There are not any per-status code error pages defined – which means that there are no <error> sub-elements within the <customErrors> section.  This avoids an attacker being able to differentiate why an error occurred on the server, and prevents information disclosure.

Enabling the Workaround on ASP.NET V3.5 SP1 and ASP.NET 4.0

If you are using ASP.NET 3.5 SP1 or ASP.NET 4.0 then you should follow the below steps to enable <customErrors> and map all errors to a single error page:

1) Edit your ASP.NET Application’s root Web.Config file.  If the file doesn’t exist, then create one in the root directory of the application.

2) Create or modify the <customErrors> section of the web.config file to have the below settings.  Note the use of redirectMode=”ResponseRewrite” with .NET 3.5 SP1 and .NET 4.0:

<configuration>

   <system.web>

     <customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="~/error.aspx" />

   </system.web>

</configuration>

3) You can then add an Error.aspx to your application that contains an appropriate error page of your choosing (containing whatever content you like).  This file will be displayed anytime an error occurs within the web application.

4) We recommend adding the below code to the Page_Load() server event handler within the Error.aspx file to add a random, small sleep delay. This will help to further obfuscate errors.

VB Version

Below is a VB version of an Error.aspx file that you can use, and which has a random, small sleep delay in it.  You do not need to compile this into an application – you can optionally just save this Error.aspx file into the application directory on your web-server:

<%@ Page Language="VB" AutoEventWireup="true" %>
<%@ Import Namespace="System.Security.Cryptography" %>
<%@ Import Namespace="System.Threading" %>

<script runat="server">
    Sub Page_Load()
        Dim delay As Byte() = New Byte(0) {}
        Dim prng As RandomNumberGenerator = New RNGCryptoServiceProvider()
        
        prng.GetBytes(delay)
        Thread.Sleep(CType(delay(0), Integer))
        
        Dim disposable As IDisposable = TryCast(prng, IDisposable)
        If Not disposable Is Nothing Then
            disposable.Dispose()
        End If
    End Sub
</script>

<html>
<head runat="server">
    <title>Error</title>
</head>
<body>
    <div>
        Sorry - an error occured
    </div>
</body>
</html>

C# Version

Below is a C# version of an Error.aspx file that you can use, and which has a random, small sleep delay in it.  You do not need to compile this into an application – you can optionally just save it into the application directory on your web-server:

<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Security.Cryptography" %>
<%@ Import Namespace="System.Threading" %>

<script runat="server">
   void Page_Load() {
      byte[] delay = new byte[1];
      RandomNumberGenerator prng = new RNGCryptoServiceProvider();

      prng.GetBytes(delay);
      Thread.Sleep((int)delay[0]);
        
      IDisposable disposable = prng as IDisposable;
      if (disposable != null) { disposable.Dispose(); }
    }
</script>

<html>
<head runat="server">
    <title>Error</title>
</head>
<body>
    <div>
        An error occurred while processing your request.
    </div>
</body>
</html>

 

Posted