Author Archives: timwarnock

Extremely Large Numeric Bases with Unicode

Previously, we discussed using Punycode for non-ASCII domain names with internationalized URLs, e.g., https://去.cc/叼 I would like to use this approach to create a URL Shortening Service, where we can create shortened URLs that use UTF-8 characters in addition to … Continue reading

Posted in python

PseudoForm, a Bot-resistant Web Form

I would like to create an HTML form that is resistant to bots. This could be a classic comment form or really any web-accessible form. In most cases, requiring authentication and an authorization service (such as OAuth) would be sufficient … Continue reading

Posted in css, html, javascript, python, software arch.

multiple git remotes

I would like to manage a project across multiple remote git repositories, specifically, a public github repository and my own private repositories. Fortunately, git supports as many remote repositories as you need. When you clone a repository, there will be … Continue reading

Posted in git

OOP or Procedural?

I would like to know when it is best to use object-oriented programming, and when it is best to use procedural programming. tl;dr: neither, go with functional programming By procedural programming, I mean the kind of code you'd find programming … Continue reading

Posted in c, java, software arch.

Trie or Set

Given a grid or input stream of characters, I would like to discover all words according to a given dictionary. This could be a dictionary of all English words or phrases (say, for an autocomplete service), or for any language. … Continue reading

Posted in data arch., python

iter_words

I would like to iterate over a stream of words, say, from STDIN or a file (or any random input stream). Typically, this is done like this, And then one can simply, For a more concrete example, let's say we … Continue reading

Posted in python

Punycode

I would like a webapp that supports UTF-8 URLs. For example, https://去.cc/叼, where both the path and the server name contain non-ASCII characters. The path /叼 can be handled easily with %-encodings, e.g., Note: this is similar to the raw … Continue reading

Posted in python, software arch.

Using getattr in Python

I would like to execute a named function on a python object by variable name. For example, let's say I'm reading in input that looks something like this: enqueue 1 enqueue 12 enqueue 5 enqueue 9 sort reverse dequeue print … Continue reading

Posted in shell tips

Graph Search

I would like to discover paths between two nodes on a graph. Let's say we have a graph that looks something like this: The graph object contains a collection of nodes and their corresponding connections. If it's a bi-directional graph, … Continue reading

Posted in python, software arch.

python unittest

I would like to setup unit tests for a python application. There are many ways to do this, including doctest and unittest, as well as 3rd-party frameworks that leverage python's unittest, such as pytest and nose. I found the plain-old … Continue reading

Posted in python

HTML + CSS + JavaScript Lessons

I would like a very simple introduction to web development, from the basics of HTML and CSS, to the proper use of JavaScript; and all without getting bogged down in complicated textbooks. I've been working with HTML, CSS, and JavaScript … Continue reading

Posted in css, html, javascript

bash histogram

I would like to generate a streamable histgram that runs in bash. Given an input stream of integers (from stdin or a file), I would like to transform each integer to that respective number of "#" up to the length … Continue reading

Posted in bash, shell tips

xmouse

I would like to remotely control my Linux desktop via an ssh connection (connected through my phone). Fortunately, we can use xdotool. I created a simple command-interpreter that maps keys to xdotool. I used standard video game controls (wasd) for … Continue reading

Posted in bash

VLC remote control

Recently I was using VLC to listen to music, as I often do, and I wanted to pause without getting out of bed. Lazy? Yes! I learned that VLC includes a slew of remote control interfaces, including a built-in web … Continue reading

Posted in shell tips

datsize, simple command line row and column count

Lately I've been working with lots of data files with fixed rows and columns, and have been finding myself doing the following a lot: Getting the row count of a file, twarnock@laptop:/var/data/ctm :) wc -l lda_out/final.gamma 3183 lda_out/final.gamma twarnock@laptop:/var/data/ctm :) … Continue reading

Posted in bash, shell tips