ASP.NET Permanent (301) Redirect

Within ASP.NET, the System.Web.HttpResponse class providers a method to handle HTTP redirects, aptly named Redirect. The Redirect method has two overloads:

  • Redirect (string)
  • Redirect (string, bool)

The former accepts a string representation of the URI that you’d like to redirect to. The latter accepts the string URI and a boolean indicating whether you want ASP.NET to stop processing the request immediately or to continue throughout the life cycle of the request.

Unless you’re a HTTP junkie or you’ve had a specific reason to issue a permanent redirect (reorganising a web site is a prime candidate), you can be forgiven for not realising that the Redirect method issues a temporary redirect (HTTP 302). Not having needed to issue a permanent redirect through ASP.NET before, I assumed (there is that word again) that there would be additional overloads to handle both temporary (HTTP 302) and permanent (HTTP 301) redirects or optionally another method; I was wrong.

To issue a HTTP 301 permanent redirect through ASP.NET, you need to do a little bit of manual labour; don’t worry it’s only two lines of code:

  • Response.Status = "301 Permanently Moved";
  • Response.AppendHeader ("Location", URI);

At this point, so long as nothing else interferes with the response – the client will receive a standard run of the mill 301 HTTP permanent redirect. If you know or are worried that something following the above lines may modify the response, you can issue an optional Response.End() as the third line to make it take effect immediately.

Posted in Programming | Tagged , , , , | 1 Comment

Jim “Mr Shy” Mirkalami

In February, I wrote about receiving comment spam from a guy by the name of Jim Mirkalami. Since that time, there has been a lot of different people writing about the spam that they’ve received from our friend Jim; however it appears that he isn’t liking the new found attention that he is receiving.

This week, I received what would otherwise be considered a cease and desist type of comment. It surprises me that Jim would now be spamming more people telling them to stop writing about him and using his name, when it was clear that was his intention in the first place.

In any case, Jim is just going to have suck it up like everyone else online as it isn’t going to get removed from anyones site in a hurry.

Posted in Commentary | Tagged , , | 1 Comment

Rapid Development Using Django

In February, Jesper Nøhr wrote about taking an idea from conception to profitable web site in 24 hours. The project involved building an advertising product for the indie crowd, so they could advertise their products throughout other web sites in a similar fashion to how Google Adwords & Google Adsense works.

The final product named The Indiego Connection, allows advertisers to sign up and their account is manually verified to make sure that it meets their indie requirements. Once their account has been approved, they can go about configuring their advertising, which is then displayed throughout other web sites.

The really interesting thing for me about this project was the technical aspects of it, which involved:

Jesper wrote the front end of the site using Django, as he uses it for his day job. Given the demanding time frame that the product was built in, I expect that as many of the existing applications were utilised – such as auth. The prototype for the advertising server was built using CherryPy and once Jesper was satisfied with how it was constructed, moved that into Erlang for the lightweight threading and performance.

About 24 hours after starting the project, Indiego Connection was pushed into the wild. Word got out about a free advertising product for the indie crowd quickly and within hours they had over 100 users.

In any sort of normal environment, working an idea from start to finish in 24 hours would seem nearly impossible; especially if technology is involved. Through clever use of the tools, its allowed Jesper to rapidly develop a complete product in a short space of time.

Posted in Programming, Web Development | Tagged , , , , , , , | 1 Comment

Django Friendly Hosting

If you’re about to purchase hosting for your Django application, everything you’ll need to make a good decision is in one place at Django Friendly.

Ryan Berg is the man behind Django Friendly and put together the site as a way to consolidate the plethora of hosting options available for Django. As with some other scripting languages such as Ruby, Python also has some special hosting requirements which makes it inconvenient to host it within standard hosting configurations. The development of mod_wsgi for Apache is aiming to provide a simple, high performance option for hosting Python applications within shared hosting environments.

Allowing users the ability to filter web hosts by price and shared/dedicated hosting types is a great step forward. My suggested improvement for the site would be the ability for users to dynamically build a search query. As an example, being able to filter by server location, hosting type, price ranges, ratings and so on. Maybe an interface in a similar fashion to what is offered by a custom ticket search within the popular Trac software could be used as a starting point.

Either way, it’s another fantastic looking Django specific site which has been offered up to the greater community – you’ve got to love it.

Posted in Services | Tagged , , , | 1 Comment

Google Account Signin With CAPTCHA

Google Account login featuring CAPTCHA for additional securityTonight I was presented with a Google login page which was different in a few ways:

  • size and shape of the control were different
  • instead of using an in page control, it took me to a completely new page
  • required additional CAPTCHA validation

I suspect this may have been triggered by logging in and out of various Google products tonight, where I closed a tab but didn’t close the browser, opened new tabs and logged in and out and it might have had conflicting session information.
Does anyone know what causes this type of login prompt to be thrown up by Google?

Posted in Services | Tagged , , | Leave a comment

Change The Django Source Directory With A .pth File

John DeRosa recently wrote about using junctions (the Windows version of a symbolic link within Unix) to change the Django source directory. While that solution clearly works, I got the impression it seemed like a lot of hard work and John asked if there was a better way of handling that scenario.

If you’re wondering why a developer might want different versions of Django installed – it’s common if you need to upgrade an existing site from one version to another or if you offer a distributed application that is meant to work on the latest and also older versions of Django.

Under normal circumstances, developers place a copy of the Django source code underneath their ${install_path}\Lib\site-packages\ folder. While this works, it isn’t particularly convenient if you want or need to switch between the different versions. Under a unix based system, the common way of switching between the different versions is using a symbolic link; so you’d change the symbolic link from pointing from version A to version B. Unfortunately, in a Windows environment the concept of a symbolic link either doesn’t exist or isn’t common knowledge. As a by product, the average developer is only left with the option of copy and pasting the Django source code around in their file system or renaming folders – not particular convenient.

Fortunately, a little known feature of Python is that it supports special files with a .pth file extension. The .pth files or path files, are using by the site module (found under ${install_path}\Lib\) when the interpreters environment is initialised. The .pth files are standard text files, which contain one path per line, which when loaded are added into the sys.path collection.

A quick run down, place a django.pth file under ${install_path}\Lib\site-packages\, with a single line pointing towards your preferred Django source code version. When you need to change the version of Django you’re developing against – change the path within the file. Remember that if you have a Python interpreter open at the time, you’ll need to restart it and likewise if you’re running Django via something like Apache.

Posted in Programming | Tagged , , , | 3 Comments

Jim Mirkalami, The Lurking Spammer

Today I received a curious comment into #if debug:

Name: Jim Mirkalami
Email: jim@homenetmail.com
IP: 74.14.19.186
Comment: I have been visiting this site a lot lately, so i thought it is a good idea to show my appreciation with a comment.
Thanks,
Jim Mirkalami

Other than the fact it is a fairly standard useless comment, it perked my interest immediately when he mentioned that he’d been visiting the site a lot lately. While I’m sure my content has been nothing short of engaging, it’d be surprising given I’m using a standard WordPress template and the domain is only three months old.

For the sake of it, a quick investigation about Jim Mirkalami reveals that he has been using a lot of peoples sites lately. In fact, not only has he been using them – he has been leaving a similar or identical comment on them all.

I suspect that Jim is a clever sort of a bloke, looking for smaller gains than your average spammer. Instead of dropping a comment with a dozen or more links – his comments don’t include any links. The comment uses plain English, so it is less likely to get hit by a bayesian filter and polite enough that some people would let it through their comment moderation. Mr Mirkalami also appears to favour the highly visible domains such as Google and Yahoo!.

At some point down the road, Jim is going to return to the sites that he later found to accept his comment and is hoping to exploit a convenient option that most WordPress users enable. The option is related to comment moderation and allows someone to pass through comment moderation once they have had a comment approved.

If Jim is doing what I suspect he is, you have to give him a little credit for showing a small amount of patience with his spamming. Of course, that credit becomes completely invalid when you remember that he is nothing but a filthy filthy spammer.

Posted in Commentary | Tagged , , | 5 Comments

Installing Django On Windows

Ever needed to install Django in a Microsoft Windows environment, here is a quick start guide to make that happen:

  1. Read through the official Django installation documentation, it might just save you a world of hut down the road.
  2. Download Python for your version of Windows.
  3. Install Python, my preference here is to put it into the Program Files folder under a folder named Python<Version>
  4. Add your chosen Python installation path into your Windows path environment variable. This is an optional step, however it allows you to just type python in the command line and have it fire up the Python interpreter. An easy way of adding it is going into Control Panel, System and into the Environment Variables section.
  5. Download Django, you can either download a compressed file or if you’re comfortable with using version control – check it out from the Django Subversion repository.
  6. Create a folder named django under your <Python installation directory>\Lib\site-packages\ folder. Using my example above that would have been C:\Program Files\Python25\Lib\site-packages\.
  7. If you chose to download the compressed file, open it and extract the contents of the django folder into your newly created folder. If you’d prefer to check it out from Subversion, the normal check out points are http://code.djangoproject.com/svn/django/trunk/ for the latest development copy or a named release which you’ll find under http://code.djangoproject.com/svn/django/tags/releases/.

Done, you now have a working Django installation on Windows.

At this point, it’d be pertinent to confirm that everything is working properly, which you can do by following the first Django tutorial. The tutorial will make mention of django-admin.py, which is a utility which offers some basic functionality to get you off the ground. The file is located in the bin folder under your Django installation directory. When you need to use it, you can either type in the full path to it or simply add that file path into your environment variables as well.

Posted in Programming | Tagged , , , , | Leave a comment

Google Reader Duplicate Item Improvement

One of the features that I love about RSS, is that it allows users to keep their finger on the pulse of certain topics very easily. As some people may know, I quite like the Python web framework Django and I use Google Reader to help me keep up to date about what is happening within the greater Django community. I do this by subscribing to RSS feeds of people who I know regularly write about the product but also by utilising online social booking marking sites such as del.icio.us and ma.gnolia.

I recently read an article by James Holderness about detecting duplicate content within an RSS feed (via). For those not bothered with the jump, James outlines different techniques that the top x many feed reading products use to detect duplicate RSS content, which ranges from using the id field within the RSS down to comparing title and description information.

Back to the improvement, which is related to the information that James provided. When I subscribe to the social booking marking sites, they end up providing back a huge range of content matching certain criteria. The ones I’m subscribing to at the moment for Django are:

As you can imagine, each of these services has a different and overlapping user base. Each of which will find common items throughout the internet and bookmark them each day. When that stream of information is received by Google Reader, it will display half a dozen of the same unique resource, but masked by different user accounts within their bookmarking tool of choice.

What would be a great optional feature to add into Google Reader would be the ability to detect duplicate items even when they are sourced via the same domain or different domains.

The trick to something like this would be identifying the pattern, so as to allow Google to use an algorithm to flag it. For the sake of this concept, I think it’d be reasonable to consider items posted into social bookmarking sites and an aside or link drop in a blog to be reasonably similar.

My initial concept would involve comparing the amount of content within an item. If there are less than a predefined limit of words and a small number of links, then that item might be considered to be a link drop. You could apply that logic not only to social bookmarking sites but also to the standard blog, where an author might find something cool they want to link to.

The next thing up for consideration might be which items to remove as duplicates and which to include. News of any kind on the internet tends to reverberate throughout it quite quickly, so it’s common to find the same information posted many times. As the vibrations are felt throughout, people will tend to link back to where they found that information (as I did above). Google Reader could leverage off the minty fresh search engine index to help with this by using the number of attribution links passed around. As a quick and simple example, imagine the following scenario:

  • Site A has the unique Django content that I’m interested in
  • Sites B through Z all link to site A directly
  • Some sites from C through Z also link back to B, which is where they found that information

I don’t subscribe to site A directly, however some of the sites B through Z have been picked up by the social networks. Using the link graph throughout those sites, it’d be possible to find out which one(s) among that list are considered authoritative (based on attribution or back links) and start filtering based on that. It might then be possible to use other features of the Google Search index to do with theme, quality, trust to filter it further.

I think a feature like that within Google Reader would be fantastic, especially if I could apply those sorts of options on a per feed or folder basis. That way, I could group all of the common information together (Django) and have Google Reader automatically filter out the duplicates that matched the above criteria.

I’m sure the development team from Google Reader will hear my call; who knows, in a few months maybe a feature like this could work its way into the product.

Posted in Services | Tagged , , , , , , , | 4 Comments

Matt Mullenweg Changes Domain

Blogging master and WordPress founder Matt Mullenweg has changed domain.

Matt has been blogging for the last seven years under http://photomatt.net, which was an appropriate domain at the the time. Early on in the piece, Matt would post photos regularly and any photos of him often included his own camera.

Since leaving CNet and founding Automattic, Matt has been fiercely committed to developing the blogging platform WordPress and its associated products Ping-o-matic, Akismet and recently Gravatar.

How times have changed for Matt, after taking the initial gamble of starting Automattic – the company has just closed a USD$29.5 million dollar series B funding. The new round of funding is going to allow the team to not worry about money for salaries for the next few years and really focus on enhancing their current product line and building out new ones.

With the change, the new internet home of Matt Mullenweg is announced http://ma.tt

Posted in Commentary | Tagged , , , | Leave a comment