Roy Tang

roytang.net

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

Blog Notes Photos Links Archives About

Subscribe: RSS JSON

2019 November

  • DevNotes: Python's yield

    I've been using Python for well over 10 years, and I still don't have an intuitive mastery of one of its keywords: yield. Everytime I see it in someone's code I need to stop and mentally remind myself what it does. I figured I'd write a devnote to help improve my recall. Typically, yield is used in a function with a loop, like so: def some_func(lim): for i in range(0, lim): yield i yield means the function returns a "generator" that can be used as an iterable in a loop: for val in some_func(5): print(val) You can also straight up

    read more (172 words)

2019 August

  • 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)

  • Devnotes: Migrating Mercurial to Git

    Big news in online repositories this week is that Bitbucket is sunsetting support for Mercurial! This might be the death knell for Mercurial, although Git was already the super popular choice before. Back when I started using online source control for my personal coding projects I started out with Bitbucket over Github because they offered unlimited private repos and Mercurial (which I had already tried out before at work, so at first I preferred it over git). Now that Gitlab and Github both offer unlimited private repos, there's no reason to stick with Bitbucket either. I had already migrated most

    read more (279 words)

  • I recently found myself doing a really small project as sort of a proof of concept/demo for a potential client. It often seems that it might be a waste of time to do something like this since you don't know if the project will actually push through or maybe the client will want something else. To kind of hedge my bets a bit, I decided to take the opportunity to try out some new technologies so that no matter what I at least learned something from all of this. (What is life if not learning?) Django Rest Framework. I've been

    read more (750 words)

  • I decided to start doing small "devnotes" on developer stuff I'm doing so I can refer to them later (and also because I feel like I could use more technical content on this blog) Today is about PostgreSQL. I haven't used it much beyond standard ANSI sql stuff. You won't always have a graphical interface to access your database, sometimes you need to ssh to prod and query the database from the shell. The command line for PostgreSQL is psql. You can do: psql [database-user-name] -d [database-name] and it should prompt you for your password. But when I tried this

    read more (317 words)

    Posted by under blog at #devnotes #software-development

    Also on: twitter / 317 words