Python development on Windows – Setuptools & Pip configuration

Code,Web Development — Mark @ 9:42 pm

Sometimes installing Python modules on Windows is a pain. You have seen the setuptools error message complaining that you don’t have Visual Studio 2003 installed? Yes, well then you have probably seen that the fix is easy:

python setup.py build –compiler=mingw32 install

But what if you want to install using easy_install or pip? or you want to use a pip requirements.txt file in a virtualenv? I have the solution for you.

First: Install MinGw including gcc, make and all the other regular goodies you would have on a Unix system.

Second: Add your \MinGw\bin directory to your path.

Third: If you are using an older version of Python (pre 2.6.6) you will have to manually set your HOME environment variable to your user directory.

Finally: In your C:\Users\Admin (where Admin is your Windows user account, Windows XP users, adjust to \Documents and Settings\ appropriately), create a text file called pydistutils.cfg and paste in the following options:

[build]
compiler = mingw32

That’s it! Enjoy using the magical goodness of pip and easy_install on packages like Twisted, SimpleJson (with speedups) and postgres

Python – Convert a Dictionary to a List

Code — Tags: — Mark @ 9:53 pm

We can easily create a Python list by pulling only the values out of a dictionary. This is done via the values() method.


>>> x = {'a':1, 'b':2}
>>> x
{'a': 1, 'b': 2}
>>> y = list(x.values())
>>> y
[(1), (2)

Ruby on Rails + Gmail SMTP (TLS)

Code — Tags: , , — Mark @ 7:55 pm

This took way too long to figure out the answer to without using a custom plugin. I hope this helps others! I was setting up Redmine with Gmail as an SMTP server utilizing config/email.yml. Behold!

email.yml with no other related changes in environment.yml using Rails 2.2.2

production:

delivery_method: :smtp
smtp_settings:
enable_starttls_auto: :true
address: smtp.gmail.com
port: 587
domain: GMAILDOMAIN.com
authentication: :plain
tls: :true
user_name: "EMAIL@YOURGMAILDOMAIN.com"
password: "YOURPASS"

If you are setting up Redmine, there is a nice feature under Administration > Settings > Email Notifications > and in the very bottom right corner of the page, a “Send a Test Email” link.

List of Free and cheap Subversion (SVN) repository hosts

Code — Mark @ 4:24 pm

So currently I am hosting 4 SVN repos on the same box as our web server. The server is maintained by me and gets backed up not nearly enough. So before I have a disaster and lose months of work I began looking to at least store my code somewhere safer. In my search to find SVN hosting this is what I found which can hopefully save you some searching:

  • XP Dev –  Completely free SVN repository hosting for projects smaller than 1.5 gbs. Free for Open Source and private projects, with any number of contributors. XP Dev offers a pretty impressive list of features for a free service including issue tracking, wikis and task management. Looks like a great and promising site. They even have posted a guide to help you migrate your existing repository over to them. Commiters must create an XP Dev account.
  • Project Locker – Appears to be the best value from the bunch for paid SVN hosting. Appears as if you want to have a Trac you either need to be an Open Source project or pay. For $5 USD you can get 5 commiters, unlimited repos, unlimited Tracs and of course backups. Comparison of service options here.
  • SVN Repository – Appears similar to Project Locker except more expensive on small projects. Cheaper for unlimited number of commiters. Comparison of options on main page.
  • DejaVu – Another but not nearly as cheap as the others, cheapest plan is $19 USD if you are not one of the ‘chosen ones’ who recieve a free invite only account.
  • Assembla – Offers a free workspace for free and public projects including ticketing system, Trac, team collaboration, wikis, time tracking and more. Assembla is much more than just project hosting, they offer a team management system where the cost is determined by the number of users. Assembla also offers Git and Mercurial as source control options.
  • Dreamhost – Offers unlimited SVN repos for web hosting account holders. SVN is an old version 1.43 which lacks merging. Setup instructions can be found here.

The Free and Open Source Contenders:

  • SourceForge – Everyone knows what SourceForge is. Free for Open Source projects, offers source control, basic project pages including issue tracking and crappy discussion forums,
  • Codeplex- Microsofts Open Source project hosting community. If you have an Open Source Windows related project you can host it on Codeplex which provides source control, issue tracking, and discussion forums.
  • Google Code - If you have an Open Source project and want a little more than just source control you can get a Google Code workspace. The Google Code account is free and includes SVN, a wiki and issue tracking as well as a basic public project page.

Let me know of any others in the comments and I will add them.

*Prices and information accurate as of February 2009.

The beautiful phrase “Man, I am an idiot…”

Code — Tags: — Mark @ 9:49 pm

How often do you have “Man, I am an idiot” moments? Forgetting to pay a bill on time, saying something stupid and regretting it immediately after, or chopping the tip of your finger off cutting red peppers? Yeah, gross… Well if I did either of those things I dont think I would be too happy but in the programming world ”Man, I am an idiot” is one of the things I like to hear most…

Today my team and I were plugging away, coding up a storm. We have some upcoming deadlines so we are all in crunch mode. The problem is that if I have done a ton of work that is all on a  related task, I begin to make stupid errors. I dont know if that is normal but I need to mix up my tasks. A little of programming, a little of building gui forms, database work or whatever else needs to be done.

Anyways, what got me thinking about this is that today I had to give a hand to two friends that were having problems that they couldn’t figure out in their code. It never hurts to have someone else take a glace at your simple mistakes, the same two friends helped me figure out a problem in 5 minutes that stumped me for an hour. So for each friend, I go over, looking over their shoulder as we step through the program. I offer some advice or suggestions where I think the bug may be hiding and leave them to get it. Lo and behold, after 5-10 minutes after I left each of them I hear one of my favourite programming phrases: “Man, I am an idiot.” 

I am not saying I found their problem but sometimes when we explain our code to other we read parts of it that you think are 100% fine and wouldnt think to check it yourself. I myself have yelled many a “Man, I am an idiot” to whoever is in earshot when I have a eureka moment. I love the feeling of overcoming a seemingly insurmountable error in ones software that turns out to be something a new programmer could spot. So today was a good day, alot was accomplished and issues were resolved. I hope to have more “Man, I am an idiot” moments soon as there are still alot of bugs :)

What is your best ”Man, I am an idiot” moment?

P.S. The errors in the software I believe were that a regular expression wasnt being matched properly because of a missing escape character and the other had a simple SubSonic/SQL query problem.

Log4net app.config with console and file logging

Code,Final University Project — Mark @ 6:31 pm

Here is a quick example .config of log4net that does basic logging to the console and to a text file. I found a great tutorial outlining the config here but it didnt have a full example anywhere from what I found. (more…)

Get Adobe Flash playerPlugin by wpburn.com wordpress themes
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2012 Mark Stahler – Blog | powered by WordPress with Barecity