Having used an iPad for the last week whilst working on URY’s Radioplayer Webview, as part of a hack-week (more on that soon I hope) I have come to the informed conclusion that I don’t like it.
I’ve always been reserved over the usefulness of tablets, and mostly think of them as pointless: I can either use my laptop or my phone, both of which I normally have with me. The iPad in particular has frustrated me because it is basically a large iPhone iPod touch, which I don’t like much either. Don’t get me wrong, I don’t dislike apple. I am currently writing this on my MacBook, which I think is great, and I’m a massive fan of Logic for audio related work. However I feel the current tabletisation of OS X is making it weaker, not better.
But back to the iPad. The main thing I find is that is is cumbersome, now this I admit would be the same with any 10” tablet, so isn’t directly a fault of the iPad but it is too big and heavy to hold in one hand and use, its weight is quite noticeable in my backpack, and even sitting/lying down and holding it rested on something else, is awkward. I can see some use in having more screen real-estate than a phone for some situations would be useful, but when it comes to size and weight, I’d prefer the smaller screen.
The next thing I don’t like is iOS, now I have to say I’m not overly adept with using it and if I was then I would probably like it more than I do but as a hardened android user, I find it unintuitive, cumbersome and lacking in features. Also the blocking of applications to use their full potential unless they are made by Apple just seems backward. The only really good or useful apps in the App Store are expensive and it’s hard to find anything else.
Having said this, after a week of tablet use, I could see myself using one day-to-day (a tablet, not an iPad) and actually finding it useful. So it has changed my mind in that respect, I no longer think they are completely useless. However I don’t think I’d ever get an iPad, it would probably be something like the Nexus 7, nice and androidy, and not stupidly big and heavy. Of course there is the iPad mini, why they didn’t just start with that form factor I don’t know… Well I do, this is Apple we’re talking about here, they will only bring out new / improved features if they can make a lot of money from it, so they have to start by selling you a bad product, then slowly bring out newer versions that slowly fix the issues that were selling points in the original, but by the final revision are major flaws.
In the course of the past few days I have discovered parts of CSS that I never knew existed, but have often wished did in some form or another. Amongst these is the calc() function which lets you calculate values for properties, such as calc(100% - 3em).
The one I’m most excited about for the moment is Flexbox or the Flexible Box Layout Model. I first discovered this from Paul Irish, on his flexbox tutorial over on html5rocks.com however as warned I soon discovered the issues with the changing spec of flexbox and the many versions implemented (or not implemented) by different browsers.
The issue is as browsers implement moving specification and then it changes drastically so much to break *everything*. So now there exists the 2009 spec (display: box) which is in quite a few browsers, some mixed up 2011 stuff from a transitionary period which doesn’t exist in browsers but is scattered across the internet in various guides as ‘how to use the new flexbox’ (display: flexbox) and lastly the current implementation (at time of writing) which is implemented (at least partially) in all modern browsers.
From what I can see there don’t seem to be many guides (if any) that cover the current specification. So mostly for my benefit in any future working with flexible box layout here’s my quick summary of flexbox, I hope it helps anyone else who happens to stumble across my blog.
The css properties you need are:
-webkit- prefix needs to be added to all the properties, other than display which needs it added to the value ie. display: -webkit-flex;
And then I got to firefox which ‘supports’ it. Or rather it will support it in version 20 (stable at time of writing is 17, Dev/Aurora is 19). In 18 and 19 it can be enabled by changing the flag layout.css.flexbox.enabled to true and even then only single line is supported.
So the project I’m working on that brought this flexboxing all about needs a header/footer with left, right & centre, and centred content that always stays in those relative positions no matter what the display size is. This is why flexbox is ideal in my situation, however I would say building an entire website structure from flexbox for the majority of applications is probably not a good idea. The best layout model is probably CSS Grid, however as no browser has got round to implementing it yet, that wil have to wait.

My standard method for doing such a layout would be floats, however I wanted to give this a go. So taking my code:
<header class="box"> <div class="left"> <div class="centre"> <div class="right"> </header>
I made my CSS:
.box {
display: -webkit-flex;
-webkit-flex-flow: row;
-webkit-justify-content: space-between;
display: flex;
flex-direction: row;
justify-content: space-between;
}
.box > * {
-webkit-flex: auto;
flex: auto;
}
.left {
text-align: left;
}
.centre {
text-align: center;
}
.right {
text-align: right;
}
My flex-flow and flex lines are a bit extraneous, but particularly whilst I’m developing I like to set things manually do I know what’s going on. Also using flex means that each flex item fills out its space, rather than just sitting in position.
This works for creating the header and footer how I want them, but to get the main content right in the middle more work needed to be done. Time to add a wrapper div (OH no!) as unfortunately you get some weird things happening if you try to use the body as a flex item container. Actually having just done it, you can use the body to wrap flex items, so all is good =) My page structure has <header> <section> <footer> so each of those becomes a flex item in its own right, this time vertically in a column and the section element gets aligned centrally. My full css is:
.box {
display: -webkit-flex;
-webkit-flex-flow: row;
-webkit-justify-content: space-between;
display: flex;
flex-direction: row;
justify-content: space-between;
}
.vbox {
display: -webkit-flex;
-webkit-flex-flow: column;
-webkit-justify-content: space-between;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.box > * {
-webkit-flex: auto;
flex: auto;
}
#display section {
-webkit-align-self: center;
align-self: center;
}
.left {
text-align: left;
}
.centre {
text-align: center;
}
.right {
text-align: right;
}
with .vbox and #display applied to the body for this page layout.
And that’s about all for now, coming soon: WebSockets
(Source: developer.mozilla.org)
I’ve recently been building a new website, well newish. It’s a re-design and replacement for a website written a couple of years back and made in the CMS Drupal. I also recently read (albeit rather old) an article on URIs not changing. Now this prompted various thoughts into my head, some of which I had had whist designing this other website. Such as why do I have to have .html on all my URIs? The old site most of the content was coming from didn’t (I know this is down to mod_rewrite for fancy SEO urls by Drupal, but all the same).
So I started to try and find out what Sir Tim was on about here, something really simple you can add that makes it ‘just work’ that doesn’t sound like any web development I’ve done before… There seemed to be lots of posts from people who had also read the article and were looking for the answer, but no-one else seemed to know it, nearly everyone pointed to use some variant of mod_rewrite to various degrees of complexity. But then I found the answer, it really was quite simple, enable MultiViews in your apache config for that directory, and it would ‘just work’ you could even have it auto detect language setting from the browser.
Options MultiViews
A quick update and build later and both the site I was working on and my main website were extensionless and wonderful. However this was not to be the end of the story.
The main point of Sir Tim’s article is that uris should not go away, even if the content changes a bit, or the website is redesigned, or passes to someone else (all three of which were happening on this website). So earlier this night, having almost completely finished the site, I set about creating the redirects for the pages I’d moved to renamed.
However, after wrestling with apache rewrite and various server configs with it still not working properly, I remembered what I had had to do to get multiviews working in the first place… Helpfully the h5bp developers had configured multiviews to be disabled, which i had commented out. The reason behind this is it causes problems with redirects… So having enabled it, then tried to add a number of redirects they just wouldn’t work. Back to the drawing board (why would you write code on a drawing board?)
A bit more googleing later and I came up with a solution, the first of which was simply to re-create the multiviews effect by rewriting ‘file’ to ‘file.html’ nicely behind the scenes. However this did not solve one of the issues I had with MultiViews: someone can still access the .html file with extension (particularly if your website has already been crawled with it), thereby serving duplicate content a rather huge no-no. Obviously my previous attempts to redirect this failed due to multiviews blocking the redirect.
# If extensionless page URL with ".php" added resolves to an existing file
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
# rewrite extensionless page URL to .php file
RewriteRule ^(([^/]+/)*[^./]+)$ /$1.php [L]
http://www.webmasterworld.com/apache/3800500.htm
Then I found a second solution, that had everything I wanted. It would give you the file from just ‘file’ it would redirect you to ‘file’ from ‘file.html’ and it would even remove index(.html)? from the URI to give you the root dir. Lovely.
<IfModule mod_rewrite.c> DirectorySlash Off
RewriteEngine On
RewriteCond %{THE_REQUEST} \ /(.+/)?index(\.html)?(\?.*)?\ [NC]
RewriteRule ^(.+/)?index(\.html)?$ /%1 [R=301,L]
RewriteCond %{SCRIPT_FILENAME}/ -d
RewriteCond %{SCRIPT_FILENAME}.html !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(.+)\.html$ /$1 [R=301,L]
RewriteCond %{SCRIPT_FILENAME}.html -f
RewriteRule [^/]$ %{REQUEST_URI}.html [QSA,L]
</IfModule>
http://forum.modrewrite.com/viewtopic.php?t=37515
So now multiviews is back off from the site and all this lovely mod_redirect goodness is in. My main site however shall keep multiviews for a little while, whilst I try to solve the duplicate content issue and update what Google has crawled.
So it’s now the summer holidays for me (3 months from The University of York, thanks =P), well it has been for a couple of weeks. A lot has happened this term, exams, finishing project work, finishing the year, exploring the campus, discovering URY history, hanging out with friends, going to Whitby, and all sorts of things that I can’t remember due to the busyness. It has been busy, but it’s been great fun. Even with the pressure of exams, which never bother me too much however I’m glad to say I passed the year fairly well and shall be continuing onwards on my journey of becoming an Engineer in Computing.
With a rapidly diminishing 3 months ahead of me (it always goes quicker than you think, particularly the longer you have, I find…) I have a fair amount planned, and a fair amount ready to be filled with all kinds of randomness my friends might come up with to do.
The majority of my time is going to be taken up with the Olympic Games in london this year (only 11 days now!) as I am a Volunteer, or a GamesMaker as we’re called. I’m working in the victory ceremonies team throughout the summer, and am greatly looking forward to it =D
My other plans involve finally finishing my website, doing some webdev and server maintenance for URY, relaxing, hanging out with friends, going to the pub, some LAN gaming, film watching & generally having fun =)
Oh and writing some more blogs, starting now!
So it’s been a little since my last post, and I’m currently leaving you hanging as to what to do with iptables. So I thought I ought to write a quick post. Tbh it’s probably not even been that long, but it feels like it. I’ve just come to the end of my first week of summer term, which has been good fun. It’s nice to be back into the swing of things at York, and it’s also nice to have a slightly less busy timetable than last term. I’ve still got lots planned, for this blog and the website in general, so hopefully those will slowly weedle their way out over the next few weeks. Obviously uni work is going to take priority, and I’m not going to keep posting “sorry no posts” blogs. Personally I see no point. If you’re not posting even vaugely good or interesting content, then there isn’t a lot of point in it. So my blog will probably stay fairly sporadic with blocks of posts when I have time to write them and some biggish gaps in between. But I see nothing wrong with that, as it means I aim for (generally) higher quality posts, than rushed mediocre posts. So this will probably be the only blog post about not posting often, and I only see that as a good thing =)
Or rather, no cookies until you’ve finished all your vegetables and opted-in (mostly the opted-in part).
So I discovered today, or possibly rediscovered, about the ICO cookie regulations that were actually put in place last year, but the good old UK government decided to give webmasters/website owners a year to comply before allowing the ICO to take any action.
Basically, because most Internet users are not the most savvy of people, according to the ICO (and I might have to agree with them to some degree there), they don’t want people to allow themselves to unconsciously allowing data about themselves or their browsing etc. to be stored in cookies on their computer (or other device).
In 2003 there was legislation that websites had to allow users to be able to opt-out of cookies if they wanted to. But in 2011 that got re-written to be you have to have informed consent from each user that cookies are given to.
This comes into force soon, and as a person who is normally fairly hot on news of this nature, I find it surprising and slightly worrying that I only found out today properly what it’s all about.
So what are cookies and how do you get them (or not get them)?
Cookies are little data files your browser stored on your computer that are sent by websites. These are generally to improve your browsing experience. This could be by storing your preferences on a website, or to keep you logged into a service, or remembering you items in a shopping basket. Or most commonly by tracking what pages you visit within a website.
You may wonder how page tracking helps you as a viewer, well if webmasters can see what content is popular on their website then they can develop that content and make it better. If there is an area that is lacking then it can be brought up for improvement, or pruned off the web tree. So in allowing site owners to track within their site you help them to create a better web for everyone.
So why the ban on cookies? (they are yummy you know)
There are certain ways in which they can be used in a less desirable way. Advertisers can use them to track across all the websites that show their ads, this allows them to target their advertising more towards you, dependant on your browsing habits. Now this seems to be the main type of thing the ICO want to stop, but in doing so they are causing pain and annoyance to webmasters.
The main issue really is that people are not informed. However there will always be people who have no clue, yes they probably should be protected, but it shouldn’t have to cause hindrance to everyone else.
Also this ruling is completely dependant on webmasters implementing solutions on their own sites. If they really wanted to inform people they should be targeting browser developers.
So the cookies I give you (for free, and who doesn’t like free cookies) are from google analytics, which let me see what the best parts of my website are, so I can make them even better :)
As a final note if you want to stop advertisers tracking you, the best way is to block the ads completely. If you have a browser that uses extensions, and I strongly recommended that you use one if not (Google Chrome, FireFox) then look up ad-block, the Internet without adverts is a Lovely place :)
So I got back to York today, and after an evening of actually doing some work, then not a lot decided to have an earlier night. It was going to be the earliest for a few weeks.
But guess what? I’m still awake, it turns out after a long day travelling after not much sleep last night I can’t get to sleep :/ and I didn’t even sleep on the train…
Oh well time won’t be wasted, if I can’t sleep then I might as well queue up a few blog posts.
I apologise in advance if the quality of the next few posts that show up aren’t of the quality I’d usually atain for. Although you might not think the usual is up to much anyway :p
After several hours work installing dependancies then redoing bits that went wrong, I successfully managed to compile and install liquidsoap from source and get it fully running with init.d script and stuff. This may not sound like a big deal, but it made me pretty pleased, especially as I haven’t really done anything like it before. Also somewhere along the way I managed to forget that today was Saturday, and Sunday comes afterwards… More on liquidsoap soon :)
So now down to the nitty gritty of actually getting rules written for iptables.
To add a rule the commands can range from very simple, to long and complex. The simplest type I use is something like this:
iptables -A INPUT -d 109.200.20.250 -p tcp --dport 80 -j ACCEPT
A quick break down of this:
The first tip I learnt was to write these commands into a bash script, as having to re-type them (even with bash_history) would be a laborious task when clearing and reloading rules during the configuration phase.
So I write commands like this for all the ports I want open, and then finish the bash off with:
iptables -A INPUT -d 109.200.20.250 -j DROP iptables -A INPUT -j DROP iptables -A FORWARD -j DROP
This tells iptables to drop, firstly anything sent to me, then anything trying to pass through my ip. You may wonder why I’m dropping everything, surely that invalidates all the previous rules? Well no, it doesn’t as when a rule is matched it immediately jumps to its destination ignoring all else, which is why these must come at the end of the rules.
You may also be wondering, why DROP? I’ve heard about REJECT. The difference between them is subtle, as both drop the packets. However, reject sends back a response to say ‘no access’. So to minimise traffic, it seems best from my point of view to drop anything else.
There are advantages and disadvantages to doing it both ways, but so called stealth isn’t really a reason for or against either. A port scan will return closed on reject, and open on accept, but something like filtered on dropped packets, so there isn’t much stealthy advantage.
Now, there is a lot more that can be done, the rules I’ve mentioned so far are truly the most basic, but more on that in the next part. I also mentioned Chains, those will come up again sometime in the future. I also still haven’t covered how to actually make this into a working firewall.
More advanced configuration in part 3.
So today I started my endeavour into the wonderful world of iptables. I don’t think I’d be the first to say that there is a steep learning curve, at least to get the most out of what it can do.
The basic setup is fairly easy, open the ports you want to use, and reject everything else. But even getting that far has interesting twists and turns. Most of the rest of this post, if just going to be me documenting what I did for future reference, (and probably most posts on this blog will be too). But hey, if it means I learn something new, have it documented so I don’t forget, and can share some knowledge with the world, then that can’t be a bad thing =)
First Steps
First things first was finding out how to configure it. My server runs Debian Squeeze, and I have to say I am still fairly new to any linux. I like Debian as how it organises itself makes sense to me, so my first thought is to look for iptables in /etc/ however it’s not.
A quick google and I find myself in a wealth of iptables information, most of it (as usual when I’m googling Debian) out of date. So I find a useful iptables guide for sarge and get some basic stuff ready.
Confusions
Iptables doesn’t remember its own settings, now on first looking at this I thought it was a little stupid, but then I realised that everything else only ‘remembers’ due to loading config files.
From sarge onwards there is no init.d file for iptables, this also seems a little backwards, but I can see the sense up until Squeeze’s dependancy loading (I know there are ways to manage this pre-Squeeze but Squeeze makes it simpler). Obviously you want your firewall to be up and running before your networking has connected, otherwise you’re going to be unprotected. So now, you load your configuration from within /etc/network/{if-pre-up.d,if-post-down.d}. Now for any hardened linux user building your own config scripts and stuff would be second nature, but to me and other newbies it may come as a surprise in Debian.