Fixing Prosody SSL after upgrade to Debian Jessie

April 15th, 2016

When I upgraded my home server from Debian 7 (wheezy) to 8 (jessie), my installation of the Prosody Jabber chat server broke. Specifically, my chat client would no longer connect, saying SSL was not supported on the server, and prosody complained about SSL support not being available whenever I ran prosodyctl. First I'll show the diagnostic information, then the fix and explanation (spoiler: downgrade lua-socket!), then the new diagnostic output.

Read full entry »

Fixing WordPress redirect loops and insecure links under HTTPS

March 9th, 2016

I tried to switch my blog over to HTTPS and encountered two problems:

  • My stylesheet broke because get_stylesheet_uri() (and other links) were yielding http:// links, which were blocked by the browser
  • Attempting to log in would produce a redirect loop

This was in spite of my database and config files *all* having https URLs, not http. Mysterious and upsetting.

The problem turned out to be that (as far as I can tell) my blog is run on a server behind an SSL-terminating proxy that speaks HTTP to the server. WordPress's is_ssl() function checks the value of $_SERVER['HTTPS'] to see if it is being accessed via HTTPS. WP then (apparently) writes URLs to match this instead of using the literal base URL (this seems stupid) and also generates redirects to try to match the base URL. Both of these cause the observed breakage.

My fix was to add $_SERVER['HTTPS'] = 'on' to my wp-config.

Misbalanced parens + hoisted defn = surprising runtime error in Clojure code

January 15th, 2011

Today I ran into a frustrating syntax pitfall in Clojure, which I am attempting to learn using a simple homework assignment as motivation. Below is a simplified testcase containing the same mistake I had in my actual code. The code compiles, but at runtime I receive "java.lang.IllegalStateException: Var selfr is unbound.".

(defn magic []
  (println "magic happens") ; one too few closing parens

(defn selfr [i]
  (if (< i 0)
    [(selfr (dec i))
     (selfr (dec i))]))) ; one too many closing parens

(defn selfr-caller []
  (selfr 3))

(defn -main [& args]
;  (magic) ; uncomment to make everything work
  (println (selfr-caller)))

If you stare at the code for a bit, you'll see that selfr is defined inside the magic function. So why doesn't the compiler complain that selfr-caller can't see it? What I didn't realize until today (with the help of some wonderful people on IRC) was that defn hoists the declaration to the top-level, where everything can see it... but the assignment won't occur until the code block is actually run.

This kind of bug is extraordinarily tricky to find, since it is ultimately a syntax error but may not show symptoms depending on the execution order of the code. I suppose this could have been prevented by having a better editor, such as one with draconian indentation support (e.g. Emacs) or perhaps a matching-paren highlighting feature.

Tone down your system beep

August 9th, 2009

The "system beep" (or "system bell") can be quite annoying. Instead of disabling it altogether, you may be able to change it to something a little less irritating. Some operating systems will allow you to change it to a visual alert or a sound file of your choice. Today, I'll show you how to change the duration, pitch, and volume to something less grating if you're using X.Org (applies to just about all Unix or GNU/Linux systems.) [via]

I use xset, a command that can set various preferences in the current X display. One of the parameter sets is b, the properties of the system bell. It can be used to set the relative volume, pitch, and duration. Here's an example:

xset b 50 700 5

That example sets the system bell to 50% volume, a pitch of 700 hertz, and a duration of 5 milliseconds.

Experiment by entering that command, then pressing [Backspace] on the next line of your terminal (to generate a system bell.) Your hardware may not support certain combinations, in which the bell is silent.

To have this setting take effect every time you log in, add it to your session startup commands. In Ubuntu, that's System :: Preferences :: Sessions.

GWT, standard library, and IncompatibleRemoteServiceException

July 15th, 2009

The GWT is a set of programs that allows developers to write Java code and compile it down into Javascript to be run on browsers. This requires you to use the subset of Java that the toolkit can emulate, but the compile-time and runtime error messages it displays are often not very useful.

I was developing a GWT application with Eclipse and ran into a client-server communication issue that manifested at runtime. The client would request an object from the server, the object would properly serialize and deserialize (verified by JS debugger), and then GWT's glue code would throw IncompatibleRemoteServiceException (saying "This application is out of date, please click the refresh button on your browser.")

Read full entry »