Wednesday 1 September 2010

Transparent Android icons






I have an Android phone and I wanted to create some new icons.
Inspired by various Andoid themes on xda-developers, I wanted text only icons.
I started whipping up icons in Photoshop, but it was a pain to try new fonts (yes I know PS has scripting...).

So I created a python script to generate a series of icons and zip them up.
The script uses Python Image Library, to render separate transparent PNG files.

from PIL import Image, ImageDraw, ImageFont
import zipfile
import os

class iconpack:
  def __init__(self, zipfsp, fontfsp, fontsize, height, width):
    self.zip=zipfile.ZipFile(zipfsp, mode='w')  # create the zip file
    self.fontfsp=fontfsp
    self.fontsize=fontsize
    self.h=height
    self.w=width

  def addicon(self,lines):
    iconfsp=self.render(lines)
    self.zip.write(iconfsp)  # add the icon tot he zip file
    os.remove(iconfsp) # delete the remaining icon file
    
  def render(self, lines):
    im =Image.new("RGBA",(self.w,self.h),(0,0,0,0))  # adjust the 4th zero to adjust transparency
    draw = ImageDraw.Draw(im)
    font = ImageFont.truetype(self.fontfsp,self.fontsize) # the font file needs to be accessible
    y=0
    for line in lines:
      rendered_hw=font.getsize(line)  # figure out how wide the rendered text will be
      x=im.size[0]/2-(rendered_hw[0]/2) # so we can centre it
      draw.text((x,y), line, font=font)
      y+=rendered_hw[1]-5   # adust the gap between the lines

    # write image file
    iconfsp=lines[0]+"_"+lines[1]+".png"
    im.save(iconfsp, "png")
    del im
    return iconfsp

    
# II saw an iconpack on xda which used 46x81, on the shoulders of giants, etc

# zipfile, font file, font size, width and height
ip=iconpack('DroidSans.zip','DroidSans.ttf',23,46,81) 
ip.addicon(["Inter", "Webs"])
ip.addicon(["My", "Email"])
ip.addicon(["Work", "Email"])
ip.addicon(["Snap", "Shot"])
ip.addicon(["Pod", "Casts"])
ip.addicon(["Audio", "Books"])
ip.addicon(["The", "Mrs"])
ip.addicon(["Bar", "Code"])
ip.addicon(["Four", "Square"])
ip.addicon(["SMS", ""])
ip.addicon(["Maps", ""])
ip.addicon(["Reddit", "is fun"])



Here's hows the icons turned out.  I tried a few fonts from FontSpace, but settled on DroidSans.


Saturday 14 August 2010

Dear future self

I found myself involved in a project which uses Nagios and Splunk to monitor IT infrastructure, and needed to know how to pass syslog messages from a Debian box to Splunk.

Of course I Googled, and to my surprise I found my own post in nagios-users, from over 3 years ago with exactly the same issue, albeit with older versions of the same software.

It was a pretty weird experience, one the one hand I thought it was great that mailing lists are there to be leveraged, repeatedly, but at the same time I realise I didn't learn the solution the first time.
I guess it a testement to Nagios, it's still a great product, still very relevant.

If we can just recall information it so easily, why bother learning it at all?
Better to know how to search, than how to learn.

There's value in making our information discoverable though, so this is note to my future self :
To forward Nagios event messages via syslog to a splunk server, configure data in on the splunk server to accept data on port 514, UDP.
Edit the config of syslog on the Nagios host to forward the messages to the splunk server by adding this line...
user.* @ip.add.of.splunk

Tuesday 20 April 2010

Excel's short comings


I used to be somewhat of an Excel fanboy.
Probably because I have found it to be entirely useful throughout my career (similarly I was a Lotus 1-2-3 fan too.)

However, the more I use Excel, and push it, the more I find what it cannot do.

Here, listed in no particular order, are my top three Excel 2007 disappointments.

1. No Median function in pivot tables.
This really is very frustrating, Median is a widely used function and would be entirely appropriate to include a pivot table summary function, yet it is not.
Sum, Count, Average, Max, Min, Product, Count Numbers, StdDev, StdDevP, Var and VarP are all included, but no Median. Excel is 23 years old, why has Median been left out?

2. Cannot record chart formatting macros.
You can in Excel 2003, but not in Excel 2007.
I used to frequently craft macros to make my charts look better and consistent and to reduce the chart formatting drudgery. My old macros still largely work, so I can use Excel 2003 to make new macros, but come on, really this is the way forward?
To get some idea how annoying this is, create ten line charts, each with 4 series, in each series have 12 points of data. Now add a red marker, point value, and series name to only the last data point of each series.

3. Perhaps this is a feature request, or perhaps I juts don;t know the trick, but when entering a formula, I would like to select a cell and be able to have it referenced as an Absolute Address.
In a long formula with a log of references, this would be a great time save.
I can't find it if it's an existing shortcut.

Excel is still a great product. I use it daily and cannot find a better replacement.
















Tuesday 30 December 2008

Kinetic scrolling with Processing - part1

I've been toying with an idea for a timeline based project; it hasn't got much traction.
I did give the interface some thought and decided to try and implement a kinetic scroller.

It's pretty difficult to find a definitive explanation of Kinetic Scrolling or Flick Scrolling, but I think this pretty much sums it up:

"Kinetic scrolling is the popular term to denote the scrolling of a long list with a bit of physics so that user feels like moving a wheel. Such a list view is then often referred as a flick list, caused the scrolling involves some sort of flicking gestures. " [1]

Apple have a tutorial showing how to use their implementation here [2]


The physics are an illusion, and the approach I used is simple.
  • Click and hold the background to drag.
  • When drag is released, note how far it moved since the last draw.
  • Use that distance as the speed (or energy) of the scroll.
  • Continue moving in the same direction, but start reducing the speed (decay).
  • When the speed slow below a threshold, stop the scrolling.
I made a demo using Processing [3], click the image or here to start.
The coloured bars are just for showing the movement clearly.




[1] http://labs.trolltech.com/blogs/2008/11/15/flick-list-or-kinetic-scrolling/
[2] http://support.apple.com/kb/HT1636
[3] http://processing.org/

Sunday 7 September 2008

Ubiquity commands for openmoko searches

I've been trying out Mozilla's Ubiquty, and I love it.
I hope it gets support and flourishes to the point of being the norm for interacting with the web.

My only gripe (so far) is I have to use it from within a browser, I wish was part of the wider OS, in the way Launchy is.

Anyway, here's a couple of commands to search Openmoko mailing lists and the Openmoko wiki.

makeSearchCommand({
name: "OM",
url: "http://openmoko.markmail.org/search/?q={QUERY}",
icon: "http://wiki.openmoko.org/favicon.ico",
description: "Searches Openmoko Mailing Lists for matching words."
});

makeSearchCommand({
name: "OMW",
url: "http://wiki.openmoko.org/wiki/Special:Search?search={QUERY}",
icon: "http://wiki.openmoko.org/favicon.ico",
description: "Searches Openmoko Wiki for matching words."
});
To add them to Ubiquity, use the command editor (you'll need Ubiquity installed).
Copy and paste the code and you good to go - real-time development, weird.

To use, invoke Ubiq and enter either commands OM or OMW.

Done.

Sunday 29 June 2008

Processing Nagios Status Data - part 1

I've been tinkering with Processing of late, and having a lot of fun with it.
After finding the awsome traer physics library and Sean McCullough's implementation of force directed graph layout, I thought I would see if could visualise the status data from Nagios (..is an Open Source host, service and network monitoring program).

Essentially, after defining hosts (devices) and services (stuff the hosts provide), Nagios will monitor their performance.
I wrote a utility to extract the data I wanted from Nagios, and output an xml file.
I have plans to extend that as a seperate project - Nagiosity. The processing app uses the xml to constructs a graph. It's a bit rough, but I liked the result anyway.
The bigger circles are the hosts, the smaller circles are the servcies.
The more transparent the colour the older the status data.
Green is good, red is bad, the rest are somewhere in between.
The graph layout it's force directed, and uses an inverse gravity model; bigger mass repells.
We can use this property to create an intresting effect.
As the status data updates (every 10 secs) we adjust the mass slightly, and the graph reconfigures accordingly.
For failing services, or old data, we increase the mass, and they migrate to the edge of the screen. Click the image below and run the app, it's quite a neat organic effect.






Wednesday 9 April 2008

Error creating gateway

If you use ESX from Vmware, you may also use vRanger Pro from Vizioncore to backup VMs. Consider doing so, it's great.

If you are already and you start getting backup failures, with 'Error creating gateway' in the log, check to see if someone has changed the root password on the ESX hosts.

If the password has changed, you need to go into Configuration/VMware Hosts//Modify Host and update the password, for each vmware host.

I speant a good few of hours figuring that out. :(