Thursday, 24 February 2011

Hard disc full again?

Yeah even if you've got GigaBytes of it you still seem to run out! Here's a few free tools that are good for visualising used space - using a nice visualisation technique known as treemaps:

Windows: WinDirStat, SequoiaView (a bit old)
Mac OSX: Disk Inventory X, GrandPerspective. (Baobab is available thru darwinpaorts)
Linux: Disk Usage Analyzer (aka Baobab)

There's also plenty of others out there but I've not tried 'em.

Updated: 1jul15

Sunday, 20 February 2011

Using the Linux tbf qdisc for rate limiting on local or loopback interfaces

If you have ever played with the Linux tbf (Token Bucket Filter) on either some local interfaces, or on the loopback interface (lo) then you may have run into problems - like the attained rate is only a few hundred kilobits/s or less (zero)....?
tc qdisc add dev lo root tbf rate 10Mbit burst 10kb latency 5ms 

Basically if your interface has TSO/GSO enabled (check using ethtool -k ethX), or you're using the loopback interface - then you'll probably hit a problem. It turns out that the loopback interface has GSO/TSO enabled as default, plus since it is a software interface its default mtu is 16384 (as compared to 1500 for normal Ethernet interface). This matters as the tbf queue checks the size of the incoming 'packets' - which in the case of GSO/TSO are much larger than a normal on-the-wire packet - instead they're up to 9 x iface's mtu. So for normal interfaces it's about 12K, but for loopback it is about 100k!

In which case you'll need to add the 'mtu' argument to the tc command and then it might work( but check update below in case not):
tc q a dev eth0 root tbf rate 10Mbit burst 10kb latency 5ms mtu 100000
  
Update [29jan20]: It is also important that the burst parameter is greater than the MTU (you will see warnings in dmesg to this effect if your burst size if too small) if running on an interface that has a large MTU like the loopback interface which is now commonly set to 65535 :
tc q a dev eth0 root tbf rate 10Mbit burst 70kb latency 5ms mtu 100000

Friday, 11 February 2011

Python obfuscation

Well there's plenty of talk out there about Python obfuscation. But basically its frowned upon by most, and not that easy (though that's really the case for most languages). But if you'd like to make it a bit harder for people to rip-off your code, then these seem to be the ways to do it:
  • Compile Python code into .pyc - using Python's in-built compileall module - in your code dir run (then delete all your .py files and you can run the .pyc files):
    python -mcompileall .
  • Use [cx]Freeze (or py2exe) to compile your Python project into an executable
  • Use a Python source code obfuscater like this one or that (both a bit old)
  • Use cython instead of Python
  • There are some commercial products out there too (e.g. this)

Sunday, 6 February 2011

Airport Update 7.5.2 kills IPv6 Router Advertisements [NOT?]

[22sept11]: UPDATE: It appears that I may be wrong as I've now seen my machines automatically obtain an IPv6 address now (using an RS and receiving an RA). Possibly what was needed was a full power cycle of the Time Capsule to effect the IPv6 configuration.

After carefully managing to set up IPv6 on my Time Capsule using a manually configured tunnel I noticed that it had stopped working after updating to 7.5.2. I hadn't had the time to look into it before,  but now I have it seems that 7.5.X has some kind of 'safety' feature that disables Router Advertisements (RAs) on your LAN when another box on your LAN is doing the DHCP  (or RA) which seems DUMB. It should be configurable as alot of people don't use their TC as their main router box - since it only supports PPPoE. If someone's going to bother manually setting up a tunnel then they probably want to use it...

It seems that the Time Capsule reports this an "IPv6 Tunnel Error" - despite the fact that actual tunnel is up - so this error must be indicating it has had to stop the RA service.

I now have to manually add the IPv6 route to my hosts which make IPv6 a bit of joke on things like my iPhone or other devices I can't configure manually for IPv6.

Nice one Apple - just when we thought IPv6 was getting easier!

Friday, 28 January 2011

Skype 5 for OSX is out

Well they released an official version of it yesterday... I guess I'm getting used to it - the do seem to have made the final version a bit smaller so I suppose it's ok. The group video stuff sounds good and it all seems to work well so far...

Anyway it's good to see they're actually working on Skype for OSX - it's been a while since 2.8 was out. I guess you could give it try....!

Tuesday, 18 January 2011

Shrinking Linux virtual disks on OSX VMWare fusion

So your virtual disk is taking up tonnes of space - despite the fact it's not that big when you check its size in the Virtual machine. It's annoying that VMWare images don't do better auto shrinking...

Anyway I tried to run the vmware-tools which I installed (after a bit of jiggery-pokery) and it comes up with a 'Shrink' tab but no disks appear in the list to shrink?! Any suggestion as to how to get disks to show up there are welcome but I couldn't find much on the web about it...

So instead I looked about and the best way is to take the following steps:
  1. Start your VM OS up and optionally remove any cruft. At least run:
    sudo apt-get autoclean
  2. To prepare for the shrinking process run:
    sudo cat /dev/zero > zero;sync;sleep 1;sudo rm zero
    This fills all remaining space on your virtual disk with a file full of zeros so the space can be reclaimed in the shrinking step.
    Note: Your hard disk WILL NOT fill up as the vmdk images do actually optimise the storage of files containing zeros
  3. Shutdown VM OS and delete any snapshots available then Quit VMWare Fusion
  4. To start the shrinking process in OSX run (Replacing path_to_your/disk with something like '/Users/username/Documents/Virtual Machines/Ubuntu/Ubuntu.vmdk'):
    cd '/Applications/VMware Fusion.app/Contents/Library'
    ./vmware-vdiskmanager -d path_to_your/disc.vmdk
    ./vmware-vdiskmanager -k path_to_your/disc.vmdk
    
    The first command defragments the disk, whilst the second actually does the shrinking.
    (Note: The directory for 'cd' for 3.X of VMware Fusion was:
    /Library/Application Support/VMware Fusion/) 
[27jan12: Updated for VMware Fusion 4.X]

Thursday, 13 January 2011

New Apps not showing up in Apple+Tab

So I was using my Mac (probably with way too much stuff running) and started a new App and then hid it (Apple+H) and then tried to Apple+Tab (Cmd-Tab) back to it but it didn't appear in the list of App Icons. The same happened when i started another Application.... I could always use Expose but I like Tab switcher...

So then I wondered which process controls the Tab switcher... It turns out that the Dock process not only runs the Dock bar at the bottom but also powers the Tab Switcher. So by just killing the Dock process it will then relaunch (by launchd) and sort it self out (provided you're not totally out of memory/disk space or something). You can do this from a Terminal window, using the following command:
killall Dock 

Monday, 10 January 2011

Counting lines of source code...

It seems easy at firstly sight (wc anyone?) then there's all the awkward stuff like comments, blank lines, coding style, header files, and stuff....

Anyway I came across a nice tool: sloccount which works on Linux, OSX and probably others, which does a good job of estimating "Source Code Line Count (SLOC)". Plus it also spits out coding time estimates based on some heuristics. There are other tools out there of course but this one just seems good.