Server move and software update

As of today (September 20th 2009), corsix.org has moved server. It used to be hosted over at www.ecwhost.com, who I was very happy with up until recently, whereas now it is hosted on its own virtual private server. While I was moving server, I also updated Drupal (the software which runs this site) to the latest available version.

Hopefully, you won't notice any visible differences from this change. If you do, then leave a comment or drop me email at [email protected] (or, if my new DNS servers are also failing to serve MX records, [email protected]).

Theme Hospital

For the past two months or so, one of my side projects has been writing an open source clone of Theme Hospital. I recall Theme Hospital as being one of the great classic games I had when I was younger, and it's sad to watch it slowly become harder and harder to play on modern operating systems, with modern hardware, and with modern conveniences (like 3-button mice, screen resolutions larger than 640x480, and so on). A game like Theme Hospital really deserves a decent open source clone, and so I thought I'd have a stab at making one.

You can find downloads, source code, an issue tracker, etc. over at Google Code if you're interested.

Code Signing Certificates for Individuals

Recently I undertook a hunt for a certificate authority which would issue Windows Authenticate code signing certificates to private individuals. There are lots of certificate authorities which issue code signing certificates, but almost all of them only issue them to businesses / organisations. Despite that bleak outlook, I believe that I've found a CA which does issue code signing certificates to individuals: Trustwave SSL.

Unfortunately, their certificates come at the rather expensive price of ~200 GBP per year. This is a shame, as I can't really justify £200 per year for something which I don't strictly need. Had they been asking for something closer to GoDaddy's ~120 GBP per year, I might well have purchased one, but students can only stretch so far.

If you happen to be in the market for a Windows code signing certificate for an individual, then Trustwave might be able to help you. If you do try and get one, or find another CA which issues them to individuals, then let me know (via comments or email).

Ribbon (Summer of Code)

As some of you may know, this summer I've been participating in the Google Summer of Code, creating ribbon controls for wxWidgets.

First of all, some Windows screenshots showing how things "collapse" as the ribbon width decreases:






In the above screenshot, the width is so small that some of the panels have "minimised", at which point the user can expand them when they want to use them:

At even smaller resolutions, scroll buttons are used:

The above screenshots contain the wxRibbonToolBar (on the left-most panel) and wxRibbonButtonBar (on the middle two panels). The other interesting widget is wxRibbonGallery (on the right two panels):

All of the ribbon controls are custom painted, allowing the colour scheme to be radically changed at runtime:



As well as mere colour changes, the entire art provider can be changed. All of the above screenshots are using the MSW art provider, which is based on the art style used in Microsoft Office. An alternative to that is the AUI art provider, which is based on the art style of wxAUI:

Like the MSW provider, the AUI provider can also adopt other colour schemes:

While the preferred state is to have the ribbon at the top of the window, it can also be positioned on the left:





One of wxWidget's strengths is in being cross platform. As such, a batch of screenshots wouldn't be complete without some Linux screenshots:





The MSW art style can still be used on Linux, as shown:

Obfuscated Lua

I like Lua as a programming language for its beauty and simplicity, but sometimes you have to defile a language with horribly obfuscated code:

     L=           {}           for          k,v
     in          next          ,_G          ._G
     do          L[#k          ]=v          end
    L[10        ](([[p        =prin        t;for
   'q=99,      1,-1'do'      gg'q>1'      th{n'p(
  q.."'Bs'    {f'!:::'{n    'th{'<114    ,'"..q.."
 'Bs'of'!::  [.")gg'q>2't  h{n's=(q-1)  .."'Bs'{f'[
 !::'{n'th{  '<!+$."{lse'  s="1'B'{f'$  !::'{n'th{'
 <onx."{nd;  elsegg'q==1'  then'p"1'B'  {f'x!::'{n'
 th{'wall,'  1'B'of'[!::.  "s="no'mor{  '!::''{n'th
 e'<'!4!"en  d;p("Take'{n  {'down,'pas  s'it'around
 ,'"..s)p"-  "{nd]]):gsub  ("["..[==[$  4[]==]..[[x
 ]].."]",""  ):gsub([[B]]  ,"bottle"):  gsub("''?",
 " "):gsub(  "!:+","beer"  ):gsub("gg"  ,"if"):rep(
 3-2):gsub(  "<..","wall"  ):gsub("{",  function(_)
 B=((B)or(3  ))+1;return(  "eooe"):sub  (B%4+1,(B+1
 +2+9)%4+(#  L[1]-13),(B*  2)%7)end))(  L[#L]or...)

Despite what it looks like, it is valid Lua 5.1 code. If it isn't immediately obvious what it does, then you can see the output.

The overall form of the code is loadstring(([[code]]):decrypt())(). Of course, putting a straight loadstring call into the code would make things obvious (and it would break the nice formatting). Hence there is this lovely piece of code instead:

L = {}
for key, value in pairs(_G) do
  L[#key] = value
end
-- L[10] is now loadstring (and L[1] is L)

This relies on the fact that loadstring is the only global variable whose name is 10 characters long:

LengthGlobals
1L
2_G os
4load math type next
5debug error pairs pcall print table
6dofile ipairs module rawget rawset select string unpack xpcall
7getfenv package require setfenv
8_VERSION loadfile newproxy tostring
9coroutine
10loadstring
12getmetatable setmetatable
14collectgarbage
Next comes a long string containing the true program code (although not in plaintext), and then after it come a number of calls to string.gsub to turn the string back into valid Lua code. The calls to gsub are:
PatternReplacement
[$4[x%s](nothing)
Bbottle
''?(space)
!:+beer
ggif
<..wall
{
function()
  B = (B or 3) + 1
  return ("eooe"):sub((B % 4) + 1, (B % 4) + 1)
end

After all of these replacements, the code that gets send to loadstring is: (linebreaks and indentation added for clarity)

p=print;
for q=99,1,-1 do
  if q>1 then
    p(q.." bottles of beer on the wall, "..q.." bottles of beer.")
    if q>2 then
      s=(q-1).." bottles of beer on the wall."
    else
      s="1 bottle of beer on the wall."
    end;
  elseif q==1 then
    p"1 bottle of beer on the wall, 1 bottle of beer."
    s="no more beer on the wall!"
  end;
  p("Take one down, pass it around, "..s)
  p"-"
end

This code is loaded, and then executed, and the result is (obviously) the 99 bottles of beer song.

page: 16 17 18 19 20