Author Archives: timwarnock

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

Getting the most out of your ssh config

I typically find myself with voluminous bashrc files filled with aliases and functions for connecting to specific hosts via ssh. I would like an easier way to manage the various ssh hosts, ports, and keys. I typically maintain an ssh-agent … Continue reading

Posted in shell tips, ssh

git, obliterate specific commits

I would like to obliterate a series of git commits between two points, we'll call these the START and END commits. First, determine the SHA1 for the two commits, we'll be forcefully deleting everything in between and preserving the END … Continue reading

Posted in shell tips

vim: Visual mode

I have been using vim for years and am consistently surprised at the amazing things it can do. Vim has been around longer than I have been writing code, and its predecessor (Vi) is as old as I am. Somehow … Continue reading

Posted in shell tips, vim

vim: tags and tabs

Previously, I discussed using vim and screen with automagic titles. The great part about working with vim and screen is that I can work from anywhere with minimal setup, and when working remotely I can pick up the cursor exactly … Continue reading

Posted in shell tips, vim