Developing with multiple versions of Django on windows

At work, we have sites that use various versions of Django, so there is a need to switch packages.  On my mac I use virtualenv to handle this, but I’ve never quite gotten it to play nice with windows, and just switching Django versions has sufficed so far. If you can set up virtualenv, that’s a much better solution

  1. Download junction (think symbolic links for windows). Put the executable somewhere in your path. I put it in my Python scripts folder (C:\Python26\Scripts)
  2. Plan out your directory structure: Make sure you don’t have any stock django eggs or folders in your site-packages folder
  3. Create a django_veresions folder in site-packages (C:\Python26\Lib\site-packages\django_versions)
  4. In this folder I put my different django installs
     C:\Python26\Lib\site-packages\django_versions\1.1\django
     C:\Python26\Lib\site-packages\django_versions\1.3\django
     C:\Python26\Lib\site-packages\django_versions\1.4\django
    
  5. I also put a txt file inside the django folder to easily see what version is there (this will be helpful later to double check)
    C:\Python26\Lib\site-packages\django_versions\1.4\django\1.4.txt
    
  6. Create a file called djangoversion.cmd and drop it in C:\Python26\Scripts
    junction -d C:\Python26\Lib\site-packages\django
    junction C:\Python26\Lib\site-packages\django C:\Python26\Lib\site-packages\django_versions\%1\django
    
  7. The first line removes any links that may have been there. The second line creates a new link to the version you’ll pass in.
  8. Now, to switch versions, just run this from the command line:

    djangoversion 1.4

    PS C:\Users\tbroder> djangoversion 1.4
    
    C:\Users\tbroder>junction -d C:\Python26\Lib\site-packages\django
    
    Junction v1.06 - Windows junction creator and reparse point viewer
    Copyright (C) 2000-2010 Mark Russinovich
    Sysinternals - www.sysinternals.com
    
    Deleted C:\Python26\Lib\site-packages\django.
    
    C:\Users\tbroder>junction C:\Python26\Lib\site-packages\django C:\Python26\Lib\site-packages\django_versions\1.4\django
    
    Junction v1.06 - Windows junction creator and reparse point viewer
    Copyright (C) 2000-2010 Mark Russinovich
    Sysinternals - www.sysinternals.com
    
    Created: C:\Python26\Lib\site-packages\django
    Targetted at: C:\Python26\Lib\site-packages\django_versions\1.4\django
    PS C:\Users\tbroder>
    
  9. Switch as needed

Sync side-loaded content between your Kindle and other devices

I read a lot of books on my kindle that I got from other sources, mostly Manning and O’Rielly, but these won’t sync between my phone and my kindle.  Only books purchased from Amazon will sync between devices. Again, Calibre to the rescue. For this to work, the book must already exist on the kindle and be sold through Amazon.  The example book I’m going to use is Version Control with Git.

  1. Add the book to your Calibre library
  2. Update any needed metadata.
  3. Jump over to Amazon and open the book’s page
  4. Make sure you are on the Kindle edition of the book.  If there is no kindle edition, this will not work.
  5. Make note of the ASIN code.

  6. Take this code and use it as the ISBN number in Calibre (it will not like this, that’s ok)

  7. Convert the book to .mobi (Even if it is already in .mobi format, you have to do this)
  8. Copy the book to your kindle via USB. Either by dragging it in your file manager or through Calibre. Do not use email, wifi, or 3g to do this, it will remove the ASIN code that we just wrapped onto the document. Once it is on the device syncing over wifi/3g will function as normal)
  9. Using USB, copy the file to your device. For android this is the kindle folder on your SD card. I haven’t tested but doing through iTunes is supposed to work for an iphone/ipad.

Enjoy!

Where the new Ice Cream Sandwich build of dropbox stores files

In the old version of dropbox, you used to be able to long press > download a file.  This has been replaced by “favorite”.

Instead of going to:
/sdcard/dropbox
These files are now stored in:
/sdcard/Android/data/com.dropbox.android/files/scratch

What do you listen to? (podcast edition)

I tend to listen to a decent number of podcasts. Usually while doing the dishes, running, or something or other in the park.  Some are book/comic related and help me keep up to date with what’s coming out and how some books were that I didn’t have time to read.  Others are tech and help me get other opinions on the new libraries or trends.  I’ve found a number of fun libraries/how-tos from listening. Check them out below, what do you listen to?

Tech

Non Tech

* I listen to every episode, others I cherry-pick

Creating a stateless request in Magento

Have you ever wanted to create a stateless request in Magento? Something that doesn’t touch any of Magento’s sessions?  We were having issues with some of the ajax calls on our cart and checkout pages mucking with the user’s cart and had get stateless on these calls.  The issue we were having was our checkout page was loading, then a javascript include was going out and bringing code from a 3rd party relevance engine into our dom, which was in turn calling back an ajax request to our servers.  This issue with this being that at the start of the page load, the checkout session was being set to a certain state.  This state was then being sent through the rest of the page load, and the ajax calls. Unfortunately, by the time the ajax call got back to our server, the session was different in both locations, creating a race condition.  The ajax request usually won, removing the work the full page load had done with trying to process checkout.  The good news was there was nothing in the ajax call that needed to touch the session, it was just some data lookup. So, nix the session part of that call, and our troubles should be over… Magento’s api controller is the only place that implements a stateless request this but its fairly easy to do (after a bit of digging).

As long as Mage_Core_Controller_Varien_Action is a parent in your controller’s hierchy, you are good to go (it probably is).  This class has a const FLAG_NO_START_SESSION which looks promising. Digging into the code a little we see that it controls whether cookies are processed or the session is started:

<?php
...
        if (!$this->getFlag('', self::FLAG_NO_START_SESSION)) {
            $checkCookie = in_array($this->getRequest()->getActionName(), $this->_cookieCheckActions);
            $checkCookie = $checkCookie && !$this->getRequest()->getParam('nocookie', false);
            $cookies = Mage::getSingleton('core/cookie')->get();
            if ($checkCookie && empty($cookies)) {
                $this->setFlag('', self::FLAG_NO_COOKIES_REDIRECT, true);
            }
            Mage::getSingleton('core/session', array('name' => $this->_sessionNamespace))->start();
        }

By adding to the preDispatch() method of our Action or Controller we can toggle this:

<?php
class Ai_AjaxCatalog_Controller_Action extends Mage_Core_Controller_Front_Action
{
        public function preDispatch()
        {
                $this->setFlag('', self::FLAG_NO_START_SESSION, 1); // Do not start standard session
                parent::preDispatch();
                return $this;
        }
}

Now, any action in this controller will be stateless and not effect any sessions.

Jira Tabs: Open all those Jira’s at once!

Ever want to open all the Jira’s on the screen in new tabs? Jess does, I do, and you should too!

For firefox and chrome we now have the JiraTabs bookmark button.

Drag this link up to your bookmarks bar: JiraTabs. Then, whenever you are on a filter or search view of Jira’s, click the button and all the jira’s on your screen will open up in new tabs

Demo:

Any updates will be made here.

Google’s Groupon Competitor Goes Live

http://bit.ly/eFvNwn

Skynet Becomes Self Aware Tonight

Terminator: The Sarah Connor ChroniclesEdit Terminator: The Sarah Connor Chronicles section

As a result of temporal interference by Sarah Connor, her son JohnMiles Dyson, and the T-800[2] destroyingCyberdyne headquarters and all backups of the research in 1995, the date for Judgment day is moved back to here.[3] Skynet is destined to go online a few days earlier on April 192011 at 20:11
Performance Optimization WordPress Plugins by W3 EDGE