On Corporates, Recruitment Agencies and CVs
To pull down, sort out and import the guide data for vuPlan.tv I thought it would be a good excuse to use PowerShell. I’ve been wanting to use this for ages, to get up-to-speed with what the future of scripting on MS Windows looks like.
I hated every moment of it.
This simple script took more than a whole day to write.
#
# Looks for the latest downloaded .zip file and extracts its contents.
#
$random = new-object -typename System.Random
$dataRoot = "C:\DATA"
$sourceFolder = $dataRoot + "\EPG"
$extractRoot = $dataRoot + "\EPG\TEMP-" + $random.Next(100)
$dataRepository = $dataRoot + "\EPG\HEAP"
$unzipToolPath = $dataRoot + "\unzip.exe"
$importerToolPath = "C:\Users\Public\Documents\~Main\Vuplan\Evoq.Vuplan.Data.Epg.Importer\Evoq.Vuplan.Data.Epg.Importer\bin\Release\import.exe"
clear
set-location $sourceFolder
#$latestFiles = get-childitem | where { $_.Name -like "*TV*" -and $_.LastWriteTime.Date -eq [DateTime]::Now.Date }
$files = get-childitem | where { $_.PSIsContainer -eq $false }
$latestFiles = $files | sort -property @{Expression={ $_.LastWriteTime }; Ascending=$false}
$latestZip = $latestFiles[0]
echo "Extracting " + $latestZip.FullName + " to " + $extractRoot
md $extractRoot
# This little chunk of code unzips using Windows shell but problems with the feckin .zip file mean
# that some files extract twice and invoke a UI prompt for overwrite-replace.
#
#$shell = new-object -com shell.application
#$zipFile = $shell.namespace($latestZip.FullName)
#$extractTo = $shell.namespace($extractRoot)
#$extractTo.Copyhere($zipFile.Items())
#foreach($item in $extractTo.Items) {
#
# $item
#}
$processArgs = "-o " + $latestZip.FullName + " -d " + $extractRoot
$startInfo = new-object System.Diagnostics.ProcessStartInfo($unzipToolPath, $processArgs)
$startInfo.UseShellExecute = $false
$unzipProcess = new-object System.Diagnostics.Process;
$unzipProcess.StartInfo = $startInfo
$startInfo
echo "Starting process."
$unzipProcess.Start()
while(!$unzipProcess.HasExited)
{
echo "Waiting for process to complete..."
[System.Threading.Thread]::Sleep(1000)
}
$sourceDirectoryInfo = new-object System.IO.DirectoryInfo($extractRoot)
foreach ($item in $sourceDirectoryInfo.GetFiles())
{
$destinationPath = [String]::Concat($dataRepository, "\", $item.Name)
if ([System.IO.File]::Exists($destinationPath) -ne $true)
{
"Copying " + $item.Name + " to the heap..."
[System.IO.File]::Copy($item.FullName, $destinationPath)
}
if ($item.Extension -eq ".xml")
{
$processArgs = $item.FullName
$startInfo = new-object System.Diagnostics.ProcessStartInfo($importerToolPath, $processArgs)
$startInfo.UseShellExecute = $false
$importProcess = new-object System.Diagnostics.Process;
$importProcess.StartInfo = $startInfo
$startInfo
echo "Starting import."
$importProcess.Start()
while(!$importProcess.HasExited)
{
"[" + $item.Name + "]" + " Waiting for import to complete... " + ([DateTime]::Now - $importProcess.StartTime)
[System.Threading.Thread]::Sleep(1000)
}
}
}
$sourceDirectoryInfo.Delete($true)
It was such a disappointment. I’m still disappointed as I type this. Being a scripting environment for the .NET Framework, I thought it’d be so cool. The power of the .NET Framework and the freedom of scripting.
But the Integrated Scripting Environment (ISE) is just some crappy cobbled-together tool written in not much more time than it took me to write my script here. It even uses the atrocious code editor from the Expression suite and not the awesome editor that Noah Richards and his team made for Visual Studio 2010.
But worst of all, it has no IntelliSense. Can you imagine?
Apparently there’s PowerGUI that is a non-Microsoft ISE that does have autocomplete (which is an absolute must when you’ve all of the .NET Framework at your disposal and there’s no compiler to warn as you go), but I read something about a guy having a problem with a script which was down to the PowerGUI editor getting confused over some combination of slashes and dots, which put me right off.
So I punched my code into the MS ISE, almost single fingering the keys to ensure it was all correct, like I was back in the 1980s with my Sharp MZ-700.
And slowly my will to live drained from me.
I even read some dude praising it because all he needed was Notepad and Google to be a master of his universe. Not out of my pocket does an engineer work with such inefficiency. Would you take the cab if you saw that the driver was peddling the car through a hole in the floor?
Next time, I will do what I usually do and write a full blown console application in a tenth of the time.
If you’re a .NET developer, Hell, if you’re a sys admin (as I was for years), I’d just use Visual Studio all the way. Skip those cmdlets.
Get properly organised by writing and adding to an assembly of reusable components and classes to help you do your admin tasks. Get the whole department adding to a super cool library of administrative joy.
I came into programming from a sys admin background. I worked for a very large organisation with tens of thousands of computers. I saw the same code across so many scripts, it was a terrible duplication of effort.
So I cultivated a library of fine-grained admin tools in a COM component that was deployed to the PC estate and called from the scripts, a core set of reusable functionality. Then later I integrated it with a Microsoft Excel add-in. That’s right, sys admins could build out their scripts from a report in Excel, drag and drop, cut and paste. Done.
Anyway, I’m going off on a tangent. The benefits of PowerShell from my noob viewpoint are, simple visual remotability and a focus for vendors to create simple APIs (by way of custom cmdlets).
These things are important for the daily activities of a busy sys admin performing live commands, sure, but if its a automated or long scripted process you need to write, its not ideal.
If you’re already a programmer, then just write a proper applet in the superior tools you know and love and share it with your team. And if you’re not a programmer, skip scripting and learn C#.
Coding in Visual Studio will blow your mind and make you a hero.
Luke
Labels: tangent, windowsA friend recently told me he’d started spread-betting and had a misguided perception that I know a thing or too about it, might even be good at it. I thought the truth would make for an interesting off-topic blog post, so here’s what I know.
The recent crash cleared out all my winnings and then some. I eventually liquidated everything last month and was, over 10 years of trading/investing, about £3k down, probably all the trading fees!
I learned a number of lessons.
Back in 2004, I opened an account with IG Index so that I could expose myself to gold. There were no ETFs then so spread-betting was the only way to go. I opened a position with £700 in the account at £50/tick opening at $450/oz. A man called from IG Index doing a survey, and asked why I chose gold. I told him that inflation was rife. The CPI was about 1.5% so he audibly laughed! So I knew I was right.
Contrarian investing goes along the thinking that there are no people left to sell/buy a position so it cannot go lower/higher, this is best when something becomes accepted as a law, a constant that will never change, such as to suggest the opposite invokes derision.
But my reasons for taking this view was that in 2004, copper and lead prices were double the previous year, sugar, too, and yet nothing was more expensive in the shops and nothing said in the press. Prices were flying up, in stealth mode. At some point it'd hit consumers in the shape of massive inflation.
I once predicted the net result of this in an email to a trainee credit derivs trader at the bank, saying:
(If I’d known something about the RMBS market and CDOs, maybe I could have predicted the bigger collapse)
Today gold is at $1,200-ish but I didn't make £37,500. The reason is that I tried to trade the position so that I bought back in at low points. The obvious logic is that, even though you're a bull, why hold the position during weakness when a) your money can be used elsewhere b) you can get by more later, lower?
The problem is that when you're onto a good thing, you often don't know how right you are. You sell and make a profit and the price weakens but you don't buy, it's going lower. It goes higher. But it'll go lower and you'll get back in. You don't want to buy back in and then it goes lower and you lose and then you'll be doubly annoyed because you *knew* it was going lower but were weak willed. It goes higher. It goes higher. You never buy back in. Months later when you’ve forgiven yourself and your mind has cleared, you buy back in, but you missed it.
This isn't actually the main lesson. I bought back in after they released an ETF, Gold Bullion Securities (GBS.L). I held this at the same time as a load of shares. My thinking was that with a financial apocalypse ensuing, gold will go through the roof and hedge any losses elsewhere.
What actually happened was that gold did nothing. I remember watching gold during the deepest darkest days of the meltdown and it actually did nothing. The financial system of the entire planet about to implode and gold did nothing.
Then I had to sell my position because the ETF was backed by a subsidiary of SG, then by an Australian company and underwritten by AIG, who were going bust.
And later it came out that China was buying dollars by the hundred-billion-load during the crash. This kept gold up. They were secretly buying from the Fed to manipulate the currency because China’s wealth in denominated in USD and they could not afford for that to sink.
The lesson is two-fold. With AIG, it showed that the whole system is linked. You can’t escape it. As Warren Buffet once said, it’s like insuring the Titanic via a company based on the Titanic.
The second part shows that even when you know stuff, you don’t know stuff. I didn’t know that much bigger powers would manipulate the market to prevent my perfect plan from working out.
The next main lesson was discovering the ramifications of something you know from day one: that share prices are quite literally nothing, zero, to do with the company or its performance. Share prices are in the minds of the participants.
“The market can stay irrational, longer than you can stay solvent.”
Because there is no link between a share price and the reality of a company’s financial health, it means that a perfectly profitable company with a good outlook can have a share price of nothing, and can go bust because of it. Share prices, company’s fates, the stock exchange and the world’s wealth are driven solely by mass human hysteria. The system is ridiculous.
If enough people think that everything is going to pot, then everything will go to pot. This is why exchanges have daily limits and cut offs. It’s to stop everyone from running to starboard.
For me, this meant that, as in the case of a gold mining company I invested in, I was able to draw up a financial model of their company, ins, outs, raw materials prices, and predict their profits to within a few hundred thousand pounds, I was unable to translate this incredible knowledge into gain, because the market does NOT care for reality. The market is perception, and perception is usually masses of stupid humans doing stupid things.
Investing/trading takes up a lot of time. My biggest profits came from the stuff I never touched. General ‘ideas’, such as China’s growth, Brazilian industry, natural resources; my funds did quite well though all of this, up 25%, and I spent an hour a week researching, if that. If I’d put all my money in funds, I’d be much, much better off.
I bought and held a general idea, let someone else manage it, and sold years later. These days, I’d put my money into someone I can trust, have 100% control over, and enjoy the process – myself, my business or my home. For savings and pensions, I’d use trusts, but revise it every 6 months.
The problem with most people and pensions that end up worthless, is that they buy and hold something good in 1969 and never take an interest thereafter and it dies while the world changes. Buy and hold, but keep control and tweak it according to world issues.
And there you have it ;) – lots of time wasted, lots and lots of stress, much reduced focus on my core skills as a programmer and all for nothing. Or maybe all for a life lesson…
…at least I learned all this now and not when I am 60.
Luke
P.S. Check out Robbie The Trader (nakedtrader) online. While I’d try and make thousands per position, Robbie makes many, many meagre profits. http://www.nakedtrader.co.uk/trades.htm
He used to run a cafĂ© and has amassed >£750k from an ave. £200 profit per trade. It’s funny because the rare times I have played a fruit machine I took whatever was there and went away a winner, but I couldn’t apply it to shares, as Robbie does.
This is how I won the Warrants trading competition, it wasn’t real money and with so few people in the game, in profit, I knew that all I had to do was make a small profit in ALL weeks because most people would suffer at least one week of immense losses.
Labels: finance, investing, tangentWhile looking at a site listing some wonderful animated infographics, I came across Melih Bilgil's fabulous short film and thought it worthy of a post all to itself.
I tagged it with User Experience as the representations of the consituents and their interactions and transitions are inspiring communications.
Labels: tangent, user experienceActiveSync Encountered a Problem on the Desktop
This is just a quick note explaining a method I used to resolve the error message above.
Firstly, I disconnected the phone and closed Outlook and repaired all my storage files using the old ScanPst.exe tool that's secreted away when Outlook is installed.
C:\Program Files\Microsoft Office\Office12\SCANPST.EXE
I pointed this at my primary storage file, which is an Offline Store because I used the Windows Live Connector to get at my Hotmail account.
C:\Users\lukepup\AppData\Local\Microsoft\Outlook\lukepup_hotmail.ost
And then I repaired all other PST files I use, just for completeness. During the repair, ScanPst can hang and be reported as Not Responding - this is surely because while its single thread does the repair it stop pumping the window message queue.
Then I deleted the partnership in Windows and also on ActiveSync actually on the phone itself; run ActiveSync and then in Options, hit Delete on the head of the tree of folders which kills the partnership and cleans up.
I opened Outlook on the desktop and let it do it's thing with Windows Live. It seemed to detect major changes because it appeared to exhaustively sync every item in all folders, taking 10 minutes.
Closed Outlook when done and connected the phone. Setup a new partnership with different names in case it linked back to old registry data. Allowed a good 10 minutes to complete. Well, actually it never completes because I've had a problem for months where it encounters some kind of error and restarts, but this doesn't happened until all items are in, so I don't really worry about it.
Disconnected, done.
Labels: tangent, windowsOff topic, but hey its snow and its on the right side of Christmas – or white side. Got up at 3.30am to run down to The Pantiles and get some super festive shots.
An LG LS55 laptop I bought for a family member from eBay had an awful affliction which I seem to have encountered a number of times and is a common condition.
The sound stutters or vibrates, particularly when playing Microsoft encoded sound and video files, WMV, WMA and now Silverlight movies and particularly when the machine is busy or buffering.
I fixed it and so for the sake of helping people googling the symptoms, here’s what I did.
Firstly, I ensured it wasn’t a codec or driver issue. The laptop in question has a C-Media 9880 sound chipset, which is Intel I think and runs under the Microsoft UAA standard. I tried to disable the Xear 3D DSP but its just not possible – its ‘in’ the driver.
Reinstalling Microsoft codecs is a case of downloading and installing Windows Media Player again. Suspecting a conflict with the ATI video card, I used the performance settings of Display in Control Panel to take the hardware acceleration to none and did the same in Windows Media Player.
After a lot of time and with horrible pixellated videos, I still had stuttering, echoey and stretched sound, and I was really sure that it was a hardware conflict.
Also, the mouse pointer would jolt every second when smoothly drawing a circle, even though the CPU was at 4%.
Device manager showed that many devices were hanging off IRQ 15 or 16, and of course I couldn’t change them. The BIOS on this machine is pretty basic, too.
Although the BBC iPlayer was fine, the growth of Silverlight meant that it wouldn’t be long before my uncle would call from Belgium complaining about video playback – I couldn’t let him have it like this.
I tried disabling the parallel port to free up IRQ5 and hoped that Windows would move a device. No joy.
So my only choice was to disable IRQ Steering and take back control of my device allocations. There was some bad advice and warnings out on forums about this but I came across a great article.
I have a friend in the music business and their needs for high-performance and reliable studio computers tells me that if anyone knows how to solve pops and clicks in sounds, it’s the music industry. (my friend now runs an 8-core Mac with 32 gig RAM)
This article from Sound-on-sound magazine was my saviour.
http://www.soundonsound.com/sos/Mar02/articles/pcmusician0302.asp
I simply when into Device Manager, right-clicked “Computer” and updated the driver to Standard PC from its current ACPI one. It copied over a new HAL, I rebooted and Windows started back up and happily detected and reinstalled all devices!
My mouse moved quickly, my sound sounds sound and videos are silky smooth. I just have to press the power button when Windows shuts down now, and there’s no standy, but its worth it.
Apparently Vista and Win7 are better at spreading devices across the available interrupts. I just wish that user and computer could work cooperatively when I need to force a device setting and let IRQ Steering work around my needs.
Labels: tangent, windowsThe future is a mouse you can stroke
Posted on Channel 9 this morning was a short 5 minute video showing a number of prototype mice that replace the wheel and buttons with touch/finger/whole hand sensors.
Given that holding our arms out in front of us to touch our screens all day will be prohibitively hard to sustain for 11 hours in the office, the future has to be some variation on the desktop pointing device or trackpad.
Check it out (and enjoy the bleepy futuristic music):
http://channel9.msdn.com/posts/LarryLarsen/This-May-Be-Your-Next-Mouse/
Labels: frontiers, tangent, touch, user experienceIntel Ready for On-die GPU with Core i5/i7
“The floor plan above shows the main blocks in Nehalem, and if you've followed previous Nehalem launches (most notably Bloomfield) then you may be able to spot what's missing: there is no QuickPath Interconnect (QPI) interface. Instead, in a significant twist that differentiates Intel's new PC system architecture from even AMD's offerings, there is now a PCIe interface that enables the GPU to attach directly to the processor socket. This latter move was made in anticipation of two things: 1) the GPU will migrate right into the processor socket at a later point when Intel releases a CPU with an on-die GPU integrated into it, and 2) for a discrete GPU, Intel hopes you'll use Larrabee.”
Labels: concurrency, frontiers, tangentMicrosoft Surface Touch UI Fully Exploited at E3
Arguably off-topic I couldn't help posting this demo of a game called RUSE. It exploits Microsoft's $12,500 Surface computer to the fullest that I've seen so far with a war strategy game called RUSE. For me, touch and robotics are set to be the two most disruptive innovations for years.
Now I haven't played games since discovering girls but for a number of years I've felt that, in terms of enjoyment, games are more consistent. Seriously though, I think we can all learn alot from the games industry, especially since technologies like WPF and Silverlight have delivered such a rich toolset (3D and touch) to the LOB and web developer.
Labels: frontiers, tangent, touch, user experience