Thursday, 20 August 2015

Weaving a Paper Sombrero


I'm leaving my usual topic of computers and technology for a change, and doing something crafty. I've made a fair but of stuff out of cardboard in the past, but today I'll be using paper.

We're hosting a Mexican dinner party soon and I thought it'd be fun to try and make a sombrero. 

Obviously the first thing you do is google it, but the search results returned mostly pictures of cakes, so I set about trying to build my own hat from scratch. After a few false starts I decided to use long paper strips and construct it in the style of a woven palm hat.

Making a Start

The boring bit is making a ton of paper strips using wall lining paper. It's relatively stiff paper, course finished and slightly off-white coloured. (Ideal really)

Making paper strips - you'll need lots of these!
  1. Cut off a long strip of lining paper, around 1.5 metres (5ft) long. Fold it along it's length and cut down with a knife to give you two narrower strips.

  2. Repeat this until you end up with strips about 4 cm (1.5 inches) wide, fold these along their length but don't cut them this time. (We're aiming for double thickness 2 cm strips to give the hat better strength.)

  3. Take eight strips and weave them together to give a square starting point, as per the next photo, and fix them with a glue stick. (Glue sticks are quick bonding, not too messy, and can be unpicked if things go wrong.)
Starting weave showing eight strips woven togther.

Weaving the Crown

OK, that was the easy bit, now go and find yourself a tapered pot (I used a flower pot) to use as a former to weave the crown around.
  1. Bend the strips down and start weaving and gluing into a diamond pattern.
Weave down in a diamond formation.
  1. Now it gets a little tricky, add extra strips to fill in the gaps as go, but don't add too many, or your crown will grow too wide. Pull the sides in to each other as you weave.
Add extra strips and weave sides together.
  1. Keep going until your crown is about 20 cm (7-8 inches) high and slightly wider than your head.

Finishing the Crown

Now we'll fix a paper band inside the hat to give it strength and set the width.

  1. Take a strip of paper long enough to go just over twice round your head and glue it together to form a strong oval (head shaped) band.

  1. Once dried, glue this to the inside of the crown with PVA or contact adhesive. (I used the latter because it's fast drying and very strong)

Starting on the Brim

Once dried, turn the hat over and start weaving the brim. Again this can be a little tricky to get started because the strips don't tend to be very evenly spaced. But at least this time you can weave on a flat surface.

Ready to start the brim.
  1. Start with easy diamond shaped weaves again, adding extra strips where missing.
Weaving the brim.
  1. Build it out until you reach your desired width. I went for 18 cm (7 inches) from the base of the crown. (You'll find that even with four layers of paper the brim is very floppy, but don't worry the next stage with fix that.)
Keep adding extra strips as you weave.

Finishing the Brim

Everyone knows that sombreros curve up at the edge, but that's very hard to make. Instead I opted for a simple square edge, and it really transformed the brim from a floppy sheet into a rigid hat.
    Brim edge marked and strips folded up.
  1. Mark the brim's circumference with a pencil, fold up the strips and cut off any excess length. (You may need to unpick some of the weaving if you went too wide.)
  1. Take one of your left over weaving strips, ensure it's long enough to go round the hats circumference, and temporarily join it together to make an edge band. (You'll want to fine tune the length later.)

  2. Weave the strip around the brim's edge using clips until the glue dries. Work your way from the middle of the band to the join.

  3. Glue the join as you finish the last bit of weaving and then repeat from step 12 to add a second band.
Weave edge bands to add rigidity.
  • Your hat should look something like this..
The hat almost finished.
  1. Finally double back the remainder of the strips, trim and glue over the top edge band and you're done.
The completed sombrero.

What Next?

It's a good idea to give the whole thing a coat of diluted PVA glue. (50:50 should do it) This will make the hat a little more durable and prepare it for any pattern you want to add.

I hope you found this useful, and if anyone does have a go at building one, good luck. Oh and please send pix, and I'd love to see the results.

Friday, 7 August 2015

Web Scanning for Devices on your network using Nmap and Perl


I wanted a way of keeping tabs on how much the kid's computer was being used during the day while we were out. I can look on the router to see what devices are connected to the network, but this only works while I'm at home.

As I run a web server at my home, I decided to put together a quick webpage that scans for devices and shows the result on a smartphone.

Scanning the Network

After a few web searches I found the best tool to use on my Linux server was nmap, so I installed it and started playing around scanning my network. Results were initially pretty patchy, either the scan took too long (in excess of a minute) or finished quickly but didn't pick everything up.

The results depend on what sort of scan you want to do, it will scan ports and even attempt to detect the device's operating system.

In it's simplest form just enter:-

  nmap 192.168.1.*

Which will scan for range of addresses using a wildcard, or you could just do the following for a smaller range ( -


You can perform a fast scan by using the F flag:-

  nmap -F 192.168.1.*

Or include a range of ports (say 80 to 200):-

  nmap -p 80-200 192.168.1.*

Anyway, it does loads of good stuff, and also generated a lot of errors like this..

  RTTVAR has grown to over 2.3 seconds, decreasing to 2.0

I couldn't find much help about this warning message, but it seems to be related to the scan taking longer than expected. Be patient.

Eventually, I settled on the following command which gave a rapid reply and a reasonable degree of accuracy. (The T5 flag sets the timing template so it times-out sooner.)

  nmap -F -T5 192.168.1.*

Building it into a Webpage

My main aim was to show the data in a webpage which could be viewed from anywhere. I chose to use Perl and the CGI library to do this, although I could have used PHP instead. (I'm just more familiar with Perl)

Here's the code I came up with, it also uses the Nmap_Parser library to make handling the nmap data easy.

use strict;
use Nmap::Parser;
use CGI ":all";

my $q = CGI->new();
print $q->header();
print $q->start_html(-title => 'Scan Network',
                     -head  => meta({-name    => 'viewport',
                                     -content => 'width=device-width, initial-scale=1'}));

my %known = ('Unknown-f0-b4-79-19-a8-ff.home'             => "Rick's Laptop",
                         'android-16f4d57ae478ea5.home'   => "Saul's Phone",
                         'Unknown-84-38-35-41-0d-56.home' => "Ruth's Laptop");

print "<h1>Devices on Network</h1>";
print "<FORM><INPUT TYPE='button' onClick='history.go(0)' VALUE='Refresh'></FORM></h1>";

my $np = new Nmap::Parser;
$np->parsescan('/usr/bin/nmap','-F -T5',"192.168.1.*");

for my $host ($np->all_hosts()){
   if ($host->hostname){
       my $hostname = $host->hostname;
       if (exists($known{$hostname})){ $hostname = $known{$hostname}; }     
       print "<p><span style='display:inline-block;width:7em'>".$host->addr."</span>: ".$hostname."</p>";
print $q->end_html();

You may also notice I added a way of remapping 'Unknown' devices to something more helpful. It goes without saying that you should add your own devices to the '%known' hash array, if you find them being displayed with unhelpful names.

I also set the meta tag in the html head so that it behaves better on mobile devices.


In use it takes between 5 and 10 seconds to perform a scan. Sometimes devices aren't detected on the first scan (especially mobile devices), so refresh the page a few times to get a more accurate idea.

It picks up most devices including my Bluray player and Humax PVR, but for some reason it wouldn't detect the Nintendo Wii earlier. (not sure why)

Anyway, hope some of you find it useful.