Other Technical
Interactive storefront display | ARvertising news
As you walk down the street you are approached by a dog. He is on his guard trying to discern your intentions. He will follow you and interpret your gestures as friendly or aggressive. He will try to engage you in a relationship and get you to pay attention to him.
from Interactive storefront display | ARvertising news.
Computer generated dog, reacts to real-world passers-by.
How to Correctly Open a Banana
So, it turns out me and everyone I know have opened a Banana the wrong way our entire lives. I have always thought that banana’s could only be opened that one way and always been rejecting any other way of doing it. But the living learn and me included. When I watched this the first time I thought to myself that this guy has to be joking. What’s the joke in the whole clip…but how wrong I was. It actually turned out to be a much more efficient way of pealing the banana to get to the actual fruit.
Ruby Mock Web Server
I spent the afternoon today working with Sarndeep, our very smart automated test guy. He’s been working on extending what we can do with rspec to cover testing of some more interesting things.
Last week he and Elliot put together a great set of tests using MailTrap to confirm that we’re sending the right mails to the right addresses under the right conditions. Nice tests to have for a web app that generates email in a few cases.
This afternoon we were working on a mock web server. We use a lot of RESTful services in what we’re doing and being able to test our app for its handling of error conditions is important. We’ve had a static web server set up for a while, this has particular requests and responses configured in it, but we’ve not really liked it because the responses are all separate from the tests and the server is another apache vhost that has to be setup when you first checkout the app.
So, we’d decided a while ago that we wanted to put in a little Ruby based web server that we could control from within the rspec tests and that’s what we built a first cut of this afternoon.
require File.expand_path(File.dirname(__FILE__) + "/../Helper")
require 'rubygems'
require 'rack'
require 'thin'
class MockServer
def initialize()
@expectations = []
end
def register(env, response)
@expectations << [env, response]
end
def clear()
@expectations = []
end
def call(env)
#puts "starting call\n"
@expectations.each_with_index do |expectation,index|
expectationEnv = expectation[0]
response = expectation[1]
matched = false
#puts "index #{index} is #{expectationEnv} contains #{response}\n\n"
expectationEnv.each do |envKey, value|
puts "trying to match #{envKey}, #{value}\n"
matched = true
if value != env[envKey]
matched = false
break
end
end
if matched
@expectations.delete_at(index)
return response
end
end
#puts "ending call\n"
end
end
mockServer = MockServer.new()
mockServer.register( { 'REQUEST_METHOD' => 'GET' }, [ 200, { 'Content-Type' => 'text/plain', 'Content-Length' => '11' }, [ 'Hello World' ]])
mockServer.register( { 'REQUEST_METHOD' => 'GET' }, [ 200, { 'Content-Type' => 'text/plain', 'Content-Length' => '11' }, [ 'Hello Again' ]])
Rack::Handler::Thin.run(mockServer, :Port => 4000)
The MockServer implements the Rack interface so it can work within the Thin web server from inside the rspec tests. The expectations are registered with the MockServer and the first parameter is simply a hashtable in the same format as the Rack Environment. You only specify the entries that you care about, any that you don’t specify are not compared with the request. Expectations don’t have to occur in order (expect where the environment you give is ambiguous, in which case they match first in first matched).
As a first venture into writing more in Ruby than an rspec test I have to say I found it pretty sweet – There was only one issue with getting at array indices that tripped me up, but Ross helped me out with that and it was pretty quickly sorted.
Plans for this include putting in a verify() and making it thread safe so that multiple requests can come in parallel. Any other suggestions (including improvements on my non-idiomatic code) very gratefully received.
20 foot multi-touch screen
I haven’t posted anything on multitouch stuff for a while, mainly because I haven’t seen anything that’s really that new or exciting – I haven’t been looking too hard either, so feel free to correct me in the comments.
Today, though, Mike tweeted a link to a video of NUI Group building a 20′ multi-touch screen for an event in dubai.
pointers are awesome
pointers are this video explaining pointers is awesome.
Throttling Flickr Uploads
I’m part way through uploading a substantial backlog of photos (11,000+) to Flickr.
I had started out trying to go through them and decide which were worth uploading and which weren’t, but that approach was taking far too much time. I needed some help. So I decided that I’d upload all of them and open them up to my family to help with the sorting – asking them to tag the photos with the people in them and also use tags like "TODELETE" to mark those that are just noise and should be thrown out.
I could have opened the net wider, but there are photos of my kids and other people’s kids in there so just family it is.
I’m using phpFlickr to batch upload photos to Flickr and my script uploads as fast as the bandwidth will allow, though admittedly single-threaded. This meant that I couldn’t use it at work, at least not with a clear conscience, so have been uploading from home only. Those 8+ hours a day in the office have been bugging me though, so I was looking for a way to have photos uploading without having a detrimental impact on our connection.
A little googling found an article on bandwidth throttling in OSX that showed the basics of using ipfw to limit transfer rates. A bit of tweaking and I ended up with
sudo ipfw pipe 1 config bw 128KByte/s
sudo ipfw add 1 pipe 1 dst-ip 68.142.214.24
This limits the upload traffic to api.flickr.com to 128KB/s and means I’m not going to cause anyone a problem.
Sweet.
Moving Stuff Finished :-)
Yesterday evening I followed the excellent instructions from the WordPress Codex on Migrating from Movable Type to WordPress. This proved to be extremely easy with all the posts, categories and comments coming through perfectly.
I had some files (photos, ppt etc) manually uploaded, so logged in to move those over. As well as migrating I moved the blog from /blog/ up to the root of the site. That all went swimmingly and I picked a nice shiny new theme called demar.
The only thing left was to sort out redirects for all the old links – so I don’t lose all the link love I’ve managed to build up over the years.
After reading through the various options I had a few issues. I’d tinkered a bit with the MT URLs in the past and had a lot of legacy stuff hanging around. I decided I’d just do it with apache’s .htaccess. Not a choice for everyone, but my regex skills aren’t too shabby, so I figured I’d start there.
The URLs fell into a few different patterns:
/blog/atom.xml, index.xml, etc – the feeds. For now these can all redirect to /feed/ so we start with
RewriteEngine On
RewriteRule ^blog/atom.xml$ /feed/ [L,R=301]
RewriteRule ^blog/index.rdf$ /feed/ [L,R=301]
RewriteRule ^blog/index.xml$ /feed/ [L,R=301]
Feeds dealt with I moved on to the root of the blog, adding
RewriteRule ^blog/$ / [L,R=301]
RewriteRule ^blog$ / [L,R=301]
and then onto the archives, where we start to get trickier. First we have categories which take the form /blog/archives/cat_somewhere_I_put_stuff.html. WordPress creates a different pattern by default – /categories/somewhere-i-put-stuff. Not too hard, first we pull out the words, then glue them back together again.
RewriteRule ^blog/archives/cat_([^_]*)_([^_]*)_([^_]*)_(.*)\.html$ /category/$1-$2-$3-$4 [L,R=301]
RewriteRule ^blog/archives/cat_([^_]*)_([^_]*)_(.*)\.html$ /category/$1-$2-$3 [L,R=301]
RewriteRule ^blog/archives/cat_([^_]*)_(.*)\.html$ /category/$1-$2 [L,R=301]
RewriteRule ^blog/archives/cat_(.*)\.html$ /category/$1 [L,R=301]
Each of these regexs pulls out categories of 4 words long, 3 words, 2 words and 1 word respectively. If you have categories with more words in then you’ll need to add longer versions of these, ordering them longest first.
Next the monthly archives, in MT /blog/archives/2004_04.html and in WP /2004/04/
RewriteRule ^blog/archives/([0-9]{4})_([0-9]{2})\.html$ /$1/$2/ [L,R=301]
easy enough.
Then we have the individual posts. These fall into two groups, name based files and numbered files. The name based files are all /blog/archives/categoryname/postname.html. I had thought these were going to be a pig, but I discovered completely by accident that if you simply use the postname part of that then WordPress figures out which post you meant and redirects to its nice new WP URL. Sweet.
RewriteRule ^blog/archives/[^/]*/(.*)\.html$ /$1 [L,R=301]
The exception to this turns out to be posts that have a hyphen in the name. MT strips the hyphen, leaving WP with a name that doesn’t match. I put a rule in specifically for the one post I have that was affected:
RewriteRule ^blog/archives/personal/beijing_sightse.html$ /2008/05/04/beijing-sight-seeing/ [L,R=301]
Which just leaves the numbered posts: /blog/archives/000217.html. The numbered entries proved to be tricky. While you can just append the number /1234 like so and WordPress will fid a post for you, the posts weren’t matching up. As many of these had been indexed by Google and linked by others I wanted to hook them up to the right posts.
Fortunately I had Movable Type still rendering my site as static HTML files, so with a quick bit of bash magic I pulled out the numbered posts and made rules to map them to the Movable Type post name based permalinks (which we already did rewrite rules for above):
find . -type f \
| grep "^\./[0-9]*\.html$" \
| xargs grep permalink \
| awk ‘{print $1 " " $17}’ \
| sed -e ‘s%^\./%RewriteRule ^blog/archives/%’ \
-e ‘s%\.html:%.html$%’ \
-e ‘s%href="http://www.dynamicorange.com%%’ \
-e ‘s%">Permalink</a><br%%’ \
> rules.txt
Each line of rules.txt ends up looking like this
RewriteRule ^blog/archives/000285.html$ /blog/archives/semantic-web/vocabs.html [L,R=301]
which results in a second redirect to just /vocabs and then a third as WP works out where to take you finally. Not great to be bouncing around so much, but much better than losing the link.
Good luck if you decide to make the same move.
Flickr Bashing
I spent some time a little while ago writing a bash interface to the Flickr api, using curl to handle the http interactions.
I was doing it because I have a backlog of around 11,000 photos that need sorting and uploading. To get them backed up I decided to simply upload them all marked as private and tagged as ‘toProcess’ so that I could then start to go through them online.
I’d written most of the raw bash scripts to do the job, but hadn’t put enough error handling in, or enough testing, to trust them with my live flickr account.
That was back at Christmas, so coming back to it fresh a thought occurred to me. At work we’ve been working with php a lot, and php works just dandy as a command line scripting language as well as a web language. Not only that, but php also has a great Flickr library already, it’s tested and in production use – phpFlickr by Dan Coulter.
So, with all my photos already organised in folders…
#!/usr/bin/php
<?
$path = ini_get(‘include_path’);
$myPath = dirname(__FILE__);
ini_set(‘include_path’, $path . $PATH_SEPERATOR . $myPath);
ini_set(‘include_path’, $path . $PATH_SEPERATOR . $myPath . DIRECTORY_SEPARATOR . ‘phpFlickr-2.2.0′);
require_once ‘phpFlickr.php’;
$f = new phpFlickr(‘your api key here‘, ‘your secret here‘);
$f->setToken(‘your token here‘);
$f->auth(‘write’);
$searchPath = $myPath.DIRECTORY_SEPARATOR.’later/’;
$uploadDir = opendir($searchPath);
$is_public = 0;
$is_friend = 0;
$is_family = 0;
while (false !== ($listing = readdir($uploadDir)))
{
$isHidden = ((preg_match(‘/^\./’, $listing)) > 0) ? true : false;
if (is_dir($searchPath.DIRECTORY_SEPARATOR.$listing) && !$isHidden)
{
echo $listing."\n";
$year = (preg_match(‘/[0-9]{4}/’, $listing)) ? substr($listing, 0, 4) : null;
$setName = $listing;
$setDir = opendir($searchPath.DIRECTORY_SEPARATOR.$listing);
$tags = "$year \"$setName\" toprocess";
while (false !== ($setListing = readdir($setDir)))
{
$isJpeg = ((preg_match(‘/\.jpg$/i’, $setListing)) > 0) ? true : false;
if ($isJpeg)
{
$photoFilename = $searchPath.DIRECTORY_SEPARATOR.$listing.DIRECTORY_SEPARATOR.$setListing;
$response = $f->async_upload($photoFilename, $setListing, ”, $tags, $is_public, $is_friend, $is_family);
echo $response."\t".$photoFilename."\n";
rename($photoFilename, $photoFilename.’.done’);
//sleep(1);
stream_set_blocking(STDIN, FALSE);
$stdin = fread(STDIN, 1);
if ($stdin != ”)
{
echo "Exiting from stdin keypress\n";
exit(0);
}
}
}
}
}
closedir($uploadDir);
?>
This script wanders through the folders uploading any jpegs it finds, tagging them with the name of the folder they came from as well as a year taken from the first four digits of the folder name. All so simple thanks to Dan Coulter’s work.
moving stuff around
Just spent the evening moving this blog over to WordPress (from MovableType).
All seems to have gone well, though old permalinks will be broken right now, ’til I get to fix it.
Fixing a plasma TV
My father-in-law very, very kindly donated me a plasma TV recently, a 32" Phillips from a few years ago. It was refusing to switch on, the power LED on the front of the screen indicating what the manual calls "protect" mode. This means that the TV has a fault and the LED shows it by blinking red.
Finding information about stuff like this online is always annoying difficult due the variance in search terms. Is that LED blinking, flashing, cycling, going on and off or any of a number of other descriptions. I found several references to this problem on a mix of forums, but eventually found a thread describing how to fix a phillips plasma tv with a flashing red led on avforums.
From there I managed to find that the type of TV I have is covered by the FM23 AC Service Manual, available here in the annoying form of a 16 part rar file which unrars to a single PDF.
Most of the successes in the thread seemed to have come from following Barbusa’s instructions in the thread linked to above, detailing three capacitors that wear out on the main power board. Diagnosing this was based rather loosely on the fact that if I kept switching it off and back on every time it went into protect it would eventually power up and run just fine. I’m guessing that this comes from the caps managing to build up enough charge over several power cycles.
Capacitors like these are really cheap to replace, I bought some from a local Maplin for the grand total of £1.14. I also bought a new soldering iron, a fine tipped butane one as Barbusa recommended for the job, bringing the bill to a lofty twenty quid – far less than I’d have to pay just to get someone to look at it for repair.
Armed with these new caps and the stupidity necessary to play at soldering inside a high voltage appliance I started stripping it down. Lying the screen flat on its front (on something soft) to remove the stand and screws from the back panel which gives us a great view of the insides – click for larger images.
In the middle here I’ve outlined the main power board, it’s the one with big capacitors, transformers and the two really big metal heat sinks (one black, one silver) running up the middle of the board.
To remove it, we first have to disconnect all the connectors, I took a few photos so I could put them back, but it seems the cabling routes and different sizes of connectors means that they will only fit one way. There are several screws all around the edge and one in the middle of the board, there a small torq fitting, the same as the case screws not sure what size these are, but they’re the smallest torq I’ve got in my toolbox.
Having removed the board we need to find capacitors 2662, 2663 and 2664. In my 32" screen 2662 is a 1000μF 25v 85°C with 2663 and 2664 both 25v 100μF 25v 85°C. I took Barbusa’s advice and bought 105°C rated caps to deal better with the heat. For 2663 and 2664 I couldn’t get the 25v caps, so bought the higher rated 50v ones that are fitted in the 42" plasmas. I’m no expert, but thanks to some friendly advice in #electronics on freenode.net I was confident they would be safe.
Finding them is easy enough, the board is numbered, so with fingers on the capacitor and my new soldering iron on the joints I slowly pulled the caps out and replaced each one in turn.
The numbering is on both sides of the board, here I have replaced 2662 and I’m just about to replace the other two.
Carefully putting everything back together – deep breath – it all works, powering up first time and running fine. Many thanks to the help of strangers :->
Search
What I'm Doing...
- @JingyeL I don't know yet, someone from here will be. in reply to JingyeL 2 days ago
- @JingyeL are you going to ISWC 2010 in November, Shanghai ? 2 days ago
- Back from work to find 666 unread emails waiting for me — must be a sign... 2 days ago
- More updates...
Recent Comments
- Puia on ISBN 10/13 Converter in Excel
- tee on Fixing a plasma TV
- computer doctor on Fixing a plasma TV
- Mars on left wondering…
- neeli on Pranav Mistry: The thrilling potential of SixthSense technology | Video on TED.com
- infopeep on You’re not the one and only…
- talisians on You’re not the one and only…
- olyerickson on Semtech 2010, San Francisco
- PaulMiller on Semtech 2010, San Francisco
- ldodds on Semtech 2010, San Francisco
Categories
- .Net Technical (8)
- Blog on Blog (6)
- commands I have issued (10)
- Enterprise Architecture (19)
- event (4)
- Fiction Book Review (2)
- Food (2)
- Intellectual Property (9)
- Interaction Design (27)
- Internet Social Impact (43)
- Internet Technical (16)
- IP Law (10)
- Library Tech (19)
- Linked Data (1)
- Music (2)
- New Toy (4)
- Non-Fiction Book Review (7)
- Ontologies (6)
- Open Data (7)
- Other Technical (20)
- Personal (36)
- Random Thought (16)
- Resourcing (4)
- Review (1)
- Security And Privacy (11)
- Semantic Web (32)
- Software Business (11)
- Software Engineering (37)
- Talis Technical (9)
- Uncategorized (44)
- Working at Talis (26)
- [grid::blogpaper] (8)
- [grid::fatherhood] (4)
Archives
- July 2010 (1)
- June 2010 (2)
- February 2010 (1)
- January 2010 (4)
- November 2009 (10)
- October 2009 (4)
- September 2009 (2)
- August 2009 (9)
- July 2009 (12)
- June 2009 (5)
- May 2009 (6)
- April 2009 (7)
- March 2009 (3)
- February 2009 (6)
- January 2009 (10)
- December 2008 (4)
- November 2008 (4)
- October 2008 (9)
- September 2008 (23)
- August 2008 (8)
- July 2008 (1)
- June 2008 (1)
- May 2008 (6)
- April 2008 (14)
- March 2008 (3)
- January 2008 (5)
- December 2007 (6)
- November 2007 (13)
- October 2007 (9)
- July 2007 (2)
- June 2007 (1)
- May 2007 (10)
- April 2007 (5)
- March 2007 (11)
- February 2007 (10)
- January 2007 (13)
- December 2006 (8)
- November 2006 (8)
- September 2006 (2)
- August 2006 (1)
- June 2006 (2)
- February 2006 (2)
- January 2006 (3)
- December 2005 (3)
- November 2005 (2)
- September 2005 (2)
- August 2005 (5)
- July 2005 (8)
- June 2005 (3)
- May 2005 (2)
- February 2005 (1)
- January 2005 (4)
- December 2004 (3)
- November 2004 (6)
- October 2004 (2)
- September 2004 (2)
- August 2004 (5)
- July 2004 (1)
- June 2004 (4)
- May 2004 (4)
- April 2004 (3)
- March 2004 (13)
- February 2004 (6)
- December 2003 (3)
- November 2003 (1)
- August 2003 (2)
- July 2003 (1)
- June 2003 (2)
- May 2003 (1)
- March 2003 (1)
- January 2003 (1)
- October 2002 (1)
- May 2002 (1)
- March 2002 (1)
- August 2001 (1)
- May 2001 (1)
- April 2001 (1)
- January 2001 (1)
- December 2000 (1)
- November 2000 (1)
- December 1999 (1)
- November 1999 (1)
- July 1999 (1)




