Skip to content

PHP 5.3 database connection problems

My database scripts were all hanging after an upgrade from PHP 5.2.8 to 5.3.1 on Windows. Turns out it’s a problem with the new MySQLnd library that doesn’t like IPv6. You need to comment out the line in C:\Windows\system32\drivers\etc\hosts that resolves ::1 to localhost.

Thanks to Corey Gilmore for documenting it; I figure the more people get it online the quicker it will be for people to find it.

The New CBC Radio 3

I often listen to CBC Radio 3 at work. Recently they updated their website; while it’s mostly a change for the better (yay, the player doesn’t stop updating!) there were a couple of things bugging me about it. With the old design, you always had access to the player and the main navigation, but now they stay at the top of the page. Not helpful when you’re scrolling through comments and whatnot.

So I wrote a Greasemonkey script that keeps the player and the left navigation bar in place. It also clears out the CBC header at the top, as well as the CBC Radio header that sits below that, for a cleaner page.

Continue reading

Building a 64-bit Firefox on the Mac

With the release of Snow Leopard, Apple is really starting to push 64-bit programs. Firefox is working towards a 64-bit release but even though the bugs are all resolved, it won’t be shipping anytime soon. Here’s what I did to build a 64-bit LLVM version of Firefox. Important warnings follow the list!

Continue reading

Working with HTTP_Request

I needed to make a bit of sample code for someone the other day, demonstrating how to log into a website and collect data programatically from PHP. The HTTP_Request PEAR class works fairly well for this; HTTP_Request2 should be a big improvement when it’s finished, as the original is geared toward PHP 4’s abysmal object model.
Continue reading

Donate!

I’ve made a few things that lots of people have found helpful over the years. A few of those people have asked for a button to click on to show their appreciation. Who am I to refuse them?



Geography Class!

Click on a county for more information.

Map of Ireland showing counties and provinces
Map of Ireland showing counties and provinces







antrim derry tyrone donegal leitrim sligo mayo fermanagh cavan monaghan down louth armagh galway roscommon meath longford westmeath dublin wicklow kildare wexford offaly clare laois carlow kilkenny tipperary waterford limerick kerry cork
Name
Antrim
Irish Name
Aontroim
Province
Ulster
County town
Antrim
Population (2002)
Name
Armagh
Irish Name
Árd Mhacha
Province
Ulster
County town
Armagh
Population (2002)
Name
Carlow
Irish Name
Ceatharlach
Province
Leinster
County town
Carlow
Population (2002)
46 014
Name
Cavan
Irish Name
Cabhán
Province
Ulster
County town
Cavan
Population (2002)
56 546
Name
Clare
Irish Name
Clár
Province
Munster
County town
Ennis
Population (2002)
103 277
Name
Cork
Irish Name
Corcaigh
Province
Munster
County town
Cork
Population (2002)
447 829
Name
Derry
Irish Name
Doire
Province
Ulster
County town
Derry
Population (2002)
Name
Donegal
Irish Name
Dún na nGall
Province
Ulster
County town
Lifford
Population (2002)
137 575
Name
Down
Irish Name
Dún
Province
Ulster
County town
Downpatrick
Population (2002)
Name
Dublin
Irish Name
Baile Átha Cliath
Province
Leinster
County town
Dublin
Population (2002)
1 122 821
Notes
County Dublin hasn’t officially existed since 1 January 1994. It is now composed of the counties Fingal in the north, Dun Laoghaire-Rathdown in the southeast, and South Dublin in the southwest.
Name
Fermanagh
Irish Name
Fir Manach
Province
Ulster
County town
Enniskillen
Population (2002)
Name
Galway
Irish Name
Gaillimh
Province
Connacht
County town
Galway
Population (2002)
209 077
Name
Kerry
Irish Name
Ciarraí
Province
Munster
County town
Tralee
Population (2002)
132 527
Name
Kildare
Irish Name
Cill Dara
Province
Leinster
County town
Naas
Population (2002)
163 944
Name
Kilkenny
Irish Name
Cill Chainnigh
Province
Leinster
County town
Kilkenny
Population (2002)
80 339
Name
Laois
Irish Name
Laois
Province
Leinster
County town
Portlaoise
Population (2002)
58 774
Name
Leitrim
Irish Name
Liatroim
Province
Connacht
County town
Carrick-on-Shannon
Population (2002)
25 799
Notes
Every census since 1841 showed a declining population, until 2002. The population increased by 742 people.
Name
Limerick
Irish Name
Luimneach
Province
Connacht
County town
Limerick
Population (2002)
175 304
Name
Longford
Irish Name
Longfort
Province
Leinster
County town
Longford
Population (2002)
31 068
Name
Louth
Irish Name
Province
Leinster
County town
Dundalk
Population (2002)
101 821
Name
Mayo
Irish Name
Maigh Eo
Province
Connacht
County town
Castlebar
Population (2002)
117 446
Name
Meath
Irish Name
Province
Leinster
County town
Trim
Population (2002)
134 005
Name
Monaghan
Irish Name
Muineacháin
Province
Ulster
County town
Monaghan
Population (2002)
52 593
Name
Offaly
Irish Name
Ua Fáilghe
Province
Leinster
County town
Tullamore
Population (2002)
63 663
Name
Roscommon
Irish Name
Ros Comán
Province
Connacht
County town
Roscommon
Population (2002)
53 774
Name
Sligo
Irish Name
Sligeach
Province
Connacht
County town
Sligo
Population (2002)
58 200
Name
Tipperary
Irish Name
Tiobraid Arainn
Province
Munster
County town
Tipperary
Population (2002)
140 131
Name
Tyrone
Irish Name
Tir Eoghain
Province
Ulster
County town
Omagh
Population (2002)
Name
Waterford
Irish Name
Port Lairge
Province
Munster
County town
Waterford
Population (2002)
101 546
Name
Westmeath
Irish Name
Iarmhí
Province
Leinster
County town
Mullingar
Population (2002)
71 858
Name
Wexford
Irish Name
Loch Garman
Province
Leinster
County town
Wexford
Population (2002)
116 596
Name
Wicklow
Irish Name
Cill Mhantáin
Province
Leinster
County town
Wicklow
Population (2002)
114 676

Living in Ireland

Or, as they call it in Irish, Éire. Brandi and I moved here in the fall of 2001, looking for a change in our lives, and hopefully some cheap travel opportunities to Europe, Africa, or maybe Iceland.
We came expecting the verdant green “emerald isle” that the tourist board spreads rumours of, but were a bit disappointed, especially by the environmental situation. The Irish people seemed to take their wonderful island for granted, dumping litter by the tonne everywhere, piping raw sewage into the seas, and vomiting on the streets every Friday and Saturday night (this with plenty of help from the British and American tourists.)
Over the last few years, these things have improved dramatically. As part of joining the EU, things like recycling and stronger environmental protection have come into law, and the government now acknowledges that alcohol is a problem in society, especially youth binge drinking. We saw many improvements in the environmental situation just in the first year we were there, such as the plastic bag levy of 15 cents and the immediate impact it had on the amount of litter.

But you can’t judge a country by its “green” cred, or I wouldn’t be much of a fan of my fellow Canadians either. There were, of course, many good things about living in Ireland, and I’d probably go live there again if I had the chance. A lot of people are very friendly. We had complete strangers offer us a room in their house when we first arrived, and were homeless and unemployed. The countryside is very beautiful, once you’re far enough away from the city. Green fields and castles and stuff, just like the tourist board says! The weather is pretty reasonable, despite what the Irish like to think. It’s a lot drier than my hometown of Vancouver, but feels a lot colder because of the ocean winds, which can produce some amazing storms. I did miss summertime though; we barely broke through 20ºC while we were there.

Finding a Job

We had the misfortune of arriving shortly after the terrorist attacks on 11 September, so Brandi wasn’t able to get a job as a travel agent, which she had been in Vancouver. And computer jobs were as scarce there as they were anywhere those days, despite all the rumours of the “Celtic tiger” economy. So after failing to find jobs in Cork, we relucantly moved to Dublin. Brandi found a job within a couple of weeks, working for AOL Europe as a billing administrator. After about a month I got a job as a box packer and paperwork filler-outer at Money Point. Fortunately I got a promotion four days later, after I was found to be one of those invaluable “computer guys.”
The most useful online resources we found for finding jobs were FÁS, the state employment agency, and irishjobs.ie. The other web sites, were largely filled with recruiting agency positions. For the most part, it seemed that recruiting agencies were just posting positions, even if they had been filled months before, just so they could get people signing up with them. The newspapers were likewise filled with a bunch of recruiting agency jobs, and not a lot of real positions.
After getting our jobs, we needed to get PPS numbers from the government. This was pretty painless, aside from the loooong wait in line with all the welfare recipients. We weren’t able to apply for this right away, because we needed proof of residency first, but the sooner you get it the better. Until you provide the number to your employer, you get taxed at the “emergency” rate, which at the time was 20% for the first month and 40% after that!

Finding a Home

Once we found jobs, we needed a place to live. We were in for a bit of a shock. In Cork, we looked at a few places, including a lovely new condo in Cobh, maybe 800 square feet, about 20 metres from the water, for €725. When looking in Dublin, most of the places were a minimum of €800 for a tiny one bedroom. Of course just over the short time we were there, rents continued to skyrocket even higher. If we had decided to go a year or two later it would have been really painful, but prices now (2009) actually seem about the same as when we were there. Anyway, we went through a property management company, because it seemed easier, and ended up paying €1100 for the two bedroom top floor of a 1960’s row house in Sutton (Bayside.) It had no insulation, so was very cold in the winter, but the furniture, carpets, and kitchen were all new, which was nice. Also, it was a 3 minute walk to either the DART station or the coast road, where we could catch the 31B into town. We could have got a cheaper place, but we wanted to be close to town and work. We had been doing hour long commutes back home, and wanted to avoid it in Ireland.
If I were moving back again, I would most definitely try to get one of the newer apartments in the IFSC district. They were a bit pricier, but it’s a 10 minute walk downtown, they’re warmer, and much more modern.


The Utilities

We had to get our own accounts with ESB (electricity), Bord Gáis (gas), and Eircom (telephone.) I don’t know if it’s the standard to have separate gas and electricity, but that’s the way our landlord had his house set up. Everything was billed bi-monthly, which also was strange to us; everything’s monthly in Canada. Prices weren’t too much higher than home, fortunately – phone was about €60, as was gas. Electricity was a bit less, maybe €50.
Most of the setup was pretty painless, but the phone was terrible. It took 9 weeks to get our phone line hooked up. And once it was hooked up, it was not very good quality. It was okay for phone calls, but our dial-up internet connections (which were free, but for the per-minute charges) were painfully slow. Eircom has reasonably priced high speed internet now, but when we were there it was just being introduced and was about €100 a month.
We didn’t have a TV for the first few months we were there, and when we did get one, we didn’t bother getting cable from NTL, Chorus, or Sky. We could pick up the four Irish channels with the antenna
(RTÉ 1 and 2, TV3, and TG4) so that was good enough for us.
Once we had some bills come in the mail, we could open a bank account. Under some very strict laws – which are supposed to prevent money laundering – we had to not only provide identification, but also a reference from a place of employment, and proof of residency in Ireland. We went with AIB just because they were next door to my wife’s job. The other big banks are Bank of Ireland, and Ulster Bank. There are also “building societies,” which are sort of like our credit unions. EBS is the big one, Permanent TSB used to be just TSB (a building society) but then they got bought, and are now a bank.

Keeping Busy

So we only got four channels on TV, our house was freezing, and we had a dodgy internet connection. As you might imagine, we didn’t hang out at home a whole lot, especially in the winter! One thing which I would recommend to any new residents is a trip to Cineworld Dublin on Parnell Street (behind ILAC Centre.) Not that the cinemas are that great (they’re not) but they have a monthly subscription. For €20 a month (we were paying €12 a month!) you can see as many movies as you like. Yes, that’s right, unlimited movies, for the price of 2 regular admissions. I don’t know if this is a normal thing in Europe, but to a North American it’s like finding the holy grail or something. And, if you plan on traveling, it’s good at dozens of Cineworld cinemas in the UK as well.
We also did a lot of walking around our neighbourhood. As I mentioned, we were only a couple of minutes walk from the coast road. A large proportion of Dublin Bay has a seawall with a bike and pedestrian path on it, which we often walked along. Sutton is situated on a thin little isthmus so we could also go north towards the DART station, and get to the sea that way. Sutton Strand was a very beautiful beach, big and sandy, with a lovely view across the water of Portmarnock and their beach (Velvet Strand.) Often we’d walk east along the beach until we got to Howth, where we could buy some fresh fish for dinner at Beshoff’s, walk around the harbour, or just watch the tourists.
Most weekends we’d go into town and do some shopping. We usually avoided shopping on Grafton Street, because of the large crowds and expensive trendy shops. We found Talbot/Henry/Mary/Earl Street (yes, it was all one street, just lots of names) had pretty much everthing we needed: Tesco, Marks and Spencer, Dunne’s (and of course “Mall Mart” – RIP) Sure it was a bit run down at the Talbot Street end, but we’ve got worse here in Vancouver. That’s not to say we never spent time on the south side of the river – I loved walking along the canal on a sunny day. St. Stephen’s Green shopping centre has a lot of stuff, and there were a lot of shops that we frequented down there. And as for shopping, there weren’t a lot of American companies with stores in Ireland; it was nice getting away from The Gap, Starbucks, Levi’s, Nike, and Sony Stores, etc. Although a lot of that’s going to change eventually. Starbucks, for example, invaded in Summer 2005; they now have 25 shops around Dublin alone.

Travel?

As for that traveling I was mentioning, we spent those first 3 weeks in Cork, visited Donegal and Belfast with Brandi’s relatives, saw Waterford and Galway with my dad, and lots of the countryside in between. I saw Wexford by myself, after Brandi had gone home, although I was shown around by one of the locals. We did get to do a bit of traveling outside Ireland while we were there, to Luxor, Egypt; Oslo, Norway; and Edinburgh, Scotland. We didn’t get away as much as we had hoped, due to the high cost of living and all the money we sent home, but it was nice paying 4 cents to go to Oslo!

The Irish Language

Introduction

The first thing I should mention is that Irish is not Gaelic. The language may be called gaelige in Irish, but in English, Gaelic is the name of a language family that includes Scots Gaelic and Manx as well as Irish.

Having got that out of the way, I can go on to say that Irish is one of the most confusing languages I’ve come across (although it doesn’t even begin to compare with Welsh.) I think it’s mostly because they use most of the standard Roman alphabet, but half the letters don’t make the same sounds they do in English, French, or any other language I know that uses the Roman alphabet. They used to have their own alphabet, similar to ours, but it fell victim to government policy in the mid-20th century. So even though I know it’s a foreign language, I can’t help but think of the English pronunciation of the letters. As I am about to explain, this is a big mistake.

Pronunciation

If you ever visit Ireland, you can amuse the locals by trying desparately to pronounce Irish words phonetically. Dublin, for example, is written Baile Áth Cliath. It is pronounced (ball’-ya ahh clee-aw’). The Irish word for prime minister is taoiseach, but is pronounced (tee’-shok). There are patterns that emerge once you’ve been exposed to it for a while, but overall it’s very confusing. I’m using very approximate pronunciations, because a) I am not a dictionary, and b) some of the sounds in Irish aren’t found in English at all. The word for the police (gardai), for example has an unusual /d/ sound. The best I can explain it is this: the same thing you do with a /t/ to make a /th/ sound – you do that to the /d/

There are 17 letters in the Irish alphabet. Vowels can have an acute accent (fada) added, and consonants can be modified by a following h. The h is not a letter, it’s just like an accent (if you think about it, the h sometimes serves this purpose in English, with ch, gh, ph, sh, and th.) It used to be represented by a dot (sí buailte) over the letter, but that was discarded when they switched over to the Roman alphabet. Here’s a rough pronunciation guide, although there are all sorts of exceptions, as with any language.

Letter Pronunciation
Broad* Slender*
a ah
á aw
b b b
bh v w
c k k
ch guttural
ch
guttural
ch
d d j
dh guttural
gh
ee
e eh
é ay
f f
fh silent silent
g g g
gh guttural
gh
ee
i i
í ee
l l l
m m m
mh w v
n n n
o aw
ó oh
p p p
ph f f
r r r
s s sh
sh h h
t t ch
th h h
u uh
ú oo

*Broad and Slender

Consonants are considered broad when surrounded by a, á, o, ó, u, or ú. They are considered slender when surrounded by e, é, i, or í. The vowels on either side of a consonant are required to be the same class, except with some foreign words.


Place Names

For anyone wanting to visit the country, here’s a list of common words that you’ll see in town names. Keep in mind many of these were anglicized during British occupation. So, for example, Dun Moíre, which originally meant “the large fort,” would be called Dunmore. (Irish is similar to French, in that adjectives usually come after the noun they are modifying.)

Irish word English adoption translation Example
baile bally town Ballymun
bun bun foot (of a river) Bunratty
carrig carrick/carrig rock Carrick-on-Suir
cill kill church Killester
cluain clon field Clontarf
dubh dub black Dublin
dún dun fort Dundrum
inis ennis/innis land Inniskillen
leitir letter hillside Letterkenny
loch loch/lough lake Glendalough
moír more big Tramore
noc knock hill Knock
rath rath fort Rathmines
trá tra beach Tramore

Common Words

Some other words you might come across…

Irish English pronunciation
Éire Ireland (air’-a)
Éireann Irish (air’-an)
fáilte/fáilte isteach welcome/welcome in (fawl’-cha)/(fawl’-cha ish’-tock)
fir men (feer)
garda/gardai a police officer/the police (gar’-da)/(gar-dee’)
iarnród railroad (ee-arn’-rod)
an lár city centre (on lar)
mná women
slán/slán abhaile goodbye (slawn)
Taoiseach prime minister (tee-shok’)
Tánaiste deputy prime minister (taw’-nish-ta)
uisce water (ish’-ka)

Names

There are some unusual names, or common names with unusual pronunciation. I’ll give the English equivalent if it sounds the same, or the pronunciation if it doesn’t.

Irish Pronunciation
Aisling (f) (ash’-ling)
Eithne (f) (et’-na)
Emer (f) (ee’-mer)
Eoin (m) Owen
Grainne (f) (grawn’-ya)
Kieran (m) (kee’-ron)
Micheál (m) (mee’-hall)
Niamh (f) (neev)
Nuala (f) (noo’-la)
Oife (f) (ee’-fah)
Oisin (m) (oh’-sheen)
Padraig (m) (por’-ig)
Ruaraidh (m) Rory
Róisín (f) (rosh’-een)
Seán (m) Shawn
Siobhán (f) (shuh-vawn’)

English Usage

The Irish have a unique way of phrasing many English constructions; often this is related to how the same phrase is used in Irish. The most noticeable example is the use of the word “after” as a verb modifier. “I’m after having seen that new film,” which would mean that the speaker has just recently seen the film. This phrasing is a literal translation from the Irish. This literal translation also results in a question such as “How long are you a teacher?” The speaker is asking how long the person has been a teacher. Fairly straightforward, but it can be confusing if you are living in Ireland and people ask, “How long are you in Ireland?” What do they mean? How long have I been here? Or how long will I be here?

Another notable construction is in responses to questions. “Will we see you tonight at the pub” could (but likely wouldn’t) be answered by “You will not.” Similarly, “Can I have a biscuit?” could be answered by, “You can of course,” or just “You can.” Some sources I’ve seen claim that this stems from a lack of words for yes and no in Irish, but my understanding is that there are such words, at least in modern Irish. Similar sounding but unrelated, if you were offered a biscuit and declined it, you could expect your polite host to insist, “You will.” (or, “You will of course.” Irish hostesses can be very insistent.) Beware! Further refusal may be met with cries of “Go on!”

Questions are often followed by the answer the speaker expects to recieve. For example, “The film was crap, yeah?”
And whereas the American use of “like” is to insert it as a placeholder in the middle of a sentence (“That was, like, so funny.”), the Irish put it at the end (“That was real funny, like.”) In both cases it is, of course, completely useless.

External Links

I find the English language to be endlessly fascinating. Likewise with others’ use of it. Here are a few pages I’ve found interesting that relate to the Irish use of English.

Delete MediaWiki pages from the database

Deleting a page from the wiki doesn’t actually remove it, just hides it away. Here’s a procedure to permanently remove things from the database, and never ever see them again.

DROP PROCEDURE IF EXISTS delete_page;
DELIMITER //
 
CREATE PROCEDURE delete_page(IN page_id_var INT)
	LANGUAGE SQL
	NOT DETERMINISTIC
	MODIFIES SQL DATA
	SQL SECURITY INVOKER
	COMMENT 'permanently deletes pages from the database'
BEGIN
	DECLARE page_title_var VARCHAR(255);
	DECLARE page_namespace_var INT;
	SELECT page_title, page_namespace INTO page_title_var, page_namespace_var FROM page WHERE page_id = page_id_var;
	DELETE FROM redirect WHERE rd_from = page_id_var;
	DELETE FROM externallinks WHERE el_from = page_id_var;
	DELETE FROM langlinks WHERE ll_from = page_id_var;
	DELETE FROM searchindex WHERE si_page = page_id_var;
	DELETE FROM page_restrictions WHERE pr_page = page_id_var;
	DELETE FROM pagelinks WHERE pl_from = page_id_var;
	DELETE FROM categorylinks WHERE cl_from = page_id_var;
	DELETE FROM templatelinks WHERE tl_from = page_id_var;
	DELETE text.* FROM text LEFT JOIN revision ON (rev_text_id = old_id) WHERE rev_page = page_id_var;
	DELETE FROM revision WHERE rev_page = page_id_var;
	DELETE FROM imagelinks WHERE il_from = page_id_var;
	DELETE FROM recentchanges WHERE rc_namespace = page_namespace_var AND rc_title = page_title_var;
	DELETE text.* FROM text LEFT JOIN archive ON (ar_text_id = old_id) WHERE ar_namespace = page_namespace_var AND ar_title = page_title_var;
	DELETE FROM archive WHERE ar_namespace = page_namespace_var AND ar_title = page_title_var;
	DELETE FROM logging WHERE log_namespace = page_namespace_var AND log_title = page_title_var;
	DELETE FROM watchlist WHERE wl_namespace = page_namespace_var AND wl_title = page_title_var;
	DELETE FROM page WHERE page_id = page_id_var LIMIT 1;
END//
 
DELIMITER ;

Now you can look up your article ID, and then call the procedure with CALL delete_page(999);.

No route matches “…” with {:method=>:get}

I configured Ruby on Rails to run with Apache, because I’m not too worried about speed and didn’t want to mess with proxies. I also configured the app to run in a subdirectory, using Apache’s Alias directive to point to the app’s public directory. I’ll point out this is the first time I’ve ever looked at Ruby in my life, and my first time working with any MVC framework, although I’ve looked into them a bit.

I was getting the dreaded No route matches "/subdirectory/" with {:method=>:get} error and it seemed pretty clear what the problem was. The app didn’t know it was in a subdirectory; I’d probably need to edit the routes to tell it so. It seems this is the last thing the people in Google-land were needing to do, but I eventually figured it out. I’d need to do something like this with the routes:

map.connect 'subdirectory/:controller/:action/:id'

So I took a look at routes.rb and it was using resources, not traditional routes. So what do I do with that?

It took hours of searching before I found the answer to my problem — a testament to the quality of Rails’ documentation I suppose. The answer is path_prefix

map.resources :groups, :path_prefix => 'subdirectory/'

You can also use it for the root as well.

map.root :controller => 'start', :path_prefix => 'subdirectory/'

Now I just have to fix the fact that the author of the app hard coded all sorts of stuff with the assumption that the app wouldn’t be in a directory. Grrr.

Update: Turns out it’s even easier than that. I didn’t have to change routes.rb at all.

config.action_controller.relative_url_root = '/subdirectory'

This has the added advantage of fixing things like linked stylesheets and stuff as well.

Configuring Unison on Windows

Unison is a free file sync utility that runs on Windows, OS X, or Linux. As with most of these things, Windows support is a bit of an afterthought, and can be tricky to work with. Here’s a step-by-step list of what I did to get it working. Note that I’m only setting things up for mirroring (ie one-way sync) so I only installed the SSH server and Unison text client on the “client” and the remainder of the stuff on the “server.” If you’re doing full 2-way sync, perform all the installations on both machines.

  1. Install GTK for Windows. I tried a couple of installers that didn’t work, but found an installer as part of this project that worked great.
  2. Install an SSH server. freeSSHd is a great little program, and it’s a tiny download. Make sure to install as a Windows service when it asks you.
  3. Configure the SSH server. Starting up the freeSSHd GUI actually tries to open another SSH server, even though you configured one to run as a service. This means that changes you make in the GUI won’t take effect until you restart the service. The only thing you’ll need to do is create a user, with password stored as SHA1 hash, that is allowed to use the shell.
  4. Configure environment variables. Unison expects to find an environment variable called HOME and will complain if it doesn’t find it. I set mine to C: and it’s happy with that.
  5. Get a fake SSH client. Unison expects that it can say ssh and something will answer. So first download PuTTY and Plink and make sure they’re in your path. Then download the Unison-ssh wrapper and make sure it’s in your path. It will redirect any calls for ssh.exe to plink.exe
  6. Put the Unison client in place. Windows binaries are available here. Rename the binaries something simple like unison-gui and unison. I suggest naming the text version unison as this is the name that Unison expects the client to have. Make sure the binaries are also in your path.
  7. Test your SSH. At this point you should be able to go to a command prompt and do this:
    ssh -l username -pw password server "unison -version"
    and get something like this:
    unison version 2.27.57
  8. Test your Unison. Assuming that worked, try testing Unison with the -testserver parameter:
    unison -testserver -sshargs "-l username -pw password" c: ssh://server//
    which should give you something like this:
    Connected [//server1/c:/ -> //server2/c:/]
  9. Set up your files. Congratulations, the servers are talking to each other! I suggest running the next step in the GUI, as there may be a lot of initial file syncing to be done:
    unison-gui -sshargs "-l username -pw password" c:directory ssh://server//directory
    It’s pretty self-explanatory, arrows point in the direction of updates, click “Go” when you’ve got it set up how you want it.

After the initial setup, you can continue using the GUI, or start using the text mode. There are a number of preferences that make things easier, which you can learn about in the documentation. As I mentioned, I’m using this for mirroring, so I use the -force parameter to make sure the “server” always takes priority over the “client.”

Creating a FreePBX module

The process of creating a module for FreePBX is, in theory, documented in a number of wiki pages, but these are worse than nothing. Full of outdated information — some of it labeled as such, some of it not — as well as broken links and vague promises of information “to be determined,” this collection of pages does more harm than good. Here, then, are some pointers to get a module working, presented as a list of files you need to have in your module’s directory.

module.xml
One of the few well documented pages in the wiki, this determines how the module is displayed within the FreePBX menu structure, as well as information on version, change logs, etc. that will be displayed in the module administration page.
install.php
Any code that needs to be executed when the module is installed should be placed here. This includes database setup; the wiki will tell you that install.sql fulfills this purpose, but it doesn’t. Within this file you have access to the $db object, which is a PEAR::DB object. Note that this file gets executed during upgrades as well. So for example if you add a column to an existing FreePBX database table, make sure to catch any errors that might happen if the column already exists from a previous install.
uninstall.php
Similarly, this file is used to clean up after the module is uninstalled. Again, uninstall.sql is not processed properly so all database cleanup should be in this file.
functions.inc.php
This file is necessary if you want to interact with other FreePBX modules; for example, to add a drop-down box while editing an extension. How is this done? During the initialisation stage of the page, before anything is output, config.php runs through the list of installed modules and includes all their functions.inc.php files. It then checks for a function called modulename_configpageinit and executes it if found.
Within this function you can call addguifunc to specify a function to be run when the page displays, and addprocessfunc for one that is run after the page has been submitted for changes. The simple act of adding a drop-down box to a page requires you to prepare a list of items at the initialisation stage (using addoptlist and addoptlistitem) and then refer to that list during page output in your GUI function to actually output the drop-down box (using the gui_selectbox object.) To save the value, your process function is called, and you are given the chance to do what you like with the POST request.
page.modulename.php
This is one of the many things in the wiki marked as “deprecated” with no mention of what replaces it. So I’ve continued to use it for the module’s own page. Unlike other modules’ pages, when you’re creating your own module’s page it is largely included as-is, meaning you can write it like most any PHP page. If you want to do anything “AJAX” in your pages, you’ll need to exit from the page when you return an XML or JSON value; this will prevent FreePBX from tacking it’s own stuff onto the output.

WMI error 80041010 on performance counters

I recently was having problems with my WMI queries. Following some (bad) advice I rebuilt the repository. It didn’t solve my problem, and afterwards all the performance counter classes had disappeared. Win32_PerfRawData_* and Win32_PerfFormattedData_* were gone, reporting error 0x80041010 [“Invalid class”] (Instead of an error 0x80041010, MS says you might get error 0x80041002 [“Object could not be found”] or error 0x80041006 [“Insufficient memory”] when trying to connect to a nonexistent class.) All the rebuilding and troubleshooting and searching MOF files gave me nothing.

The answer? winmgmt /resyncperf rebuilds the performance counter classes in the repository. To be extra safe, winmgmt /clearadap clears the old data first.

Continue reading

ATT00000.txt files in Outlook

This information is for people who create email messages in programming languages, not Outlook users.

The separator (defined in the Content-Type header) is used to start a new part of the multipart MIME message. Standard practice (not sure if it’s RFC behaviour or not) is to place an instance of the separator at the end of the message. Outlook sees this as the start of a new attachment. Because it has no Content-Disposition information it names it automatically, and of course there’s no content so it’s an empty file. So by not placing the separator at the end of the message, you avoid the empty attachment.

Searching for the answer today I have seen loads of people asking about this online, nobody came up with an answer. Part of the problem is the frequency with which Outlook generates these ATT*.txt files; some people were seeing their attachments replaced with these empty text files, some were getting blank email bodies, but with attachments and the empty text files, etc.

This just came to me after spending the day trying to figure it out, and it works. The logic of the first paragraph is entirely guesswork on my part.

Quotes

It sometimes seems that Einstein was the point at which physics broke away from common sense.

Jad Abumrad, Radiolab

They show [Hitchcock’s The Lady Vanishes] very often in Paris; sometimes I see it twice in one week. Since I know it by heart, I tell myself each time that I’m going to ignore the plot, to examine the train and see if it’s really moving, or to look at the transparencies, or to study the camera movements inside the compartments. But each time I become so absorbed by the characters and the story that I’ve yet to figure out the mechanics of that film.

François Truffaut