Archive for the ‘Scripting/Programming’ Category

PS1 tips and tricks

Monday, September 1st, 2014

So two things have been bugging me off late, knowing if the previous command exited non-zero, and I’ve just now once too many times committed on the wrong git branch. The former question is easy enough to answer with “echo $?” and the latter with “git branch” before “git commit” – but lets be honest – how regularly do you really double check which branch you’re on?
(more…)

Preventing GCC from trashing the system

Saturday, December 31st, 2011

I’ve recently seen GCC processes consuming as much as 1GB RAM for it’s resident set size (ie, what it actually consumes in memory). I also have an i7 processor, which means I’d like to run compiles at -j8 and higher (to compensate slightly for disk IO). I have 4GB of RAM. Now, at 8 processes, each consuming 512MB of RSS, I’m starting to push into swap quite considerably, resulting in much slower actual compiles, and I can just as well be using -j2 wasting a LOT of resources by it just sitting there and not getting utilized. A plan had to be made. (more…)

ACPI based battery state notifications

Sunday, January 16th, 2011

Right, so it’s Sunday evening and Quintin just made an entry about send-notify. This immediately made me think of non-root users and ACPI and how I had a script on my previous laptop that popped up notifications when battery state changed. And so inspiration set in and I decided it’s time to redo that hack and publish it. (more…)

PHP curl – controlling multi concurrency

Wednesday, August 25th, 2010

Right, so I moved from downloading 50+ curl handles using the simple interface to using the curl_multi variant, and suddenly I bumbed into a few problems, firstly my downloads were incomplete by the time the code stopped looping (reference example code!) and the web server took some strain trying to serve 50+ severely CPU intensive queries at the same time (an individual download can take up to a few minutes depending on various things, thus why I need concurrency – multiple cores – can just as well utilize them).
(more…)