Labels

3G (1) 8600GT (1) AI (4) amazon (1) API (1) apple (3) apple mail (1) atlassian (1) audio (1) bambo (1) Bamboo (1) bloat (1) boost (1) bugbear (1) C++ (5) calling conventions (1) cdecl (1) chromecast (1) CI (1) compiler (1) continuous integration (1) coursera (1) custom domain (1) debugging (1) deltanine (1) diagnosis (1) diy (5) DLL (1) dns (1) don't be evil (1) ec2 (1) education (1) electronics (1) express checkout (1) fail (6) fink (1) firewire (1) free hosting (1) GAE (1) google (1) Google App Engine (4) H170 (1) hackerx (1) hackintosh (1) Haskell (3) homebrew (2) i1394 (1) icloud (2) iOS 9 (1) ipad2 (2) jobhunting (2) lag (1) letsencrypt (2) libjpeg (1) linux (1) mac (2) mbcs (1) mechanic (1) memory (1) MFC (3) Microsoft (1) migration (1) ML (1) mobile (1) movi (1) MSBuild (1) music (1) naked domain (1) NLP (2) o2 sensor (1) obd (1) Optiplex960 (1) osx (1) outlook express (1) payments (1) paypal (1) photos (2) PIL (1) Project Euler (1) projectmix (1) python (2) raspberrypi (3) recruitment (1) renwal (1) skylake (1) soundcloud (1) ssl (2) stdcall (1) stripe (1) subaru (2) supermemo (1) supermemo anki java (1) sync (2) Telstra (1) tests (1) thunderbird (1) udacity (1) unicode (1) Uniform Cost Search (1) university (1) upgrade (2) vodafail (1) vodafone (1) VS2010 (1) vs2013 (1) VS6.0 (1) weather (1) win (1) Win32 (1) Z170 (1)

Wednesday, 11 March 2026

I bought this Behringher 1602 MX 12 channel mixer nearly 30 years ago from (now defunct) venue music on bondi rd. I recorded my first and only album on it. It was the heart of my home studio for a long time. I recently pulled it out of storage only to find the left master fader was dodgy, you had to wiggle it to get a signal and every time you wiggled it, it got a bit harder to wiggle it exactly the right way to get a sound the next time.

 

So, I decided to fix it. I have a chequered history with fixing things. Sometimes all goes well and sometimes it ends up more broken then when I started. But this seemed easy enough, just replace the fader. What could go wrong?
Lots of screws to undo and not an op amp chip to be found! It is all discrete componentry. I then discovered I am not very good at unsoldering. I should have really watched the YouTube video before resorting to drilling out the solder filled holes. Only 10 pins to remove! Then, what to replace it with? I knew the dimensions and pin geometry, but what value?
Gemini AI came to the party suggesting 10kohm logarithmic linear pots. How the hell does AI know about servicing 30 year old mixing desks? this was a ripoff of a mackie mixer, which is how behringher started, so i found some mackie mixer pots on aliexpress. They were a perfect fit.
I replaced the left slider but because it was diffent to the original the L and R faders no longer physically aligned at the same volume level which offended my sensibilities so I replaced the right fader as well. I was still shit at unsoldering and when I flipped the board over I almost accidentally cut the pins of the fader I had just installer!
I cleaned all the knobs and buttons with my ultrasonic cleaner, as well as all the rusty metal washers and bolts on the input jacks. Gave the panel a good clean, put it back together , cleaned all the knobs and sliders with electronic contact cleaner so they were no longer scratchy.
Put it all back together whilst listening to my old iPod running through each input chanel. It was working perfectly, sounding great and looking brand new. I was so proud of myself putting the knobs and buttons back on. I love fixing things! When i was almost done i realized- I LOST a bloody knob!!!! Still a qualified success though! Or so I thought.... I put the metal back chassis on, hooked it up to my speakers and began plugging in devices to the input channels. Every time i plugged something in there was a loud pop, which of course i knew wasnt right but i kept going nonetheless.
I plugged in the third channel and there was the mother of almighty pops followed by a loud buzzing and then all the channel overload red leds came on. So much for my repair…
It turns out the three voltage regulators which are bolted to the side of the mixer to use the case as a heatsink need to have their legs bent 90 degrees to attach to the board but when i did so it was more of a curve which bought the legs dangerously close to the conductive metal rear chassis.
And they had shorted!!!
The question was had i destroyed the board or not? So i had to dissassemble it again , pop down to jaycar to buy a LM7815 LM7915 and a LM317. Good old jaycar still sells this stuff! I replaced them and the mixer worked good as new! They sure are robust. Anyway, I reassembled every again and its back in place in the studio again. Happy days!

Thursday, 7 September 2017

Google App Engine... ready for prime time?

Google recently announced the availability of google cloud and google app engine in Australia. Since that's where my users are located I decided to migrate my Google App Engine application to the Australian availability zone.

Google don't make it particularly easy to do this, there is no button in the console to move your application, you must do the following manual steps:


  1. create a new application
  2. upload the code to the new application
  3. disable datastore writes on your existing application
  4. grant permissions to the bucket used to store your datastore backups so the new application can read them
  5. backup the data store of the existing application
  6. then restore the backups to the new application 
  7. then create a mapping of your custom domain to the new application
at this point, I tested my new application and I could see that google was serving the new application, so it looked like everything was working and I went to bed.

The next morning, my application was no longer working. It was configured to accept secure connections only, and when I remapped the custom domain, app engine decided to delete my certificate without telling me.

Well, that's not so bad, all I need to do is upload the ssl certificate to my new application, right?

Trouble is, app engine won't let me. Every time I try, it fails with an extremely unhelpful error message.


This seems to me to be some unexpected error in the backend, which is no surprise as the whole App Engine infrastructure is a little half baked. Turns out I had uploaded the wrong private key file, which I figured out by using a certificate checker site.



Sorry, there’s a problem. If you entered information, check it and try again. Otherwise, the problem might clear up on its own, so check back later.
Tracking Number: 6120870777002247692

Wednesday, 3 May 2017

Firewire i1394 and Skylake H170/Z170 incompatibilities

I have an old M-Audio projectmix IO audio interface - it's a nice unit with 8 inputs, 6 outputs, motorized faders and a firewire interface that's rock solid.

After upgrading my computer to a Skylake H170 chipset i7 6700 and expecting to have a screamingly fast digital audio workstation (DAW) I was extremely disappointed to discover my project mix was basically unusable - the audio was constantly crackling.

I had a cheap VIA firewire card, so I upgraded to to a new, quite expensive firewire card with a TI chipset, which are generally recommended for music apps.

But no joy, it still crackled. It turns out that TI no longer recommend the XIO2200A chip used in these cards for new applications.

After some google fu I found this thread confirming firewire issues with certain chipsets.


Anyway it turns out you need the TI chipset XIO2213B, or VIA 6315 or  LSI FW643.

I picked up a card with VIA 6315 chipset on ebay for $15 AUD shipped from china and it works perfectly with the lowest buffer size of 64 which means low latency audio.

Happy days!

Thursday, 2 March 2017

HackerX Sydney, 2nd March 2017.

If you haven't heard about it before, HackerX is an invite only networking event for software developers and companies seeking to hire.This event was held at Fishburners in Ultimo, which is a shared workspace/incubator for tech startups. It is structured like a speed dating event where each candidate gets 5 mins in front of a prospective employer.

Anyway, since my contract with my current employer is up in a few weeks, I thought I would head along and check it out, more out of curiosity than anything else.

They put on free beer, soft drinks and pizza so at the very least you get a free feed and a few drinks if not a new job. And it what other situation would it be acceptable to interview with a few beers under your belt?

After about 1/2 an hour, the event kicked off, with the company reps lined up in in two rows of tables, while the candidates queued up for their 5 minutes to shine in front of a prospective employer.

Now, 5 minutes isn't very long, so if you are serious you better have your pitch down pat and some copies of your resume to hand over. I happened to run into a friend and was having a chat and ended up on the end of the queue. I highly recommend you get yourself on the front of the queue.Why?

Well, it turns out that there wasn't enough time for every candidate who rsvped to get some face time with every company. As it turned out, the speed dating ended before about 10 of us got a chance to speak to any of the companies on the second row of tables.

 However, in spite of this I think it is quite a worthwhile event, in terms of being a really efficient way to get your resume into the hands of companies that are definitely hiring... much better than the broken method of using recruitment companies as intermediaries.

So check it out if you get the chance.

Update:

I actually got a callback from one of the hiring companies who invited me to their own group recruiting event for further interviews, unfortunately I was on holiday in  Fiji and could not attend.

Monday, 29 August 2016

Google Chromecast Video does not work without an internet connection even for locally hosted video!

Google's motto is "Don't be evil". I guess they don't think that spying on every thing you do is evil.
That's the only reason I can see why your Chromecast video needs an internet connection to function, even if all you wan't to do is cast videos stored locally on your laptop to your TV.

I recently picked up a Chromecast Video in preparation for a a weeks snow holiday at Thredbo, thinking it would be handy so the kids could watch some of their own videos on the TV in the chalet. The chalet came with WiFi internet, but the cheapskate owner must have purchased the cheapest possible internet plan with the lowest quota, because even though all the right lights on the router were lit, there was no internet access.

This caused big problems trying to setup my new Chromecast, which needs to download some updates when it is first configured. I can understand why it would need internet access for that.

But once it is setup it refuses to work without an internet connection. The only reason I can see it might need an internet connection is so that it can spy on you and report your viewing habits back to google.

I managed to get it working by creating as hotspot on my iphone, having the chromecast use that hotspot for internet access and use my laptop to connect to the chromecasts WiFi to configure it.

But that's way more complicated than it needs to be. It really should be written on the box in big letters:

REQUIRES INTERNET ACCESS!


Tuesday, 26 July 2016

Letsencrypt certificate renewal process is awful!

So, my free 90 days letsencrypt certificate is about to expire.

I tried the auto-renew feature, but it does not work in manual mode. They intend it to be run automated and unattended, but I can't do that because I want to use the certificate on google app engine.

So basically, you have to re-issue the certicate , which means updating the challenge response on your website.

Well, I did all that, and generated a new certificate.

Unfortunately it expires the same time as the certificate I want to replace... WTF?

Anyway, I cleaned out /etc/letsencrypt and tried again from scratch:



sudo ./letsencrypt-auto certonly -a manual --rsa-key-size 2048 --email webmaster@mydomain.org.au -d shop.rhubarbfood.org.au

and this time it generated me a certificate with the correct expiry date. For future reference,

fullchain.pem is the public cert that appengine wants.

The private key needs to be fixed for google app engine:

openssl rsa -inform pem \
  -in /etc/letsencrypt/live/mydomain.org.au/privkey.pem \
  -outform pem 

the output of this command can be pasted straight into the text box in the appengine certificate page.

This time I documented it so I can rmember in 90 days time when I need to renew it again!

Monday, 2 May 2016

Let's Encrypt and Google App Engine... not a match in heaven

I recently got on the SSL bandwagon for a site I manage, and bought an SSL certificate from GoDaddy for less than $10 (I can't remember exactly), but it only lasted a year.

True to form, when time came up for renewal GoDaddy wanted to charge me $100.

Top Tip: Never, ever allow GoDaddy to autorenew anything you buy from them. Because they alway jack the price up when they autorenew by default.

Anyway, I heard about LetsEncrypt, the new CA which offers SSL certificates for free.

"This must be too good to be true", I thought. And once again, I was proved right.

After much yak-shaving, (installing the prerequisites on my mac, the letsencrypt software, and the appropriate challenge/responses to prove I owned the web servers) I actually managed to sucessfully generate my certificate...

...which expires in 90 days!?!

Now the people at letsencrypt think that 90 days is a really, really long time, and any longer would be a security risk. And they say, "Hey, you should automate all your certificate issuance/renewal/web hosting malarky".

The only problem is, THERE IS NO API TO AUTOMATE UPLOADING OF YOUR CERTIFICATE TO GOOGLE APP ENGINE!!!

So, every 90 days, you will have to do it manually.


And one more thing... when I tried to upload my 4096 bit key certificate, app engine complained with an extremely generic error message. Turns out it only supports a maximum of 2048 bit keys.

Way to be cutting edge Google!

EDIT: Google App Engine has finally automated SSL certifcates issuance and renewal!!!

https://cloudplatform.googleblog.com/2017/09/introducing-managed-SSL-for-Google-App-Engine.html

Wednesday, 25 November 2015

How to move your amazon instance to another account

Did you know amazon offer 1 years free EC2 hosting on a t2.micro instance when you create an account?

Free hosting for a year! But, what happens when the year is up? Hmmm, I wonder....

You might wan't to migrate the instance to another account.

How?

1) Create an AMI image of your instance
2) Add the account id of the new account to the permissions on the instance
3) Now you can see the AMI image in the new account and deploy it.
4) make sure the security group for the instance has the required ports open
5) Create an elastic IP address and associate it with your new instance
6) You may also need to update the DNS records to point to your new elastic IP.

Voila! Another years free hosting!

Sunday, 11 October 2015

Do not install IOS9 on your iPad 2!!!

So, Apple released IOS9 with a bunch of PR hoopla about how well it was optimised for older devices.

So, I installed it thinking, well my iPad 2 is running okay, and Apple promises the new version will not make it any worse, so what the hey, lets install IOS9.

What I forgot was that I never installed IOS8 because I heard it was a dog. Now I have IOS9, and my iPad has massive, massive lag!

The onscreen keyboard has a few seconds lag before the letters appear, scrolling through the apps is glacially slow, the whole thing is sluggish- basically it is a terrible UX.

And would you believe it is impossible to downgrade any lower than IOS 8.4.

I can't believe that QA at Apple signed off on IOS9 for iPad 2 because the experience sucks.

If I was cynical, I might think this was a deliberate strategy to make perfectly usable devices useless and push people to upgrade.

So DO NOT UPGRADE TO IOS 9!


Monday, 28 September 2015

No wonder PayPal is having it's lunch eaten by Stripe...

I am currently trying to integrate paypal express checkout with an organic fruit and vegetable online shop that I manage the website for.

Wow! What a flakey experience, I can only hope that the PayPal production site is more stable than its sandbox!

First up, when I tried to create test accounts in the sandbox I kept getting mysterious "system errors". Only after much googling I discovered that this mysterious system error means that the password for the test account does not meet the password complexity rules... (hint: Password1! meets the criteria).

Then there are the random, intemittent failures when I call the express checkout apis.

And now, I find that paypal gives me an nginx 404 error when I try to launch the integrated express checkout page: https://www.sandbox.paypal.com/checkoutnow?token=blah. After a while it comes good...

This just smells of a half baked test sandbox environment. No wonder upstarts like Braintree (now bought by PayPal) and Stripe are eating paypals lunch in the payments market.

In fact, I was thinking of using Braintree integration, but there signup process was a bit onerous, asking me questions about our shops delivery and returns policy (we don't have one - people pick up their groceries each week), privacy policy, etc.

Anyway, PayPal needs to step up its game as far as developers are concerned... when you have so many issues in its test environment you have to wonder how stable the production environment is.




Tuesday, 8 September 2015

My iCloud photos library finally synced sucessfully - no thanks to Apple!

In my previous post I mentioned how iCloud photos sync killed my MacBook. It was stuck on 90 Gb of my 180 Gb for 3 months, and when I fixed the issue it did the remaining 90 Gigs in about 10 days (on optus cable 1.5 Mbs upload speed).

Basically, my problem was that a couple of photos and videos in my library were corrupted, and iCloud photo sync is rubbish and keeps getting stuck on the corrupted files, instead of just skipping them (like rsync would). But you would never know this as it doesn't give any meaningful feedback on how the sync is progressing.

I first observed the issue using the system activity montor and seeing what files and handles the cloudd process had open. I could see it repeatedly looping over the same set of photos, over and over again. When I tried opening each of these photos in the finder, one of them caused preview to crash. I deleted this file and the sync got as little bit further before gettign stuck again.

I then tried repairing my Photos libaray by holding command + option while launching Photos.

http://osxdaily.com/2015/05/21/repair-photos-library-photos-app-mac-os-x/

This obviously did something as it managed to upload a few more gigs after that before getting stuck again.
Then my macbook died due to the stress of running icloud photo sync for 3 ½ months, so I took out the HDD and plugged it into my spare windows box and installed mac os 10.10 in VMWare to continue the sync, but after a while I would get a file IO eror and VM ware would crash.

I thought it might have been a problem with the physical disk, so I ran Disk Utility, and lo and behold it found a few errors and repaired them, but VM ware would still crash after a while when accessing my photos library. I then decided to copy my photos library to a virtual disk file and see if I had any more luck.

When using the finder to drag and drop the photos library to the virtual disk file, it would copy 90 Gigs (suspiciously close to the size of the library it has managed to upload before getting stuckl) and then crash.
I then began to suspect it was a problem with my photos library, so I went to the terminal and used cp -R -v to copy my photos library. After copying 90 gigs, it failed again, but this time I could see which file inside my library caused it to fail. I tried opening the photo in the finder, but it just caused the finder to hang, so I deleted the photo, which happened to be from the same event as the corrupt photo I deleted previously, and tried to copy it again, this time using rsync -v -a instead.

rsync is much more robust, and instead of failing it skips the files then tells you at the end which files failed- the iCloud developers could learn a thing or two from rsync! In this case, it was a photo and a video, both from the same event as the previous photos I had deleted. I deleted these files and ran rsync again, and it finished super quickly as it had managed to sync all of the files in the previous run.

I set . my newly copied photos library as my system photos library, and then tuned iCloud sync back on which continued to upload with no further dramas. It may have helped that the VM was running on a quad core Q6600 processor, and not a core 2 Duo laptop becuase the icloud photo sync uses your computers CPU to convert all your photos and videos to lower resolutions, which was the cause of the thermal stress which killed my trusty 2008 MacBook Pro.

TL;DR
If you are having trouble syncing your photos library to icloud, try repairing your photos library by holding down command + option when launching Photos. If that doesn't work, try copying your photos library using rysnc to see if there are any corrupt files which could be causing the problem and delete them. It also doesn't hurt to use a computer with a lot of grunt and Apple makes it work really hard converting all your photos and videos to lower resolutions.

Good luck!

Thursday, 6 August 2015

Apple iCloud killed my trusty MacBook

Well, after a three and a half month valiant struggle to upload my 12000 photos and 1000 videos- (180 GB of data in total) to iCloud, my trusty 2008 MacBook Pro has finally died, succumbing to the video chip glitch that a lot of machines of this generation suffered from. Apparently this was due to the switch to lead free solder in the manufacturing process, and can often be fixed by reflowing the solder by heating the logic board in the oven at 200 degrees C for 10 minutes. But that will have to be for another blog post...

It nearly got there, it managed to upload about 100 GB of data, until it got stuck.... according to my calculations 180 GB at 1024 MB/sec should have only taken about 17 days to upload 24/7 - not over 3 1/2 months!

The main problem is that instead of uploading everything to the cloud, and doing the video and photo thumbnail generation in the cloud, apple uses YOUR CPU time to generate 2 versions of every photo and video in your collection at lower resolution so they can be viewed on other devices, which pegs your CPU at 100% and puts a lot of thermal strain on your computer, not to mention making it impossible to use for anything else.

When it actually gets around to uploading  the files to the cloud, it maxes out your upload which kills your ADSL download speed. It was so bad that 2 weeks in to this sorry saga I decided to upgrade to cable internet.

Then, if it encounters a corrupt photo and video in your collection, it will just stall without telling you it is stuck. But you would never know, because Apple don't give you any useful progress indicators as to how the iCloud sync is progressing- the only way really to tell is that the CPU and bandwidth usage isn't getting red-lined.

I  managed to figure this out by using the Activity monitor to see what files the cloudd process had open, and noticed that it kept looping over the same set of files. When I tried to open each of these files using finder, I found one photo that crashed preview every time. I deleted this file along with all the version on other devices and my upload progressed from being stuck at 94 GB until it got stuck again at 100 GB.

You can see all the temporary files that are used by cloudd when syncing by opening the Photos library file in the finder with "Show package contents". When icloud photo sync is enabled, there will be a subdirectory in there called private,  which contains some sqlite databases that are used to track the file sync and a whole lot of directories named AAA, AAB, AAC, AAD, etc which contain the files that cloudd seems to be uploading in batches to the cloud.

There are also 2 directories for the lower resolution videos and photos that are used by the VideoConversionService and PhotoConversionService whilst they abuse your CPU and turn your laptop into a nice little room heater. Again, you can identify which files are being converted by viewing the VideoConversionService and PhotoConversionService in the activity monitor and going to the open files and ports section.

Another top tip, which got my upload briefly unstuck for a while it to repair your photo library by launching Photos while holding down the alt option keys.

I thought I would be able to consolidate all my photos in the cloud from all my devices. I think I ended up deleting the same photo from my library about 20 times trying to clean up my camera roll, but whether I deleted it from my phone, my computer or the icloud web interface it would never get deleted from my other devices.

basically iCloud photo sync DOES NOT WORK. I'm convinced it is all a big scam to sell iCloud storage plans, that they will never have to worry about actually being used.



basically, iCloud photo sync sucks.

Friday, 19 June 2015

Atlassion Bamboo Deployment plans are half baked...

I recently noticed that Bamboo now has deployment plans for deploying build artefacts. I had already  implemented deployment as another stage in my build plan, so I thought I would try my hand at making a deployment plan.

My deployment plan is a very simple windows script that remotely installs an msi on a target machine.

But guess what?

Deployment plans (unlike build plans) have no means to specify any necessary requirements of the bamboo agents that will run the plan. In this case, it is a windows script and NEEDS TO RUN ON A WINDOWS BAMBOO AGENT!

So my deployment plan runs on any available agent, including linux agents, where it fails completely.

Deployment plans are useless if you have both windows and linux build agents. You can dedicate an agent to deployment, but then you can't use it to build anymore.

Massive fail, Atlassian!

I found a workaround: include a MSBUILD job in your deployment plan, which will force it to run only on windows machines. For the solution file, choose any random name and pass /help as argument to msbuild, which prevents it from trying to open the bogus solution file.


Thursday, 12 February 2015

My new raspberry pi 2 model b arrived!


I really should write up what I did with my other raspberry pi in my other post, like I promised...

Basically, I interfaced it to my security intercom in my apartment via a relay so I could unlock the security door with my iphone, because I lost my security key and my strata wanted to charge me $150 for a replacement.

It has since been decomissioned as I have moved house(which meant I had to buy a new key from the strata anyway... but since the strata management had changed it was only $75), but I will write it up when I get around to it (could be a while as I have noticed that I haven't posted on this blog for a looong time!)

It is currently being repurposed as a time machine for backing up my macs. Not sure what I will do with this baby - its got 1gb of ram and a quad corm arm processor. It would be nice to hook up to my stereo to stream music via airplay or squeezebox... it probably overkill for that purpose!


Thursday, 24 October 2013

Visual Studio 2013 and the arrogance of Microsoft

I have just installed the recently released Microsoft Visual Studio 2013 and the most striking thing about it seems to be the sheer arrogance of Microsoft and contempt for its customers.

It needs Windows 7 or greater to install which is fair enough - even  though my corporate desktop is still Windows XP (not for long as it goes out of support in April 2014).

No, the ridiculous thing is that VS 2013 requires you to install IE 10 before it can be installed. That's right - you have to upgrade your browser to IE10 before you can install the IDE!

This is a complete dealbreaker for many corporate environments.

Fortunately here's a workaround windows command script. VS2013 seems to work just fine with ie8 so it seems to be a marketing driven decision only.

@ECHO OFF

:IE10HACK 
REG ADD "HKLM\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer" /v Version /t REG_SZ /d "9.10.9200.16384" /f 
REG ADD "HKLM\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer" /v svcVersion /t REG_SZ /d "10.0.9200.16384" /f 
REG ADD "HKLM\SOFTWARE\Microsoft\Internet Explorer" /v Version /t REG_SZ /d "9.10.9200.16384" /f 
REG ADD "HKLM\SOFTWARE\Microsoft\Internet Explorer" /v svcVersion /t REG_SZ /d "10.0.9200.16384" /f 
GOTO EXIT

:REVERTIE 
REG DELETE "HKLM\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer" /v svcVersion 
REG DELETE "HKLM\SOFTWARE\Microsoft\Internet Explorer" /v svcVersion 
REG ADD "HKLM\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer" /v Version /t REG_SZ /d "8.0.7601.17514" /f 
REG ADD "HKLM\SOFTWARE\Microsoft\Internet Explorer" /v Version /t REG_SZ /d "8.0.7601.17514" /f 
GOTO EXIT

:EXIT

 The other act of corporate arrogance is that they have deprecated non-unicode MFC applications, with the lame excuse that the 64 Mb MFC MBCS libraries would bloat their 5.7 Gb distribution of VS2013. You can still build MBCS applications but the libraries need to be downloaded separately from here.

Porting a legacy app from mbcs to Unicode is a non-trivial task... especially if there is direct pointer manipulation that assumes 8 bit chars sprinkled through the code base. This would be a whole lot of pain for zero gain.




Friday, 18 October 2013

More than I ever wanted to know about Win32 calling conventions...

Just spent the last day trying to debug a weird bug - one of those works in Debug builds but crashes in Release builds issues in a C++ MFC application. After tweaking some compiler settings I discovered it wouldn't crash if I disabled optimizations in release mode, but rather than doing that I thought I would dig down to find the root cause.
After much setting of breakpoints and attaching the debugger I found it was crashing in a call to CString::Format() - but only subsequent to a call to a function in 3rd party DLL that was used for encryption. The origins of this DLL were long ago lost in the mists of time so unfortunately there was no documentation.
The function was called by dynamically loading the DLL and calling ::GetProcAddress() to obtain the function pointer, which had the following signature:

typedef long ( __stdcall* LPFNDLLENCRYPT)(const char *, const char *, char *);

__stdcall
is used to call most of the Win32 apis. This calling convention can generate smaller code, as the called function performs the stack cleanup code.

__cdecl calling convention relies on the caller to cleanup the stack frame, and since functions are typically called from more than one place in the code, the additional stack cleanup code bloats the code.

On a hunch, I changed the function signature to:

typedef long ( __cdecl* LPFNDLLENCRYPT)(const char *, const char *, char *);

and lo and behold - it fixed the bug!

It seems the DLL was using __cdecl calling convention and expected the caller to cleanup the stack frame, but since the function pointer incorrectly declared it as __stdcall the compiler was not generating the stack cleanup code. This left the stack in a corrupted state which caused the next call to the CString::Format function in the MFC DLL to fail. Presumably the Debug build was more resilient with respect to stack corruption.

Here's a really useful article on calling conventions on CodeProject which explains calling conventions in more detail than you would ever want to know.... unless your debugging weird bugs due to calling conventions!

I love C++!

Tuesday, 17 September 2013

MS Compiler Bloat and broken MSBuild 4.0

Windows XP goes out of support next year so my work is finally upgrading to windows 7. This has provided the impetus to port our VS6.0 project to VS2010 as VS6.0 will not install on Windows 7. The port was fairly uneventful, just a few minor fixes because C++ wasn't standardized back in 98 when VS6.0 was released, so the code would not compile without a few tweaks.

The project is fairly large and takes 30 mins to build via Atlassian Bamboo build server. Imagine my dismay when I found the VS2010 version of the project took 90 mins!!! 15 years of compiler progress and they have managed to slow it down to one third of the speed!

So, I thought.... MSBuild has support for parallel builds - lets give that a crack! Unfortunately, it failed to build. After wasting a day I found this.
Apparently MSBuild 4.0 has a bug where it doesn't respect the project dependencies, so it gets the build order wrong.
Anyway, if you are using Bamboo with VS2010, use the DEVENV.EXE task for building projects, not MSBuild - it's broken!

Tuesday, 27 August 2013

bye bye vodafail

This month I inadvertently went over my data quota on my Vodafone service and copped a bill for $210. The culprit was my 3 yo son watching Thomas videos on YouTube.

I bought a data booster pack -2Gb for $30 dollars - that's $15 per gig, but it was too late, they had already charged me at a rate of $250 per Gb!

Since I am no longer under contract I'm free to leave for a player like Boost, which is offering unlimited calls and SMS with 3Gb of data - which is twice the data allowance of my Vodafone plan for only $5 per month more, and no chance of running up an excess data bill. I called customer support, thinking they would try their best to keep a happy customer, since they have been bleeding customers since the vodafail network debacle , but no... all they did was try to upsell me on plans. I even told them I was thinking of porting out...

Anyway, the port from Vodafone to Boost took less than an hour. Bye bye vodafail!



Friday, 9 August 2013

raspberry pi prototyping kit from adafruit arrived today


I already have a project in mind - an internet connected security door buzzer so I can open the front door to my apartment block with my iphone. Stay tuned for construction details

Saturday, 23 February 2013

Making Music on an iPad

Here's a little childrens song I wrote and recorded on my iPad using GarageBand - really lo-fi, just using the internal microphone and the virtual instruments available in GarageBand for iPad. I did the final mixdown on my macbook. It's a song about breakfast!