Wednesday 13 July 2011

Ubuntu 11.04 Unity Shell Global Menu & Gwyddion

Gwyddion is a program for processing STM image data. It's open source and cross-platform and very useful for researchers like myself.

Updating Ubuntu to 11.04 however brings with it the Unity shell, which happens to break Gwyddion (among other things), by hiding its menus.

A simple fix for this is to launch Gwyddion with the terminal command:
nanobaz@Ubuntu:~$ UBUNTU_MENUPROXY= gwyddion
thus bringing back the standard menu bar! That's not a typo by the way, it's
UBUNTU_MENUPROXY=<blank><space>gwyddion
This also works for any other program, and if you want to disable the app menu globally, use the command (as su):
nanobaz@Ubuntu:~$ echo "export UBUNTU_MENUPROXY=" > /etc/X11/Xsession.d/81ubuntumenuproxy
The only flaw in this fix is that I can't figure out how to bind this command into a launcher, or change the default method of calling Gwyddion in the GUI to include the first term.

Source

Tuesday 1 February 2011

English Premiership Transfers 2011 - The Data

Being a life-long Liverpool fan, I've been taking a lot of interest in this spring's transfer goings-on, so while reading the Guardian's datablog, I started to wonder to myself what the all the transfers that happened this weekend would look like if visualised.  In particular, how much money actually changes hands between Premiership clubs, and how much of it leaves the country to foreign clubs.  A very quick search turned up this useful, if horribly formatted dataset from the Telegraph's website.


A little find-replace later and I've got something a little nicer looking, in an Excel spreadsheet.  However, looking at the data now, I've got about 220 entries, most of which are loans between clubs, and don't really contribute to what I'm looking at, the money, so I cut these out.  This leaves me with 62 transfers between teams (including free transfers and those for undisclosed amounts) - a nice number, I think.

Next I decided to limit the details of the foreign clubs to their respective leagues, to make the cash flow easier to visualise.  This involved (manually!) searching for the name of each non-Premiership club and noting down the league.  Google's feature of telling you the latest result and next game for a football club really helped with this!

So now, with a little colouring and some further tweaking I'm left with a pretty good-looking spreadsheet.


Now for some visualisation.  This is the hard part, really, and I still haven't quite figured out how to do it.  My first attempt is just using a basic Omnigraffle "circles" layout, mostly because I don't really know what I'm doing with this program.
Click to embiggen!
So unfortunately that looks kind of lame, but I do like the interconnectedness of it all, and it's approaching what I was hoping it would like, so I'll keep working on it and try make it cooler.  I'm trying to think of somehow including the names of each transfer, with the thickness of connecting lines indicating the amount paid.

I've uploaded all the data to google docs anyway, so if anyone out there fancies making a cool infographic out of it, that'd be brilliant!

Friday 14 January 2011

Arduino Morse Code Sketch

Here's my first Arduino code sketch.  It uses the default "blink" circuit (just one LED connected to pin 13), and it blinks out "HELLO WORLD" in morse code.

This variation defines a function for a "dot" blink, and a "dash" blink (5 times longer than a dot), and then a function for each letter and a space.

Not the most exciting example, but since this is the first circuit you make when learning to use the Arduino, it's pretty cool writing a simple little program, uploading it, and seeing it working right there in front of you!

/*
Morse Code
by baz
http://nanobaz.blogspot.com

Uses blink circuit with an LED on pin 13

A    • −    
B    − • • •    
C    − • − •    
D    − • •    
E    •    
F    • • − •    
G    − − •    
H    • • • •    
I    • •    
J    • − − −    
K    − • −    
L    • − • •    
M    − −    
N    − •    
O    − − −    
P    • − − •    
Q    − − • −    
R    • − •    
S    • • •    
T    −    
U    • • −    
V    • • • −    
W    • − −    
X    − • • −    
Y    − • − −    
Z    − − • •
*/
int ledPin = 13, t=100;   // LED on pin 13
                          // time constant t=100ms

void setup()
{
  pinMode(ledPin, OUTPUT);
}

void loop() 
{
  H();E();L();L();O();SPACE();W();O();R();L();D();

  delay(8*t);   // End of line pause
}

void dot()
{
  digitalWrite(ledPin, HIGH);
  delay(t);
  digitalWrite(ledPin, LOW);
  delay(1*t);
}

void dash()
{
  digitalWrite(ledPin, HIGH);
  delay(5*t);
  digitalWrite(ledPin, LOW);
  delay(1*t);
}

void A(){ dot(); dash();                 delay(2*t); }
void B(){ dash(); dot(); dot(); dot();   delay(2*t); }
void C(){ dash(); dot(); dash(); dot();  delay(2*t); }
void D(){ dash(); dot(); dot();          delay(2*t); }
void E(){ dot();                         delay(2*t); }
void F(){ dot(); dot(); dash(); dot();   delay(2*t); }
void G(){ dash(); dash(); dot();         delay(2*t); }
void H(){ dot(); dot(); dot(); dot()     delay(2*t); }
void I(){ dot(); dot();                  delay(2*t); }
void J(){ dot(); dash(); dash(); dash(); delay(2*t); }  
void K(){ dash(); dot(); dash();         delay(2*t); }
void L(){ dot(); dash(); dot(); dot();   delay(2*t); }
void M(){ dash(); dash();                delay(2*t); }
void N(){ dash(); dot();                 delay(2*t); }
void O(){ dash(); dash(); dash();        delay(2*t); }
void P(){ dot(); dash(); dash(); dot();  delay(2*t); }
void Q(){ dash(); dash(); dot(); dash(); delay(2*t); }  
void R(){ dot(); dash(); dot();          delay(2*t); }
void S(){ dot(); dot(); dot();           delay(2*t); }
void T(){ dash();                        delay(2*t); }
void U(){ dot(); dot(); dash();          delay(2*t); }
void V(){ dot(); dot(); dot(); dash();   delay(2*t); }
void W(){ dot(); dash(); dash();         delay(2*t); }
void X(){ dash(); dot(); dot(); dash();  delay(2*t); }
void Y(){ dash(); dot(); dash(); dash(); delay(2*t); }  
void Z(){ dash(); dash(); dot(); dot();  delay(2*t); }
void SPACE(){ delay(4*t); }

Intro

So, this is my blog.  Well, more of a place for me to nerd out.  My nerdblog.

I've got a couple of goals for this year, and I'd like to write a little about how I get on with them.  I've been reading Make: Online for I-don't-know-how-long, and now I'm finally getting my finger out and making some stuff.
Arduino Uno Microcontroller
I got the Sparkfun Inventor's Kit for Christmas (thanks dad!), which of course includes the all-important blogger's friend, the Arduino, as well as a bunch of components.  There are some interesting starter circuit layouts, so that should get me comfortable with the basics, plus with the Arduino's open-source development environment, it allows me to finally put my limited C knowledge to use!

There are a couple of things I have in mind to do with my Arduino, but more on that later...  (Hint: they may involve facebook integration and/or musical instruments)

Starting new projects is all well and good, but I've got a few half-finished things sitting on my desk that I'm going to get to in the near future too.   Honest.

Hopefully if I blog some of what I'm doing it'll make me document it properly and I can write a couple of instructables for them, to pay that community back for a couple of awesome past projects!

Well anyway that's the main purpose of this blog, though I might even talk about my SCIENCE and whatever music catches my fancy from time to time too.  I'll do my best to not go all emo and start writing about my feelings and stuff, but I can't promise anything.  Oh no wait, I have facebook for that.