Tag: code

Installing Fehlstart - A simple, quick application launcher

Fehlstart is an application launcher, much like Launchy, Quicksilver, or GNOME Do. However, where other launchers focus on adding features, Fehlstart is as basic as they come. If you want to search for files or control your media player, look elsewhere. Felhstart launches applications. Period.

Fehlstart isn't in any major repositories so it has to be compiled from source.

  1. Install dependencies
    • git, gcc, make, libgtk2.0-dev, libkeybinder-dev
    • On most systems these packages will be available through your package manager
  2. Get the code
    • git clone https://gitlab.com/fehlstart/fehlstart.git
  3. Compile and install
    • Navigate into the folder containing the code
    • Run make
    • Run make install (with the needed permissions)
  4. Add fehlstart to your window manager's autostart list
  5. Log out and back in to launch Fehlstart.
  6. Press the key combination <Super> + <Space> to bring up the launcher
  7. Type to search through the installed applications, then press <Enter> to launch.

Gotcha with basic HTTP authentication in Python

When doing basic HTTP authentication in Python, make sure your authentication realm is surrounded by double, NOT single quotes.

Bad:

1
2
3
self.send_response(401)
self.send_header("WWW-Authenticate", "Basic realm='/'")
self.end_headers()

Good:

1
2
3
self.send_response(401)
self.send_header("WWW-Authenticate", "Basic realm=\"/\"")
self.end_headers()

The single quotes work with most browsers, curl, wget, and tons of other tools. However, when using Python to access the page (using urllib2.HTTPPasswordMgrWithDefaultRealm to manage authentication) single quotes don't trigger the "automatic retry with authentication" response, and instead just raise a 401 HTTPError.


Vim: Search and replace in multiple files

As is the way with Vim, there are a ton of features, but stumbling on the combination of commands that does what you want can be a bit difficult sometimes. In this case, the objective is to perform a search and replace over some files.

This is done in two steps: loading up the files to process, then issuing a command to run on each of the files.

Load up the files to search using the args command. This command supports multiple arguments and can use bash-style path completion.

1
:args src/*.cpp src/*.hpp README.txt

Perform a replace using sed-style syntax using the argdo command. This command iterates over all the files loaded by the args command and performs a command on them. In this case, it's performing the replace operation.

1
:argdo %s/FindMe/ReplaceWithMe/gec | update

The flags used in this case are:

  • g: global search (find more than a single occurance per line)
  • e: suppress "string not found" error messages
  • c: confirm each replace

Running update after the replace operation saves any changes to the file before moving to the next one.

© Carey Metcalfe. Built using Pelican. Theme is subtle by Carey Metcalfe. Based on svbhack by Giulio Fidente.