Archive for the ‘Tech’ Category

* How to redirect stdout to one pipe and stderr to another in bash or bourne shell

Posted on August 11th, 2017 by whinger. Filed under Tech.


So I couldn’t find an answer to this when I searched for it… how can I redirect stdout to one pipe and stderr to another?

In my head, it seems like you should be able to do

mycommand |stdoutpipecmd 2|stderrpipecmd

but you can’t.

There are many answers knocking around stackexchange that seem to not-quite do what I wanted, plus in bash you can apparently do command-redirection with 2>(stderrpipecmd); however I was using bourne shell (embedded system) so that didn’t help me.

 

Of course the answer is really ridiculously simple: simply encapsulate the redirect into a subshell, and redirect the stderr of the subshell into stdout and pipe that.

So

( mycommand | stdoutpipecmd ) 2>&1 | stderrpipecmd

It’s really that simple.

 

If you want to make the result of stdoutpipecmd not be piped through stderrpipecmd (you probably don’t), you can do

 

( mycommand | stdoutpipecmd 1>&3 ) 3>&2 2>&1 | stderrpipecmd

which will pipe the output from stdoutpipecmd to stderr, while the output from stderrpipecmd will be on stdout.

To fix that, so the output from stdoutpipecmd ends up back on stdout while the output from stderrpipecmd is on stderr, it gets a bit messier:

( ( mycommand | stdoutpipecmd 1>&3 ) 2>&1 | stderrpipecmd ) 3>&1 1>&2

What fun 🙂

Tags: , , , .



* Merge non-adjacent partitions in Windows

Posted on October 30th, 2015 by whinger. Filed under Tech.


So I got a new-to-me laptop with UEFI and Dell’s fingerprints are all over the partitions. Two partitions C: and D:, 500GB each (just about), which irritates the hell out of me, there’s almost never any good reason to want to split your disk usage in that way.

So I went into disk management to merge the two partitions and found a Dell Recovery partition in the way. Being a UEFI laptop it’s pretty clear from the internet that you can’t just delete these “recovery” partitions because the machine may well fail to boot afterwards, so I thought I was stuffed; happily there’s a nice free little program that will do exactly what’s required with the minimum of fuss.

AOMEI Partition Assistant

Deleted the D partition, moved the offending recovery partition to nearly at the end of the blank space, created a non-mapped partition in the remaining 20MB (just in case the system expects that partition to still exist), click “apply” and watch as it does its magic. Very happy 🙂

 

Usual disclaimer – I’ve never even heard of them before, so I’ve definitely no link to anyone involved.

.



* Fix Vista “Calculating time remaining” on flash drive

Posted on February 25th, 2012 by whinger. Filed under Tech.


I’ve recently changed laptop to one with Vista64, which bothered me because I’ve stuck stubbornly with XP; however I’ve been impressed with the speed and usability of what is now a pretty stable OS.

One thing, though, that’s been really annoying me is that copying and deleting files on USB flash disks has suddenly added an extra layer of irritation: a “calculating time remaining” message that usually takes about 5 times as long as the actual operation. Quite how you can take 5 minutes to delete a file is beyond me.

The solution seems quite simple: change the settings for the flash drive from “optimize for quick removal” to “optimize for performance”. The problem simply goes away.

This is definitely a bug – the amount of time we’re talking about here is massive and isn’t explainable by write caching; however at least now I can cope. I just have to remember to click “remove” on the device before pulling the stick, but to be honest I always do that anyway.

.



* android alarm fail

Posted on May 25th, 2010 by whinger. Filed under Tech.


Lesson number 36 of Android.

Want your android phone’s alarm to wake you in the morning? Don’t kill the “clock” process.

I thought that process was just the front-end bit. It seems not. Thank goodness Willow was there to remind me it was time for walkies…

Tags: .



* MYSQL: Convert hex string to integer

Posted on May 7th, 2010 by whinger. Filed under Tech, Web Development.


So there’s a few places on the web asking how to do this; while it’s easy to do

SELECT x'1fb5';

if you have the hex string stored in a field you can’t do that.

The answer is to use CONV()

ie

SELECT CONV(myhexfield, 16, 10);

It’s that simple.

Tags: .



* XP BSOD STOP 0x0000007b after a virus scan

Posted on January 3rd, 2010 by whinger. Filed under Tech.


Scenario: heavily infected machine, drive attached to second machine and scanned; infected files deleted but when drive reinserted windows fails to boot with 0x0000007b blue screen STOP message.

Lots of stuff on the internet about this, mostly suggesting hardware changes or faulty hardware. No-one mentions the virus scan. It turns out the reason is one of the files deleted by the virus scan is loaded during early boot.

I went through the list of files loaded by the machine (I was lucky that this page showed the list of files Windows loads on the machine – a Dell Dimension 2400) and checked the file existed on the target – the only one that was on my working install and not on the target was atapi.sys; copying this from the working machine solved the problem instantly.

I guess the sensible thing to do was to keep a track of the files deleted by the virus scan… but if – like me – you were too blasé to do something so sensible, I hope this helps some.

Edit: Note that on vista (unlike XP) you can run sfc /scannow from the recovery console

.



* your negative aura just zeroes me out

Posted on October 6th, 2009 by whinger. Filed under Tech, Whinges.


So in this post I talked about -COALESCE(null, 0) returning -0 in my legacy 5.0.15 mysql server and moaned that I couldn’t use -COALESCE(null, -0) to get around it.

It occurred to me that this might be because the parser intercepts the “-0” and goes “don’t be silly”. So I tried this:

SELECT -COALESCE(null, -COALESCE(null, 0))

and – genius! – it works!

Tags: .



* no order too small…

Posted on October 2nd, 2009 by whinger. Filed under Tech.


I’ve used the components supplier farnell before and found them to be excellent. Up until recently I’ve been able to get around their minimum order value for free delivery because work has an account with them; however work has changed their policy so I can’t order stuff through them any more (grrr).

So anyway, I needed to repair the PSU on a Topfield I got off ebay and the 6 capacitors I need came to £2.69 inc VAT; I figured I’d have to bite the bullet and pay a fiver or so for delivery (although I wasn’t too happy about it). Imagine my surprise, therefore, when the checkout came out at “free same-day-dispatch”.

It turns out that farnell abolished the minimum order requirement for website cash orders at the beginning of the year. So hurrah for them!

Edit: they arrived next-day too. Brilliant!

Reedit: no-minimum-order policy has now been reversed. Booooo!

Tags: .



* MySQL’s design team triumphs again!

Posted on August 24th, 2009 by whinger. Filed under Tech, Web Development, Whinges.


From this upgrade note for MySQL 5.1

As of MySQL 5.1.15, InnoDB rolls back only the last statement on a transaction timeout.

Oh, what a fantastic design decision.

I love that there’s no explanation, no reasoning. Just “we’ve fucked over transactions”.

It’s almost like they decided that MySQL was getting far too close to being a usable enterprise solution so they did this to make sure it stayed where they know it really should be – website backend city.

Edit: MAD points out that the old behaviour can be turned back on with an option, but most people new to a database will install it with the default options and really, implementing this option at all just displays complete disregard for the ACID ideals

Tags: .



* Paul Robichaux considered harmful

Posted on August 10th, 2009 by whinger. Filed under Tech.


Paul Robichaux is (I’m sure) a well-respected MVP. I’ve no issue with either MVPs, him in particular or indeed Microsoft. I use a number of MS products, I’ve been (in days when I wasn’t a php-whore) an MSDN-subscribing developer and I’ve made my living in no small way thanks to a number of their products; as such I’d like to make clear that I’m neither a raving loony free-software fanatic nor a MS hater.

However Paul’s rant against z-push seemed so inflammatory and given that the existing comments displayed the most moronic and ignorant attitudes of the free-software community, I felt obliged to post a more measured comment to his site myself for some balance.

It’s been a good few days now and the comment hasn’t appeared. I’m not drawing any conclusions from that yet; however I thought I’d post the essence of what I said here (I don’t have the original text because I submitted it to Paul’s site, which probably makes it his copyright anyway!)

The problem I have with Paul’s position is that it’s disingenuous. No-one really wants to “steal” (as he puts it) MS’ synch protococol, because being able to synch my contacts (which probably change once a week if that) or even my calendar (admittedly slightly more useful) in real time without plugging my phone into my laptop (ooh what a hardship) isn’t a big sell. What they do want is to get their phones to pick up email quickly and cheaply (preferably at approaching zero-cost) without using a huge amount of battery power. There are a number of ways to do this – the cheapest and simplest being IMAP IDLE, which holds a connection open to the IMAP server and waits until the server says “here, I’ve got a new email” (pretty much the same as MS’ “innovative” product does, in fact 🙂 ).

The problem with this is that MS’ phones don’t support IMAP IDLE, despite the openness of the protocol, the wide support for it across almost all IMAP servers and the fact that their own users have been crying out for it for years. Why don’t they? Perhaps because (up until recently) the only way to get instant email on an MS phone (apart from the exorbitant blackberry) was to pay for Exchange. That sounds remarkably like abuse of their market position to me.

I also find it intriguing that Apple decided not to support IDLE either, when they licensed the Activesync protocol. Coincidence?

So here’s a deal Paul. Get MS to support IMAP IDLE natively in their phone’s email client and I’ll stop using z-push in a heartbeat. And if you can get Apple to do it I bet a fair few more of its users would too.

Tags: , , .



Blogroll

Categories