Tag: python

  • Learn Python from Google

    Google’s Python Lessons are Awesome:

    The lovably geeky Nick Parlante — a Google employee and CS lecturer at Stanford — has written some awesomely succinct tutorials that not only tell you how you can use Python, but also how you should use Python. This makes them a fantastic resource, regardless of whether you’re just starting, or you’ve been working with Python for awhile.

    via: @seankaiser

  • Pythonista, programming on your iPhone and iPad

    Let me show you something that will make you feel young as when the world was new. — Dr. Carol Marcus

    I feel like a teenager again while playing around with Pythonista (Universal, $6.99), an app for iOS allows you to program in python directly on the device. It reminds me a lot about when I was learning to program in BASIC on my Atari 800XL (my favorite computer ever, although my iPod Touch is a close second). With Pythonista, I can finally write little apps to make my day easier. A lot nicer than going to the App store, downloading a bunch of free apps, all which have obnoxious ads and don’t do quite what I want.

    My first script was written to automate my 365 project. A project that I am terrible at keeping up, but now my DOY script will make it easier when I post once a month. I always struggle with the text I add at the end of my description for the picture, where I calculate the day of the year:

    #365 (218/365)
    

    I’d end up having to go to a website to find out what the day of the year it was. Well, at least that’s what I did in the past. Now I have written the following script and created a shortcut to it:

    # We're going to need work with dates, access to the clipboard,
    # and to launch an app (you use the webbrowser to do that).
    import datetime
    import clipboard
    import webbrowser
    
    # Figure out the day of the year
    day_of_year = datetime.datetime.now().timetuple().tm_yday
    
    # Create out tag line
    clip = " #365 (" + str(day_of_year) + "/365)"
    
    # Put it in the clipboard
    clipboard.set(clip)
    
    # Open Camera+
    webbrowser.open('cameraplus://')
    

    Camera+ has a shoot and share mode, which is what I have set as the default. So now I click on the DOY icon, Pythonista does its thing and Camera+ opens up. I take the picture, type my witty caption, and paste the tagline. Very, very cool.

    Pythonista can also export your script as an XCode project, one that you can load into XCode and create an actual iOS app. I haven’t had the chance to try that out yet. A couple of negatives. Getting scripts into Pythonista can be a lesson in patience. Due to Apple’s limitations on loading code, you cannot simply load code from your Dropbox or other sources, you have to copy and paste. This also means that scripts on your iPhone are automatically synced to your iPad. There is a Dropbox workaround, but I haven’t had the chance to try it out yet. The other negative that I’ve found so far is that there isn’t a built in user interface library, so you’re limited to text or creating your own graphics for things like buttons.

    All in all, it’s well worth the price (especially since it’s universal!).

  • Good bye WordPress, hello Pelican

    This website has undergone various transformations over the last 10 years. Looking back at the first incarnations from 2003 shows a site that reminds me a lot of current day Facebook and Twitter. An example of my words of wisdom from 2003:

    And tonight marks the end of a great TV series that it seemed like nobody was watching. Buffy the Vampire Slayer ends its seven season run with the episode “Chosen”.

    I feel that this series never got the recognition it deserved, with such great episodes like Hush and Once more with Feeling, the creator Joss Whedon was never afraid to totally change your perception of characters.

    At least Angel will be back this fall, and I’ve been buying the Buffy DVDs. The plan is to watch Season 2 this fall on Tuesday nights.

    (I now own the entire series of Buffy on DVD, just in case you were worried)

    In those days I was running Postnuke, and apparently by 2005 I had switched over to WordPress, which I had used up until last month. I have nothing against WordPress, and for a majority of users, WordPress is the way to go. For myself, I was getting tired of administrating the site more than writing and I wanted more speed without jumping through a bunch of hoops. So last month I switch to Pelican

    Pelican is a website generator written in Python. The difference between something like WordPress and Pelican is that WordPress parses each web page as a user views it while Pelican generates the site ahead of time as html pages that can be uploaded anywhere. This means I can host my website any place that supports static web pages. I’m currently using a virtual private service (VPS) to host my website. When I’m tired of administrating my VPS, I can easily switch to publishing on Amazon S3. Other options include the Public folder in Dropbox or in Google Drive.

    Another aspect of Pelican I really like is the ability to check my entire site into version control (git in my case). With version control, I can easily work on new branches of the site without disturbing the current site. And, if you’re bored, you can fork the repo of the site at Github.

    My comments were already switched over to Disqus, and I was able to mimic the same urls from WordPress in Pelican. This allowed me to use my Disqus comments as is.

    There are two pieces that I need to work on. One is to set up some way to schedule posts, and the other is a theme that’s not the default. Oh, I also need to go through all my old posts and fix the categories. WordPress allowed multiple categories per post, Pelican does not.