About Steve

Bio info to go into here

Code presentation in WordPress posts

I have edited my recent post on Removing unwanted pastes from Stikked. I used the <code> tags to delineate the command line interactions from the descriptive text. However I wanted the code to appear more like quoted text in a Mediawiki instance. My first  thought was to hack the css to make the code tag work how I wish, however whilst searching for help on that I discovered that the <pre> tag gave exactly the effect I required, whilst the code tag remains useful where you might wish to use a fixed width terminal style text in line with your content.

The other advantage of the 'pre' tag is that it will not force a line wrap if you have a long line of code

The only thing that I still had to do was reduce the font size for these two fixed width fonts as 13px looked a bit chunky along side the normal text.

P.S Having written this I found this comprehensive page on the WordPress site http://codex.wordpress.org/Writing_Code_in_Your_Posts

The BBC: good value?

I grew up before the days of the Internet, listening to BBC Radio 4; much of what I learned of society, history and science has been from the Radio. The BBC continues to produce high quality informative educational and entertaining programmes. Many of which I consume as podcasts; currently I have the following BBC podcasts in my feed.

  • In Our Time – Melvyn Bragg  (BBC Radio 4)
  • Outriders (BBC Radio 5)
  • Comedy of the Week (BBC Radio 4)
  • Mark Kermode and Simon Mayo’s Film Reviews (BBC 5 Live)
  • Friday Night Comedy (BBC Radio 4)
  • Comedy of the Week (BBC Radio 4)
  • Discovery (BBC World Service)
  • More or Less: Behind the Stats (BBC Radio 4)

These are paid for by the TV License. For my £145.50 a year I get these podcasts, all the TV and Radio output of the BBC, iPlayer and all the related supporting material on the Internet. Oh yes and the rest of my household get all that too.

The BBC have had a massive positive influence on the adoption of technology and attitudes towards it in the UK.

In the early 80’s Acorn found its feet making the BBC Micro, went on to become ARM, whose microprocessor architecture is now in everybody’s iPhones, iPads and Android devices and masses of other equipment.

In 1986 the BBC Doomsday Project gave us a vision of the future of multimedia presentation, with 1 million contributing to a digital archive of the UK.

In the 90’s the BBC website set the standard for presentation of quality on-line news and web content.

BBC iPlayer pushed the boundaries for streamed media and once again set the standard for other broadcasters to follow.

More recently we’ve seen the digital switch-over,  in which the BBC played a major role.

With a few notable exceptions having the BBC there, providing content and spurring technical innovation, raises the bar for the rest of the media. It’s a shame that the recent issues with senior management, remuneration, golden handshakes etc., give politicians the opportunity to question their continued funding.

Removing unwanted posts from Stikked paste bin

Stikked is a pretty handy open source paste-bin application; that I’ve been using as a private paste-bin. It lets you set a time-out on a paste so as it cleans up after you’ve used the paste. Unfortunately occasionally I leave it set at ‘Keep-Forever’. It doesn’t have an admin interface or a delete option for the pastes, so over these unwanted pastes build up in the database.

I failed to find  a guide to delete posts from Stikked on the web, though there were people who had asked how they could remove unwanted posts. So I put this short guide together.

In the browser display the paste that you wish to delete. The paste id is shown at the end of the URL, make a note of the paste ID(s) you wish to remove. The paste IDs appear as an eight character hexadecimal string such as 8ae4ae1a.

Now we have the IDs we can log into the command line on the server and delete the pastes directly from the mysql database.

Log into mysql (you will need to have the root password or an account that has rights over the database).

$ mysql -u root -p

Change to the correct database

List the databases

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| paste              |
| performance_schema |
| phpmyadmin         |
| test               |
+--------------------+
7 rows in set (0.00 sec)

In this case the database was called ‘paste’. Switch to the correct database.

mysql> use paste;

Show the tables in the paste database

mysql> show tables;
+-----------------+
| Tables_in_paste |
+-----------------+
| blocked_ips     |
| ci_sessions     |
| pastes          |
| trending        |
+-----------------+
4 rows in set (0.00 sec)

Stikked has a relatively simple schema with only 4 tables only two of which relate to pastes.

Describe the pastes table

mysql> describe pastes;
+--------------+---------------------+------+-----+---------+----------------+
| Field        | Type                | Null | Key | Default | Extra          |
+--------------+---------------------+------+-----+---------+----------------+
| id           | int(10)             | NO   | PRI | NULL    | auto_increment |
| pid          | varchar(8)          | NO   | MUL | NULL    |                |
| title        | varchar(50)         | NO   |     | NULL    |                |
| name         | varchar(32)         | NO   |     | NULL    |                |
| lang         | varchar(32)         | NO   |     | NULL    |                |
| private      | tinyint(1)          | NO   | MUL | NULL    |                |
| raw          | longtext            | NO   |     | NULL    |                |
| created      | int(10)             | NO   | MUL | NULL    |                |
| expire       | int(10)             | NO   |     | 0       |                |
| toexpire     | tinyint(1) unsigned | NO   |     | 0       |                |
| snipurl      | varchar(64)         | NO   |     | 0       |                |
| replyto      | varchar(8)          | NO   | MUL | NULL    |                |
| ip_address   | varchar(16)         | YES  | MUL | NULL    |                |
| hits         | int(10)             | NO   | MUL | 0       |                |
| hits_updated | int(10)             | NO   | MUL | 0       |                |
+--------------+---------------------+------+-----+---------+----------------+
15 rows in set (0.00 sec)

The pastes table holds the actual pastes in the ‘raw’ field which is a longtext string. If we have the paste id from the URL we can select for that paste.

If you wish you can check that you have the right paste before deleting the item.

mysql> SELECT pid,title,name FROM pastes WHERE pid='8ae4ae1a';

If you need to see the content to be sure you can add some of the raw data (100 characters) to your query, this will probably not look very pretty as any return characters will disrupt the layout.

mysql> SELECT pid,title,name,left(raw,100) FROM pastes WHERE pid='8ae4ae1a';

Once you are sure that this is the post to delete execute the delete statement with the same ‘where’ clause.

mysql> DELETE FROM pastes WHERE pid='8ae4ae1a'

This will have removed your paste. To be tidy the entries for this paste in the trending table can also be removed.

mysql> DELETE FROM trending WHERE paste_id='8ae4ae1a';

If you have a list of items to remove you can use this alternate where clause, using the ‘in’ keyword.

mysql> DELETE FROM pastes WHERE pid IN  ('8ae4ae1a','<p-id2>',...,'<p-idn>');
mysql> DELETE FROM trending WHERE paste-id IN ('8ae4ae1a>','<p-id2>',...,'<p-idn>');

Quit mysql

mysql> quit

Other cases for deleting pastes would be where your paste bin has been spammed, in which case you could select pastes to delete based on the spammer’s ip_address. In this case you would need to tidy up the trending table with a more resource hungry where clause.

mysql> DELETE FROM trending WHERE NOT paste-id IN (SELECT pid FROM paste);

Free on-line services, or do you roll your own?

The first time I was hit by a ‘free’ service being withdrawn was probably the worst time. It was back in the late 90’s when I used a ‘free’ on-line chat forum service as an adjunct to a website I created for my old school’s reunion website. This service was withdrawn with 3 days notice and the site’s popularity never really recovered from the blow.

For the most part these ‘free’ services are monetised through the users identity being sold as a merchandising opportunity. Sometimes these services are used as a taster or sales lead for a paid service with higher functionality, quality or quantity of the service. Some  ‘free’ services are closer to being genuinely free, such those offered by open source projects in support of their activities, although increasingly the commercial realities of running these services lead to advertising support of some kind.

Given my early experience with the chat-room, I’ve always used these services with my eyes half-open knowing that I’m not getting something for nothing, making a calculated decision about the compromise being made and the relative security of the content invested in the service. Over the years I’ve been caught out a number of times with ‘free’ services being withdrawn. More recently it has been Google services being withdrawn, admittedly with adequate notice, but all the same, with some inconvenience.

This year I’ve started to run or manage for myself some of the on-line services I use. The first was this blog. Previously I used Posterous and Google’s Blogger; The Posterous service was withdrawn and after the withdrawal of Google Reader, I’m not convinced that Blogger will be around for the long term.

There’s a cost to running your own services, either paying for a hosting service or running your own machine from home. Although it might seem like a cost free option to run your services from a home PC, in reality the cost of the electricity to leave it running 24/7 (approx. £1 per watt per year) may outstrip the cost of a low cost shared hosting service, which will also usually provide some form of additional backup and resilience. If you can squeeze you requirements into an ARM based machine like a Raspberry Pie or a low powered Atom based machine it might be worth running your own. So unles you have some very particular requirements its worth considering a hosted solution.

When I started out I just wanted to run this Blog and I managed to buy a year’s hosting from Tsohost for £12.99, although it would be £14.99 without the discount code I used. So far the service has been good.

The other services I’ve started to run for myself are a Google Reader replacement and a Paste Bin, but there’s a long list left where I need to decide on whether to continue to accept the compromise.

 

 

Vi Hart’s Twelve Tones

Vi Hart’s Twelve Tones What an amazing video.

12Tones

I subscribe to Vi Hart’s channel on You Tube, she does short videos on maths with amusing animation. Today Twelve Tones appeared in my in-box, this is a stunningly original and clever 30 minute video about 12 tone music, copyright, maths, science, Schoenberg, The Bowl and Laser Bat, and more! A lot of the musical stuff went straight over my head, but an awful lot more seemed to stick, I’ll need to watch this again.

 

History of Intel’s Processors

Security Now Podcast – Episode 410 – Interesting Intel History

Intel 80286 Processor

Intel 80286 Processor

This week’s security now episode is particularly interesting, it describes the evolution of the Intel processor family as used in PCs. Steve Gibson explains the key architectural twists and turns that were taken as the processor evolved from 8 bit to 32 bit. Anyone having to deal with software on Intel based machines has most likely stumbled across the terms Real Mode and Protected Mode at some point. This podcast presents a clear description of these modes of operation and some of the practical constraints they impose upon the operation and architecture of the processor family. What makes this particularly interesting is that the context of the explanation itself becomes an explanation of the underlying programming of Steve Gibson’s ‘Spinrite’ disk repair software and some of the upcoming development work that will further improve its operation.

http://twit.tv/show/security-now/410