Scripting My Setup

Posted August 30th, 2009 in General by ryan

I’ve had the occasion to setup new Ubuntu environments several times over the last couple of months and out of laziness I created a simple script to install easy_install, pip, virtualenv, virtualenvwrapper and fabric.  I’m no bash ninja, but this script makes it quick and easy for me to install the python tools I need to play.  Sharing this with you is only half of my motivation; I’m also putting this here for someday when I forget it…

#!/bin/bash
 
#prerequisites
echo ensuring buid-essential and required dev headers are installed
sudo aptitude install build-essential python2.5-dev python2.6-dev
 
#easy_install
echo installing easy_install
mkdir ~/tmp_sources
cd tmp_sources
wget http://peak.telecommunity.com/dist/ez_setup.py
sudo python ez_setup.py
rm -rf ez_setup.py
 
#pip
echo installing pip
sudo easy_install pip
 
#fabric
echo installing fabric
sudo pip install fabric
 
#virtualenv
echo installing virtualenv
sudo pip install virtualenv
sudo pip install virtualenvwrapper
 
#clean up
rm -rf ~/tmp_sources
echo all done!
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Linux Use #257 – Baby Rocker

Posted August 27th, 2009 in General by ryan

I absolutely love this video of using a shell script, string, and cd-rom to gently rock a baby…nice.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

I’ve Just Gone Mobile!

Posted August 7th, 2009 in General, iPhone by ryan

I now have the WPtouch plugin for WordPress that has an optimized layout for mobile devices.  Makes the site way more readable within my iPhone, so I hope to not put off mobile readers any more!

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Changing Gears, Changing Venues, Changing Jobs

Posted June 20th, 2009 in General by ryan

So I haven’t written in a while and it’s mostly due to a move 3,000 miles to take a new job in North Carolina.  The job is with a government contractor doing work very similar to a job I had worked in the past – although I’m not required to do it in a tent any more.

The job is a big change for me.  Leaving Ventyx, where I wrote mostly Windows client software using WPF, WCF and working with a large group of very experienced developers has now changed to a smaller, younger shop writing ASP.Net applications in a restrictive environment.  My new role has me working more on integrating coding standards, testing practices, security practices & pen testing, etc.  The new role should bring some new thoughts and subsequently new content here.

So as things settle down over here, the plan is to continue to spend some more time writing out some of my ideas here.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Spring Is Here In Sacramento

Posted March 13th, 2009 in General by ryan

Yesterday I decided to go to lunch.  Alone.  On Purpose.  It’s not that I’m anti-social.  I’m probably less anti-social than the majority of developers I have worked with.  I have been working in my cubicle during lunch trying to complete some tasks I’ve been assigned, but I’ve started feeling like I never leave my desk.  I had already worked through most of lunch when I had decided to go, so I was about an hour after the lunch rush.

So I took a break.  I walked to a deli hidden away in the middle of a few office buildings down the street.  The “Secret Deli” as we refer to it at work.  I ordered a roast beef and cheddar sandwich on a garlic roll with every vegetable on the menu and a Snapple raspberry tea.  I grabbed a Sacramento News & Review, a local newspaper-ish publication and took a seat outside.  The newspaper grabbed my attention with an article on the front page “Why Twitter Sucks”, but that’s a topic for another post.

I picked a seat outside underneath a tree, next to a water fountain that resembles a small waterfall.  The sun was bright enough to keep me warm and so I sat there eating and reading, oblivious to the world around me.  It was awesome for me to feel like I could focus on enjoying lunch.

After I finished eating, I sat underneath the tree watching the pear blossoms fall in the wind into the fountain.  The foliage around the fountain is a vibrant green, like #234F32.  It made me think about the time we spend in cubicles, surrounded by dim walls.  The weight we assume onto our shoulders when we step into this small square of solitary confinement is too great if we isolate ourselves from brain stimulation you may find in the environment around you.

I’m going to start forcing myself out of the cube more and focus on “thinking out of the box”, literally.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Microsoft Virtual PC 2007: FAIL!

Posted February 18th, 2009 in General, Microsoft by ryan

Yesterday I had a need to create a virtual image of Windows XP Pro to do some testing against a USB device.  I downloaded and installed Virtual PC 2007 and created a guest running XP Pro.  I plugged in the USB device and nothing happened.  After a quick web search I was able to confirm that Virtual PC has no USB support.

I then downloaded the trial of VMWare Workstation.  Installing XP Pro was a much easier, simple and faster experience than installing it in Virtual PC.  USB support is built in and very intuitive.

Does anyone know if Microsoft is still working to innovate with Virtual PC or have they conceeded to VMWare?  I know which one I’m using from now on….

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Learning About Django Templates

Posted January 21st, 2009 in Django, General by ryan

I was working on a template last night to handle a generic view. I started by going into the console (managey.py shell) to poke around at the model I wanted to use. From that session, I copied the following snippet to use in the template.

project.projectimage_set.all()[0].image.url

I added this to the template and it looked like this.

{% for project in object_list %}
<div class="project">
   <div class="project-image">
      <img src="{{ project.projectimage_set.all()[0].image.url }}" alt="" />
   </div>
   <div class="project-info">
      {{ project.name }}
      {{ project.link|urlize }}
      {{ project.description }}
   </div>
</div>
{% endfor %}

When running the template I received the error: “Could not parse the remainder: (0)”. I hadn’t seen this before and searched Google to get the answer. It didn’t look good on the first search. The answer was repeated in different results, originating from a Google group. The answer given (and I’m paraphrasing) was “Django templates don’t use Python code. You’re doing it wrong. Go write a template tag or custom method.” I read through the link a few times and couldn’t find the answer I wanted to hear. I figured this was common, and I thought a web framework for people with deadlines would not require me to write too much code to get to a property.

I went back to the documentation and looked around and still didn’t find anything that showed me how to access the properties further down on the related model so I went back to Google. This time I found an answer!

I’m not going to put on like I know what’s going on here. I can think about how somewhere underneath in the template language there’s an implementation of __getattr__, but I didn’t go and research it. It’s almost 0200 and sleep is calling. Because it was difficult for me to find, I thought I would just post this and maybe it would help the next guy stumble upon removing the () and [ ].

Here is the working code:

{% for project in object_list %}
<div class="project">
   <div class="project-image">
      <img src="{{ project.projectimage_set.all.0.image.url }}" alt="" />
   </div>
   <div class="project-info">
      {{ project.name }}
      {{ project.link|urlize }}
      {{ project.description }}
   </div>
</div>
{% endfor %}
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Sample Project Ideas

Posted January 8th, 2009 in General by ryan

A few years ago I found a list on the internet of 10 things to do when learning a new programming language.   I thought it was interesting and shared it with my coworkers at the time.  A couple of weeks ago, one of my former coworkers contacted me and asked me for the list.  The site has since disappeared and I could not find the same information, but by coincidence I saw a link in an RSS feed recently for a similar idea.  The list is titled Martyr2′S Mega Project Ideas List! and it contains 150 different project ideas organized into 10 categories. 

A sample of the ideas includes:

  • Find PI to the Nth Digit
  • Fibonacci Sequence
  • Distance Between Two Cities
  • Dijkstra’s Algorithm
  • Pig Latin
  • Post it Notes Program
  • CD Key Generator
  • FTP Program 
  • Packet Sniffer
  • Small Web Server
  • Web Bot
  • Bank Account Manager
  • Vending Machine
  • Family Tree Creator 
  • Quiz Maker
  • Image Map Generator
  • Traffic Light Application
  • Hangman
  • Magic 8 Ball
  • BlackJack (and several other card games)
There are many more great ideas and maybe these will give you something to use next time you want to explore a new language.
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Debugging IronPython In Visual Studio

Posted December 30th, 2008 in .Net, General, Microsoft, Python by ryan

I’ve been getting to know IronPython a little lately and one of the first things I wanted to know was how to debug IronPython in an IDE.  Since I use Visual Studio 2008 at work, I thought it would be a good start.  I searched Google and found a text representation of the steps involved over at Harry Pierson’s blog.

I found it pretty simple to do and somewhat useful for longer scripts.  It will be nice in the future to have first class support for IronPython in Visual Studio 2010.

You should have IronPython 2.0 Final and Visual Studio 2008 Professional or Better* installed to complete this demo.

Create a python file to debug:

1
2
3
4
5
6
7
8
#debug.py
class Foo:
def __init__(self, name=None):
    self.name = name
 
if __name__ == "__main__":
    f = Foo("LVS")
    print f.name

From Visual Studio, open the IronPython executable (ipy.exe). If it doesn’t do so for you, add the ipy.exe as an existing project.

From the Solution Explorer, right-click on Properties and set the Command Arguments property.  Use “-D” to tell ipy.exe to create debugging output, “-i” to start an interactive session at the end of debugging and add the full path to the script you made before.

Properties Dialog

Properties Dialog

Click Ok.

Open the script you created earlier in Visual Studio and place breakpoints as desired.

Adding a Breakpoint

Adding a Breakpoint

Run the script in debug mode (F5).

If you added the “-i” argument in step 3, after the last breakpoint is released it will launch an interactive session for you.  You will be able to inspect your script at this point, much like the immediate window in Visual Studio.

Interactive Console

Interactive Console

* I tried this in the Visual Studio 2008 Team Developer Edition and the Visual Studio Express Edition.  The Express Editions do not work as they don’t allow you to open the ipy.exe as a solution item. Sorry “hobbyists”, we’ll see if the Express sku’s of Visual Studio 2010 will target IronPython / IronRuby.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

CodeWeaver Cross Over Pro ~ Free Today Only

Posted October 28th, 2008 in Blogs I Read, General, Linux by ryan

I caught this scoop from Nolan’s blog this morning…

The company that makes the commercial version of WINE that allows you to install windows apps natively on mac or linux is giving their product away for free for 24 hours.  Here’s an article explaining it at length:

And here is the site to get the serial # and product.


[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
FireStats icon Powered by FireStats