How to convert XML into a class the easy way!
An on-the-side project, that's been going for quite a while now, extracts data from a remote service. For a very long time, this was done via reverse-engineered Java code, of which I then wrapped my own console app around. All worked very well until they changed the login service request format and stopped using the Java altogether.
The new version was just HTML and json and, but the actual payload of the data I cared about was XML. Yes, that's right, XML in a string via JSON. Who would'da thunk? Regardless of the insanity, I was still itching to parse it.
So, the usual Json to C# class generator was used to build the de-serialisable class for the initial packet. I then needed a quick and smart way to convert the XML into a class.
Turns out that there is also an XML to C# converter! Paste in your XML blob and, if correctly formatted, it'll return a class that the XML can be de-serialised into!
And, it worked perfectly. Well, nearly. There was one gotcha! The XML class I was decoding had one field called Text. This is not a valid name inside a deserialised class in C#. So call it a different name in the class but override it via an attribute, as per below.
[XmlRoot(ElementName = "g", Namespace = "http://www.w3.org/2000/svg")] public class G { [XmlElement(ElementName = "rect", Namespace = "http://www.w3.org/2000/svg")] public List<rect> Rect { get; set; } [XmlElement(ElementName = "text", Namespace = "http://www.w3.org/2000/svg")] public List<textitem> Texts { get; set; } [XmlAttribute(AttributeName = "fill")] public string Fill { get; set; } [XmlAttribute(AttributeName = "stroke")] public string Stroke { get; set; } [XmlAttribute(AttributeName = "transform")] public string Transform { get; set; } [XmlAttribute(AttributeName = "text-anchor")] public string Textanchor { get; set; } [XmlElement(ElementName = "g", Namespace = "http://www.w3.org/2000/svg")] public G[] subG { get; set; } }
Those watching trains on maps in Australia have the above site to thank for the speedy recovery of the service :)
Resetting Windows 10 Passwords
Sure, this isn't something a normal person should be doing, but this scenario required it. I'd just fixed a friend's laptop, or I thought I had, until I got a call 2 weeks later saying there were password issues again. Instantly I thought I'd screwed the BIOS up, but this time it turned out to be an entirely different error!
Oh shit... who the hell are LizerdSquad? Is that a typo? Not many google results for this cute little hack. I asked my friend if he'd opened any suspicious emails lately and body-language told me 'yes'. Anyway... google to the rescue. Top Password has a good article on using Kali Linux to reset such a password.
I found a blank USB key and created a bootable drive of the base Kali Linux i386 'light' image.
Booting was easy enough... ESC to select the USB key as the boot device.
Or was it? After choosing 'forensic' mode, the system tried to boot until I was simply presented with a blank screen. Seems my video driver isn't supported? Fail-safe mode worked... but then I didn't have the chntpw command on the terminal! No amount of 'su' or 'sudo' got the tool. Does the 'forensic' mode mount other disks to provide the toolkit?
Trying a different approach...
Keep fighting Kali? Better just use this: A bootable ISO of the chntpw tool. And it worked perfectly! I burned it to the USB key using the 'MBR' option via the same tool as above. From startup, it booted straight into console mode. Whilst loading it even went further to find and diagnose the Windows partition.
This laptop has a single user and a simple windows setup, so the default options were all correct already! Very nicely programmed. I chose through to clear the password and ... bingo!
Don't worry about the 'tmp' error on the final save.
Mission accomplished. Rebooting the machine just gave me a 'sign in' button instead of password entry box and we were at the desktop!
Mixing and matching Xeon Processors?
So I recently came to acquire this beast. It's a beautiful 13-year-old IBM Intellistation Z 6221 with a 3.2ghz Xeon processor. I really dig the IBM styling... it's also ridiculously modular, not even requiring a screwdriver to rearrange drives. Unfortunately, due to its age, it's only 32-bit. In fact, it came with one (supports two) of the fastest and final 32-bit CPUs of the Xeon family.
The first step was to find extra ram to fill the 4 slots. This would only ever max to 8gb, so I needed 4 2gb DDR PC2100 dimms. Not so easy to find any more and prices are going up... either way they were sourced from eBay. I also, now that I think of it, accidentally sold the black floppy drive because a collector wanted it. It's now silver... and doesn't look too bad... but I'm on the hunt to fix that... Or maybe I'll put a zip drive in there...
Next step was to fill the second CPU slot... Thanks to the modular case, no screws were harmed during the dismantling of this product. As you can see below, the naked socket is neatly protected by a plastic shield that plugs into the heat-sink socket. There is, of course, no heat-sink; as there is no CPU in that second slot by default. You could choose this as an option when purchasing the unit.
It turns out that I had another Xeon desktop, in the form of an HP MLxxx. Although this was only a Xeon 2.7ghz, I'd read online that you may well be able to mix CPU speeds? First thing was to remove the CPU from the HP. This turned out to be very easy as its case was also very modular.
Instantly you can see that the heat-sink is different... the IBM used case-mounted fans with passive CPU-mounted heat-sinks, whereas the HP used heat-sink-mounted-fans. I inserted the CPU into the slot on the IBM's motherboard, but the heat-sink shape was different to the bracket mounted on the IBM motherboard. The heat-sink from the HP would not fit in directly!
I quickly tried to remove the bracket from the HP motherboard, with the intent on transplanting it into the IBM. After a lot of effort, it came off (the screws HP used were nearly torqued in!), but then it wouldn't fit in the IBM! It was too wide and long and actually wouldn't fit between the rows of capacitors. So much for industry standards!?
Ok... whatever... I mean how quickly can these things heat up? I'll just hold it in place for a quick test... before I mangle the heatsink to fit. Nope. Turns out the IBM wont even power up with this CPU in the second slot. Is this a fail-safe mechanism because the CPUs aren't matched? Is this CPU a dud? (I hadn't tried it prior...) Dunno.
Make sure the CPUs match!
Off to eBay, I found an identical SL72Y processor in England. It took a few weeks, but it arrived. Again, prior to hacking up the heatsink to fit, I thought I would install the CPU quickly as a test to see if the machine would POST.
Oh wait... it wouldn't just slot in... oh wait... look at those bent pins! I still don't know if it was the beer or the fact that it came off its little foam pad already-bent, but it required about 30 minutes of pain-staking twiddling with a pair of tweezers to get the damn thing in. DO NOT RUSH THIS PROCESS. At one point I thought all was lost as it just wouldn't mount... but after a lot of adjusting it went in.
A bit of hacking was then required to fit the HP heat-sink. I had to hack pieces out of the braces that screw down to the motherboard. I then had to bend a few fins on the actual heat-sink so they wouldn't ground-on or damage the rows of capacitors placed so nice-and-close to the CPUs. And then... it just freakin' worked... and the machine finally loaded Chrome at a proper speed on Linux Mate 18. Now to find a more-appropriate OS to run on this slightly ancient hardware!
Modding an original PlayStation
I hadn't played one of these since... maybe... 1996 when my neighbour and I got Abe through his quest. I found this unit at an op-shop recently for AUD$40 and couldn't resist.
The first thing to do was a tear-down + clean. Of course, a friend then told me he had a spare modchip for it.. so... why not do a proper job whilst the unit was still open.
In true Sony-style, the units disassemble perfectly easily and are neat and tidy inside.
Once you're down to the motherboard, it's simply a matter of determining where to wire the chip. To do this, you'll need to know which chip you have and which model motherboard. Mine was a Multi-Mode 3 and I installed it onto a PU-23 motherboard. I followed the instructions here.
Flatten the chip so that you can glue it on top of an IC later.
Then just run all the wires with as-little-slack-as-possible. This just means you wont have any issues with wires getting in the way of screws later.
Test when the case is open, test when the case is closed and test again later. When testing, the CD tray mechanism requires the case to be held firmly together so that spacing is correct for laser alignment.
Last time I was in BKK, I purchased a selection of random Japanese games. Pachinko, Abe's A'go go(Odyssey), Myst and Tekken 3. Turns out they all work perfectly.
Abe's A Go Go is actually a random text-replacement version of the english version. The cutscenes are still in english with subtitles.
And then you get a random ticker at the top with instructions for non-english speakers... Anyway... time to go and play the rest.
Amstrad CPC464 Restoration
I was hoping this would be a plug-and-play, but a machine this old was always going to be a challenge. I received this unit as part of a lot with the other 6128s and have finally received a tape to test on it.
From the outside, the item was a little dusty. That white piece, which looks like a pivot of some sort, fell out when I rotated the unit to see underneath. Never a good sign... Either way, I plugged in the unit and power it up (it happily uses the same RGB and power setup as per the 6128). To my surprise, I got straight to the main BASIC screen! To try my luck further, I loaded my demo tape and typed RUN"...
All good so far... then I noticed that only the left spindle was spinning on the tape player. The right wasn't collecting any of the read tape... I had a hunch where it was going......... yep.
Time to pop it open.
Dusty... OK... I can handle that... what I can't handle is a spring (from somewhere?) magnetised to the speaker. The ad-hoc shotty taping-and-soldering was also a little bit of a surprise.
Regardless, looking at the tape player mechanism I quickly found two dead rubber components. The band to the tape counter had perished...
So had the rubber ring that drives the right spindle. This makes perfect sense and explains why the machine tried to consume my tape.
Finding spares
There's a few options online for spare parts. eBay was my first choice and I have the two main belts on the way from Germany. This'll take a while. I actually really only need the band for the tape counter, but it won't hurt to replace the main drive belt also.
The second part is a concern. It's a tight ring and my initial searching has come up with zero results. Might have to head to the hobby shop today and find a car tyre or o-ring. Meanwhile, did someome say o-ring?
Drive 'wheel'
Not having much luck with o-rings, I went to my local hobby store and bought some Fleischmann HS Scale traction tyres (00544001) (actual picture here). I bought 4 in total and just layered them up on the wheel. I was a little worried about alignment as any friction would cause the tape speed to change.
It has seemed to have worked.. but now the main drive belt is slipping. I'm going to assume it's loose and therefore not getting the required amount of traction. More waiting until the next set of spares arrives!
Drive and Counter belts
The set was ordered from eBay and arrived from the UK in good time. As expected, two belts in a bag. Much stronger and more flexible than the belts they were to replace.
There's one screw underneath to remove and then you just slide the belt over the wheels. Make sure you not twist the belt when installing. It's not 'extremely' tight, so it's pretty easy to install.
Read Errors
Back to testing. The tape drive started operating perfectly, so I attempted to load the cassette once more.
Yosh! We're getting somewhere... but then...
Read Error Codes indicate failures whilst reading from tapes. Sometimes this is a dirty head, other times the head is out of alignment. I wiped down the head with an alcohol swab and then started to attempt alignment. Not really knowing what I was doing, I hooked up the audio to 'listen' to the data and twisted the alignment screw until the audio was loudest and clearest.
After a lot of errors, I seemed to have it stable, so I restarted the machine and tried again. It got all the way to Block 11! Then it just wouldn't continue. I hung around until I could make it say 'abba'.
Was the tape dead? All of a sudden I had a hunch it could be the power supply... so I swapped to an old AT power supply... but it didn't seem to be able to provide enough current...
And then I accidently plugged in 12v...
Take your time when playing with old electronics... I've now received the dreaded Grey Screen of Death and that means any of the internal ICs could be toast. I might muck around and try and swap the socketed ones between the 6128... but otherwise... I might have just lost the battle. $%$#%#$%#%.
There's a lot of good information here on over-voltage. Seems I've cooked the lot.
Chips on the board
I'm putting this here in case I ever feel game enough to do a full board chip replacement.
Chip | Purpose | Quantity | Status |
---|---|---|---|
AY-3-8912 | Sound | 1 | |
AMSTRAD 40009 | 32K ROM; O/S and BASIC | 1 | |
74LS145P | BCD-to-Decimal Decoder | 1 | |
74HC153P | Dual 4-input multiplexer | 4 | Found, not ordered. |
HD46505SP | Video PPI | 1 | |
D8255AC-5 | CRTC | 1 | |
74HC273P | D FLIP-FLOP | 1 | Found, not ordered. |
Z8400AB1 | Z80A 4Mhz CPU | 1 | Found, not ordered. |
74HC32P | Quad 2-input OR gate | 1 | |
74HC244P | Octal buffer/line driver; 3-state | 1 | Found, not ordered. |
74HC373P | 8-BIT DRIVER | 1 | Found, not ordered. |
M3764-20RS (Or 4614?) | RAM | 8 | Found, not ordered. |
74HCU04 | Hex unbuffered inverter | 1 | |
AMSTRAD 40010/40007 | Gate-Array | 1 |
Barcode Scanner: Cheating in Style.
I picked up a random hand-held barcode scanner from the markets a few months back and it's been sitting on the shelf waiting for a proper reason to exist. Whilst playing a marathon game of Bubble Bobble on the MSX (and losing, we just couldn't beat the boss), I google'd for cheats. They were all enterable via the keyboard on the main screen... but then it occurred to me... A barcode scanner on a PC would be the best way to quickly type in cheats for your game of choice.
The Scanner
This thing is a hand-held model with stand. It's a DataLogic QuickScan QD2100 and the drivers can be found here.
Note that the device will install perfectly well on windows and show up as a HID Compliant Keyboard.
Once installed, any barcodes scanned will be input via a virtual keyboard, along with a carriage return! To fix this, I'd assumed we'd install drivers and configure the device via software. It turns out instead that we'll need to directly configure the scanner itself via programming barcodes. Grab the manual here and browse to page 90. Read the instructions that they've mentioned:
- Go to page 91 and scan the top programming code.
- Scan the Set Global Suffix code
- Scroll all the way to page 291 and scan the 0 code twice
- Scroll all the way back up and scan the programming code again to exit
Making Barcodes
There's a ton of online sites that'll do this for you. My first hit was Barcodes Inc's online barcode generator. From here, even from the screen, you can zap the codes and test the device. It should all work pretty flawlessly.
Doom
I must admit, as soon as this idea came to mind, this was the game that I thought of first. Yes, it's dos-based and this scanner isn't... but that doesn't stop me from using it under DosBox.
GOD Mode |
All Guns/Keys/Ammo/Armor |
Show location details |
Temporary automap |
Temporary radiation suit |
Temporary light |
Temporary invisibility |
Temporary invulnerability |
Temporary berserk |
Change map detail |
Chainsaw |
Walk through walls |
All Guns/Ammo/Armor |
What's Next?
You could use this to automate processes: Run-through an entire game maybe? Play music? Probably nothing at-all worthwhile... but nonetheless still fun!
Reveal MusicSTAR MIDI Piano Keyboard
Picked this up at a local tip shop a while ago for cheapcheap and have finally gotten around to checking it out. It's a short MIDI Keyboard from Reveal, model number MKB02. It turns out the company no longer exists; but Creative did try to save them back in the day.
Anyway, the keyboard is really nice. It has the standard IO: Power plug, power switch and MIDI out. On top you'll find buttons to adjust pitch and octaves.
Mine didn't come with an AC adapter, so I purchased the closest 9v 200ma supply I could find.
I was concerned whilst hooking this up as to the polarity of the plug. Usually you get the little symbol somewhere on the unit to dictate where positive is. Every other MIDI device I've seen lately has positive on the outside... but this does seem to be a Japanese thing.
The best way to solve this was to crack the unit open... it's a keyboard nonetheless, so it probably needed an internal clean anyway!
That last photo is of the IO board. The best bit? The power runs in from the DC jack into a friggen bridge rectifier! Why am I so happy/excited about this? It means the polarity doesn't even matter! It more-or-less treats the input as AC and converts it to its own polarity. How good is that!? All devices should do this.
Anyway, the next step was to simply hook it all together into my SC-55. Of course... it just worked perfectly!
Replacing the BIOS in an HP 250 G5 Laptop
After visiting the flea markets in Melbourne a lot, I've made quite a few friends. These include fellow shoppers and the odd store-holder. One of these store-holders at Oakleigh, in the South East of Melbourne, pulled me aside 3 weeks ago to ask if I was any good at repairing technology.
I hesitated at first... I love repairing (and breaking) my own things... but I am not so sure of destroying other people's equipment. Anyway, the issue was a laptop BIOS password that could not be bypassed. I mean, how hard could it possibly be?
The Laptop
This was to be a slow process. The markets are only held every Sunday and I was pretty busy during the week, so I could only pick the unit up the next weekend. Turns out the problem child was a run-of-the-mill HP laptop which, as soon as powered on, asked for a Power On Password.
A quick google showed that a visit to BIOS Password Recovery for Laptops would help. All I had to do was paste in that magic code (enter three wrong passwords) and receive the master password. Unfortunately, passwords beginning with an 'i' just can't be done like this!
A Call To Support
For all intents and purposes, HP support online is actually fantastic. I was quickly informed that this unit was out-of-warranty and a real call to the telephone support would be required. I quickly tried the 'online chat' support first and the system was actually really helpful. They take in your details and then attempt to throw you to their own KB articles.
Fortunately, my problem was impossible to fix online... otherwise everyone would just be getting past this security measure making it not-so-secure. I was then asked to provide the original invoice, a letter indicating the postal address of the owner and a hand-written note from the owner requesting a formal password reset.
Unfortunately, the owner could not produce the original invoice. The item was purchased online a long time ago and he had been unable to get it printed again. From my point of view, the online retailer was definitely not going to help me. There would be too much back-and-forth... I therefore googled a little further and realised there was another way to solve this problem.
Hardware Hack
This is my specialty. Why bother with the to'ing and fro'ing when you can just crack the machine open and replace the BIOS chip. I mean, usually these things are slotted... so how hard can it be?
Oh shit... It's a tiny 8-pin SMD IC just near the metal shielding and it's nicely soldered in place.
You'll find pre-flashed BIOS chips for sale on eBay. This one came from Latvia and even had the very latest BIOS installed. It came with a great set of instructions too.
Remove the current chip. I know, I know... I said above that I'm not down with wrecking other people's hardware... but here I got frustrated trying to remove this chip and just cut the legs. It's the easiest method and well... I would've been screwed if it didn't work!
From here, tin the pads and then place the new chip in place in the correct orientation! Then just tap the legs with the soldering iron and set the item in place.
And then... apply power!
Yes yes... as per the instructions, the CMOS settings need to be saved. When past the screen above, his ESC and then F10... set the date/time and then go to the final menu and save.
Well shit... it just worked! Now to clean it up and hand it back.
A Western Victorian Daytrip: Ararat
There was a model railway show on in Ararat... sure, I could've taken the MR2, but I'm getting old and lazy and therefore shouldered with the geezers onto vintage trains instead.
Getting to Ararat via The Overland
OK, I lied about vintage... well... nearly. The Overland could nearly be defined as vintage. The carriages are from the 1960s, but have been kept reasonably up-to-date. It's an easy trip from Melbourne to Adelaide on this service, or so I believe... I've only been as far as Ararat on it. Ararat needs 3.5 hours, whereas it's a whole daytrip to get to Adelaide.
The consist is loco-hauled and Pacific National gets the honours. Unfortunately, The Overland is provided with a standard NR Class locomotive and isn't offered a livery of its own (unlike The Ghan and The Indian Pacific.) So, due to loco-hauled-goodness, the rake of passenger cars is pulled from the freight yards by a wrong-way-round locomotive into Southern Cross Station. From there, the loco detaches from the rear-end and runs around to the front-end.
From here, we just wait for the XPT to slug off to Sydney prior to receiving a green light. Inside the train, you're presented with a very run-of-the-mill economy class cabin. It's not ugly, it's not uncomfortable... and it's not modern. Actually... with the standard gauge track to Adelaide being what it is (a freight track) the seats really do help! Unfortunately, the carriages are leaf-sprung and so I can only recommend holding on to whatever you can if you're trying to get to the dunny or the bar car.
And yes... I said bar car! Unfortunately it was 8am... so I didn't bother sampling the great wine and beer that Australia has to offer. I did enjoy the view though... it's looking very dry out west!
Ararat
We arrived a few minutes late into a very warm Ararat. The Overland doesn't hang around after dropping-off/picking-up... the engine revved nicely and got out of there in no time.
Straight away there were things to see as VicTrack is currently upgrading the line between Ararat and Maryborough to Standard Gauge. Actually, as I write this, both a grain and a fruit train have traversed the line (at around 20km/h) with revenue services! Two ballast trains were in the yard, but we weren't too sure what they were going to do.
Oh yeah... we were here for a model railway show... it was dismal. I mean, credit where due, thank you to Ararat for putting on a show! But there were only 4 layouts and a few shops. Still, one of my favourites was there!
I need to work on model railway photography! But anyway... what else to do in Ararat? Well... we brought a DJI Phantom with us...
And wanted to catch both BG and SG trains... but we chose a stupid position as I'd gotten confused with the BG and SG and the new SG to Maryborough! Either way, the trains came in and were captured.
Getting Home
That V/Locity that rolled in above took us home at a leisurely rate of 160km/h when possible and on very smooth track. It even sounded a lot healthier than the NR class that towed us in on the more-narrow tracks. There's actually nothing to mention about the trip as V/Line do an amazing job with regional Victoria.
Windows 7 doesn’t boot after installing on Hyper-V
Thanks to my fresh windows 10 install, I had to re-install Hyper-V. No real issues... made a new machine and booted a Win7 ISO. All well... installed quick... reboot just gave me a black screen with a flashing cursor.
Googling came up with this link... Lots of rubbish replies... but there was another one of those gems. Those one-liners that save the world.
Boot your installation media and go to command prompt via recovery, it said. Just type the following, it said:
bootsect.exe /nt60 all /force
And, well, shit... it worked perfectly.