Roy Tang

roytang.net

Programmer, engineer, scientist, critic, gamer, dreamer, and kid-at-heart.

Blog Notes Photos Links Archives About

Subscribe: RSS JSON

2020 January

  • Flask vs Django

2019 August

  • Python: Markov Chains

    Back when I was still learning Python in 2008, one of the first "fun" scripts I wrote was a text generator using Markov chains. I'd run it against all the chat logs I had with people at work and serve the results from a webserver on my computer. THe results were often amusing and sometimes hilarious. Since I've been going through my old scripts lately, I thought I'd update that script to Python 3 (read: add parentheses around print params and use pathlib) and run it against all the posts on this here site. I added the script to my

    read more (162 words)

    Posted by under blog at #software-development #python

    Also on: twitter / 162 words

  • Devnotes: Python Pathlib

    Ever since I started learning Python back in 2008ish, I've been using it as my primary scripting language for various tasks such as processing log files, organizing my own file system, processing stuff on this blog, and so on. A lot of it is basically moving files around. In the days of Python 2, that involved a lot of imports of different libraries like os, shutil and glob. It can become a bit messy with so many imports, and I often can't remember which import I need for a particular case and end up having to search for the documentation

    read more (316 words)

2019 February

  • TriviaStorm: Text and Answer parsing

    A while back I started a Twitter trivia bot as a weekend project. That bot is still up and running on Twitter, you can check it out there! But today, I thought I'd write about the answer-checking mechanism used by the bot. It was a bit interesting to me because it was the first nontrivial use I had for Django's unit testing framework. I'm not too keen on unit testing web functionality (something I still have to learn), but this seemed an appropriate first use of a unit test framework for several reasons: the bot had to be able to

    read more (579 words)

2018 October

  • Django Blog Application

    Ten years ago this month, I started studying Django by trying to build my own blog application. I found the code lying around while I was going through some backups lately. It's way out of date, it uses an early version of django. I thought of bringing it up to speed, but that didn't seem practical. Instead, for archival purposes, I cleaned it up a bit and uploaded the code to a github repo. (Helpful github immediately warned me that having a very old version of Django was a security risk lol). There's a lot more information in the README.md

    read more (176 words)

2017 March

  • Running Python 2.x and 3.x on Windows

2017 February

  • Weekend Project: Twitter Trivia Bot

    I had been meaning to try writing a Twitter bot for a while now. I figured a trivia bot would be pretty easy to implement, so I spent some time a couple of weekends to rig one together. It's (mostly) working now, the bot is active as triviastorm on Twitter, with a supporting webapp deployed on http://trivia.roytang.net/. The bot tweets out a trivia question once every hour. It will then award points to the first five people who gave the correct answer. The bot will only recognize answers given as a direct reply to the tweet with the question, and

    read more (264 words)

2017 January

  • The Simplest Code That Can Do The Job

    So the other day I was reworking a Python script that I had been using for years on my home PC to manage and categorize some downloaded files for me. This time I wanted to add some smarter behavior to make it more able to figure out when to group files into folders without constantly needing manual intervention from me. To do this, I needed to persist some data between runs -- so that the script remembers how it categorized previous files and is able to group similar files together. Now since my software development career has largely been as

    read more (322 words)

2011 August

2010 October

2010 July

2010 June

2010 January

2009 December

2009 September

2009 April