Tweet Log – 21-01-2012 to 27-01-2012
- Sweet! just got my ticket to the Auckland Android Developer Lab ->
- MPAA Wins the Oscar Screener Battle, but Loses the War http://t.co/jMwMsbs8 ->
- Canadian teenagers send Lego man into space http://t.co/xtgD1avV ->
- Google+ opens to teens, launches youth safety features: http://t.co/eSNzqrTy ->
- Here is a really good overview of ACTA: http://t.co/pJdtrtCR ->
- Members of parliament displaying Guy Fawkes masks in the Polish Parliament: bit.ly/wW8wH7 #ACTA #copyright ->
- Poland signs ACTA, 100 thousand people protest across country (video from a protest in Krakow) http://t.co/gsLNwltu ->
- Event Cinemas has deal that allows you to pre-buy tickets for $8, offer on for the next 4 days http://t.co/j4KcSVWQ ->
- 22 EU states sign ACTA http://t.co/2fZcFoaJ nooooooooooooooo ->
- lol… guy decides to mess with his cousin who posted his new phone no on Facebook: http://t.co/9yL7Nq5b ->
- Mega-man: The fast, fabulous, and fraudulent life of Kim Dotcom http://t.co/dYFroR9Q ->
- The Reality of HTML5 Game Development and making money from it http://t.co/1rfhxlbS ->
- HP open sources Enyo framework from webOS, now cross platform: http://t.co/mVaJi2cK ->
- Raspberry Pi's GPU twice as fast as iPhone 4S ? http://t.co/MOjpyGZi not bad for a $25 computer ->
- Ubuntu doing away with menus… replacing it with a HUD http://t.co/IC8xJmzg not so sure about this ->
- Twitter Bootstrap 2.0 due 31 Jan, here are preview docs http://t.co/fBU0mj9o includes responsive design features ->
- Its always fascinating to look over the info that Google has on you: https://t.co/P9RNn0SK ->
- Google consolidates 60 different privacy policies to 1 http://t.co/n5vc5gpb ->
- An Introduction To Object Oriented CSS (OOCSS) http://t.co/qQRZtJI4 ->
- The real reason Megaupload was shut down? https://t.co/as5MkR6U #tinfoilhat ->
- Interesting service http://t.co/0aHTw6bc shows what can be achieved when you have an eco-system of open APIs ->
- All kids should be taught to code: http://t.co/m1N6iJnD ->
- The next threats: ACTA and H.R 1981 http://t.co/kPoFh3Jp even worse then SOPA and PIPA ? ->
- 10 Wow Initiatives by Airlines and Airports: http://t.co/8Km13vz8 ->
- Oracle gets smacked again in googke Android suit but judge gives them 3rd go at coming up with realistic figures http://t.co/FC8wQhSW ->
- "Fortnight" is such a strange word…. http://t.co/Oxb6oZdH ->
- New meaning of going deep undercover????? http://t.co/QN63q5o5 ->
- BTW free @flyairnz airpoints membership with promo code JOINAP check out: http://t.co/l6RBotXy ->
- Defending Privacy at the U.S. Border: A Guide for Travelers Carrying Digital Devices: http://t.co/SUMlA3tP ->
- US customs blocking DVDs that depict "insurrection against the US": http://t.co/cp8dixwR ->
- SOPA bill author has another dodgy bill in the works… this one in the guise of stopping child porn http://t.co/gtUo7l4P ->
- ACTA will force border searches of laptops and other devices ? http://t.co/E0Nnii9x ->
- Oh dear looks like ACTA is going to be signed 26 Jan…. Worse the SOPA/PIPA ? Who knows its all secret! ->
- How U.S. Lost Out on iPhone Work: http://t.co/jJClrUyd ->
- MPAA publicly threatens to cut off funding to politicians who dont stay bought http://t.co/x5ikZsLL ->
- Google open sources SkyMap http://t.co/RgwCkSoA ->
- Yay SOPA and PIPA are 'dead' http://t.co/Umfs5CeW ->
Tweet Log – 14-01-2012 to 20-01-2012
- Lol so true http://t.co/N7mHUo0Z ->
- Why the feds smashed #megaupload http://t.co/DHMiT6pR ->
- Here is the complete list of VS achievements http://t.co/zHi084ns ->
- The new Visual Studio achievements are pretty funny: http://t.co/gcXNKMxL ->
- Google changes algorithm, now takes page layout into account: http://t.co/OWAbrzV2 if your content isn't above the fold you won't rank well ->
- Anonymous knocks out FBI, DOJ, universal, MPAA, RIAA and Warner sites in reponse to #megaupload takedown ->
- Megaupload shutdown kinda proves SOPA and PIPA aren't needed #sopa #pipa #megaupload #copyright #lotsofhashtags ->
- NZ helps shutdown Megaupload by arresting CEO, CTO and others in Auckland: http://t.co/kJmvLPeD #copyright #sopa ->
- Wonder what's going on downtown this morning, tons of Maori Wardens about ->
- Iranian dev sentenced to death for creating photo upload software http://t.co/ht9uFbOY ->
- Sigh trains all fubar ->
- Congressional support for SOPA/PIPA swings from 80/30 (for/against) to 65/102 in the last 24hrs http://t.co/VERHPPlB well done blackout ->
- Sal Khan explains SOPA: http://t.co/V8NMehOa ->
- SOPA for Non-Techies: http://t.co/U3hBJmRm ->
- LOL, guy buys .com domains of Senators who support SOPA and link them to anti-SOPA site: http://t.co/dvfd8VMt ->
- Love the "For dummies" cover generator… here is my first attempt: http://t.co/Jh4nB2Gk ->
- Atlassian’s 2011 Revenues Were $102 Million With No Sales People http://t.co/gtmdMaRW ->
- Could American web censorship be good for the rest of the world ?? http://t.co/XTievTfl ->
- Visualizing SOPA on twitter http://t.co/wrhzH90N ->
- Just watched Skyline… seriously that was the ending? WTF ->
- Cool, writing an app using only pixels and photoshop http://t.co/uZ55A9V1 ->
- Google puts a anti SOPA link on its home page http://t.co/YFXFDQ7v ->
- Wikipedia has just gone dark http://t.co/W7yhAlW5 ->
- Just found out my grandfather has passed away #sad ->
- The danger of outsourcing ?? Goggle picking up the pieces as 2 different groups of contractors misbehave: http://t.co/WNHtPmJo ->
- a very good point : http://t.co/6Uaumrxu ->
- MPAA calls protests an "abuse of power": http://t.co/F4VhS97L ->
- mPass listed as 6th best android app in Dec M2 mag http://t.co/JP27jCvz ->
- Very good overview on how SOPA and PIPA are supposed to work http://t.co/tzt8v1G4 ->
- Good coverage of the internets response to SOPA and PIPA http://t.co/O7bdemBt ->
- Goigke to protest SOPA/PIPA on home page today ? http://t.co/moNiNBAy ->
- Have blacked out my blog…. http://t.co/wT4leZNo ->
- Wikipedia explains why they are blacking out to protest SOPA and PIPA http://t.co/nYpoqaVx ->
- SOPA is a red herring ??? http://t.co/MUV9KCeH ->
- Command and Conquer "ported" to HTML5: http://t.co/d2HpTHRR ->
- Wikipedia to shutdown to protest SOPA: http://t.co/WGCg8y5n ->
- Join me & change your profile picture to protest SOPA: http://t.co/X4AH7HzX #BlackoutSOPA ->
- three.js a Javascript 3D engine.. pretty impressive demos: http://t.co/VxTQ4f7E ->
- I got a dig bick. You this read wrong. You read that wrong too. ->
- Alexis Ohanian vs NBC – Debating SOPA: http://t.co/i7ggx5vX ->
- I see the new digital signage is up at Britomart. What a complete cock up ->
- Trains back online…. bliss ->
- Top 10 Javascript MVC frameworks http://t.co/vDzxZTxd ->
- The Whitehouse's response to SOPA https://t.co/1R97jxNF ->
- Interesting way to make $300 million dollars http://t.co/A4g0tGgT ->
- Looks like Oracle's case against Google is falling apart…. http://t.co/jJEF6Dyy ->
- Twitter Bootstrap generator… easily customise the framework http://t.co/QEubq363 ->
- Tim O’Reilly: Why I’m fighting SOPA http://t.co/Qkz0lif8 ->
Tweet Log – 07-01-2012 to 13-01-2012
- the Steve Jobs action figure: http://t.co/cpGt7wnO ->
- The Pirate Bay Will Stop Serving Torrents: http://t.co/fZerysDY ->
- Samsung's transparent Smart Window : http://t.co/GUQ73mwb ->
- The author of SOPA is a copyright violator: http://t.co/ot635j5w ->
- Just for you @DeadCheerleader: https://t.co/fXvWIODW ->
- Loving the Android lint tool….. not loving the number of issues its showing up in this app I'm fixing up :( ->
- Devs jump to OpenstreetMap as Google implements crazy Google Map's charging model: http://t.co/AoEtXdBw ->
- yellow tie, pink shirt and what looks to be a tweed jacket ??? Rob Fyfe's dress sense = out the window: http://t.co/tj5IJeqE ->
- Raspberry Pi enters manufacturing: http://t.co/OeeqKFUd ->
- UK children to learn real programming in school instead of Office skills: http://t.co/sD4ZY55P need to do this in NZ ->
- Google open sources Google Body code… free layered, searchable 3D model viewer for all: http://t.co/GsztLt1c ->
- Easter eggs hidden in Apple's app icons http://t.co/nnb4eZ7G ->
- Holy cow… stunning graphics generated by 4kb sized .exe files: http://t.co/csoFQOml ->
- How SOPA would affect you: FAQ http://t.co/1yWl2y4P ->
- Reddit "blacking out" to protest SOPA on Jan 18th: http://t.co/68462MKh ->
- Currently stuck in update hell… all I wanted was to upgrade one small plugin :( ->
- Computer Programmers… the new political elite ? http://t.co/7kwgtrEP ->
- Oracle getting into BigData with Hadoop appliance http://t.co/i3GVoqPt ->
- This bus instead of train business is getting tedious ->
- Awesome cover of Somebody That I Used To Know http://t.co/ExegNX7n ->
- MS ports "cut the rope" to HTML5 http://t.co/dWSr6C5f ->
- updating….updating… updating… #needfasterinternet ->
- Reddit Founder, DNS Hacker And Other SOPA Critics Will Address Congress In Hearing: http://t.co/mZIyCBH6 ->
- Interesting write up on @flyairnz Koru Express lounge: http://t.co/W9hXZVaA ->
- Glue is a simple command line tool to generate CSS sprites: http://t.co/6m3l7xz6 ->
- OnLive now streams Windows desktop apps to your iPad http://t.co/kJyPoHwe ->
- MakerBot Replicator: personal open source 3D printer for < $2k: http://t.co/sRq7fC9z #wantone ->
- Event Programming with Google Guava EventBus http://t.co/k679PBs1 ->
- Air New Zealand Wins Airline of the Year: http://t.co/buS2qmPV ->
- Wow 95 different Android device & OS version combos in the logs… looks like I lost my bet… ->
- German Hackers Are Building a DIY Space Program to Put Their Own Uncensored Internet into Space: http://t.co/Dry4Fz4b ->
- Interesting… was just looking at some logs and I can see accesses from Samsung Galaxy S & SII running ICS 4.0.3 ! ->
- Nice Portal 2 inspired cocktails: http://t.co/54K5FNJP ->
- New post on my blog: "Building a modern web app, some learnings" http://t.co/Fpfkoj9d ->
- Watching website traffic with Google Analytics new real-time feature… very interesting ->
- Very very cool… http://t.co/b20Zq6GQ give it a try ->
- 35 Incredibly Useful Apps From 2011 http://t.co/1X8fwMbG ->
- New version of @flyairnz mPass app for Android is out: http://t.co/ykzvYyqp ->
- Awesome.. built by ex I&V dev: http://t.co/R7FlTRiT ->
- Best markdown editor for windows I have found so far: http://t.co/o55ypvK5 ->
- Bah no trains today… having to hang around for a bus :( ->
- HDMI dongle turns your dumb TV into a smart Internet connected TV running Android http://t.co/QecaPkWV very nice idea, open source too ->
- Facebook Bootstrap css framework http://t.co/EfFRbNpa ->
- Android app that scans product barcodes and tells you if the product was created by a SOPA supporter https://t.co/watUYMlb ->
- Minimum Viable SEO http://t.co/5PkxG42e ->
- South Park RPG looks just like South Park cartoon http://t.co/mBGvdhw2 ->
- Fountain Codes…. interesting algorithm http://t.co/8dpC4LzQ ->
Building a modern web app, some learnings
I recently built a fairly rich web application from the ground up. Whilst I’ve being building web apps since the mid-nineties this little project had a different flavour to it and I thought I’d go over my learnings here.
Firstly why was this project different:
- its a Facebook app and uses their JavaScript SDK. This means that 99% of the app runs client side with only a small bit of server side code.
- I’m was the sole developer. Normally I work with 2 or more other developers, focus on the back-end work and leave the bulk of front-end stuff to others
- rapid development approach. The app was built quickly with me working closely with a UX guy and a designer. Whilst the functionality was locked down early on, the user interface and interactions evolved rapidly and iteratively.
First observation: its so easy
OK that is slightly facetious, but modern CSS and JavaScript frameworks mean that you don’t have to be guru to build nice looking, smooth functioning, cross browser applications.
For this application I used the Twitter Bootstrap CSS framework and the jQuery Javascript framework.
Get a designer
Yes I know I just said that it’s easy and you don’t need to be a guru to create nice looking apps BUT whilst Twitter Bootstrap encapsulates a great design, you are still going to want to customise it.
Designers have the knack of adding the odd image, drop shadow or bit of whitespace that can make a perfectly ok looking web page just suddenly pop. Not to mention the selection of color a palettes and general pixel pushing.
On a similar front having a UX guy on hand is invaluable. If you don’t have one, then read Steve Krug’s Don’t Make Me Think book and then go and find yourself a UX guy :)
The Facebook API is now pretty mature and is very stable (compared to the last time I used it a few years ago).
One annoying things is that the calls that you make to explore the user’s social graph (via the FB.api function) are very low-level and the data is returned in a callback. This can make your code very messy, since you often have to chain your app’s logic in the callback function, if your app needs data before it can proceed. For example:
FB.api('/me', function(response) {
// do something with response here
// make next api call (with nested callback) here
});
Additionally if you need to, for instance, retrieve friend profile data you can land up making hundreds of calls:
// grab all my friends
FB.api('/me/friends', function(response) {
$.each(response.data, function(index, value) {
// get profile for each friend (this triggers another HTTPS call)
FB.api('/' + value.id , function(profile) {
// do something with profile data
});
});
});
Luckily there is a better way, the FB.query and FB.waitFor functions. These let you run queries against a user’s data using a SQL like language (FQL) and then block waiting for the response. This greatly reduces the time it takes to retrieve data and keeps your apps logic a bit simpler:
var query = FB.Data.query('SELECT uid,name,current_location FROM user WHERE uid IN (SELECT uid1 FROM friend WHERE uid2=me())');
query.wait(function(rows) {
$.each(rows, function(index, value) {
// do something with friend data here
});
});
// rest of app logic continues here
Firebug
Get it (hopefully this isn’t news to you). This tool is invaluable for web development. It allows you to debug JavaScript, view the DOM, check network traffic and tweak CSS in browser.
It’s also a good idea to test you app in different browsers as you go. During this app’s build I had FireFox, Chrome and IE 8 all running so I could see that everything was working. Luckily by using Twitter Bootstrap and jQuery I had no cross-browser issues at all other then the fact that IE didn’t get nice round corners.
Make sure it validates
The W3C provides a tool for validating web pages. It’s always good to be sure that your pages validate, not just because it is good practice but because it stops browsers from entering their “quirks mode” which often causes odd and quirky behavior.
The Web Developer plugin for Firefox provides a handle shortcut for submitting your local HTML to the W3C validator.
In my case everything validated except for the Facebook namespace declaration and the custom Facebook tags such as <fb:like>. Whilst there are ways around this I decided on not been too purist.
HTML5
Try use HTML5 for your app. It works very nicely. For IE browsers (before 9.0) use the HTML5 shim to get some HTML5 support.
However Twitter Bootstrap does not support IE6, so I used this trick to make any IE6 browsers redirect the user to a “browser unsupported” page with tips on how to upgrade their browser. In the <head>section add the following comment:
<!--[if lt IE 7]><script type="text/javascript">window.location = 'notsupported.html';</script><![endif]-->
This uses the conditional comments feature of Internet Explorer to redirect IE6 browsers to the notsupported.html page, other browsers will simply treat it as a HTML comment.
Improving load times
It is best practice to load all the CSS files in the <head> section of the page and all the JavaScript files at the end of the page (just before the </body> tag). This makes the page feel much more responsive as the browser can start to render and layout the page before everything is loaded.
Having said that, a complex web app tends to pull in a lot of CSS and JavaScript files and minimizing the number of objects that are fetched from the server is a key factor in having a speedy app.
Ideally you only want your app to load a single CSS file and a single Javascript file. To achieve this in my app I concatenate the CSS files and JavaScript files (in the correct order) and then compress them using Yahoo’s YUI compressor.
Since I wanted this to be a repeatable process I used Ant to create a build script to do this. Firstly the concatenation:
<concat destfile="${tmp.dir}/all.js">
<fileset file="${www.dir}/jquery.min.js" />
<fileset file="${www.dir}/jquery-ui-1.8.16.custom.min.js" />
<fileset file="${www.dir}/jquery.masonry.min.js" />
<fileset file="${www.dir}/bootstrap-modal.js" />
<fileset file="${www.dir}/bootstrap-twipsy.js" />
<fileset file="${www.dir}/bootstrap-alerts.js" />
<fileset file="${www.dir}/app.js" />
</concat>
And then the compression:
<exec executable="java">
<arg value="-jar"/>
<arg value="yuicompressor-2.4.7.jar"/>
<arg value="${tmp.dir}/all.js"/>
<arg value="-o"/>
<arg value="${tmp.dir}/all.js"/>
</exec>
Now during development you don’t want to be dealing with concatenated and compressed files so my PHP pages contain a snippet like this:
<?php
if ($config['mode'] != 'prod')
{
?>
<script src="jquery.min.js"></script>
<script src="jquery-ui-1.8.16.custom.min.js"></script>
<script src="jquery.masonry.min.js"></script>
<script src="bootstrap-modal.js"></script>
<script src="bootstrap-twipsy.js"></script>
<script src="bootstrap-alerts.js"></script>
<script src="app.js"></script>
<?php
}
else
{
?>
<script src="all.js?@buildtimestamp@"</script>
<?php
}
?>
</body>
With mode getting set in my app’s config file.
Of course there are a ton of other things you can do to tune your app. Get the YSlow addon for Firebug and run the report on your pages to see what can be done.
Cache busting
Ant can also very helpfully update parts of your files whilst copying them around. This can be used to burn in all sorts of things, like version numbers and build timestamps. It can also be used create a effective cache buster when a new version of your app is released….
Firstly you need to set up an Ant property with an appropriate value:
<tstamp> <format property="buildtimestamp" pattern="yyyyMMddHHmmssSSS" locale="en,UK"/> </tstamp>
Then in your HTML you can append @buildtimestamp@ following to file references:
<link rel="stylesheet" href="all.css?@buildtimestamp@"/> ... <script src="all.js?@buildtimestamp@"></script>
Then lastly apply a filter in Ant when you are copying the files around:
<copy todir="${tmp.dir}">
<fileset dir="${www.dir}">
<include name="**/*.php" />
</fileset>
<filterset>
<filter token="mode" value="prod" />
<filter token="release" value="${rel}" />
<filter token="buildtimestamp" value="${buildtimestamp}" />
<filter token="builddate" value="${builddate}" />
</filterset>
</copy>
PHP config file
To keep things nice and clean, I created a config.php file looking like this:
<?php if ( ! defined('CONFPATH')) exit('No direct script access allowed');
// set this to '@' + 'mode' + '@' during development so that style sheets and javascript files are individually included (see index.php)
// ant build scripts will replace this at build time
$config['mode'] = '@mode@'
?>
Then in my other PHP files I pulled in the config file using:
<?php
define('CONFPATH','config.php');
require_once CONFPATH;
?>
As you can see from the comments and the Ant snippets above, I overwrite the mode value with ‘prod’ during my Ant build process to ensure that my compressed .js and .css files are used.
Miscellaneous files
Finally make sure you add a favicon and a robots.txt to avoid annoying 404 webserver logs. For fun why not add a humans.txt too.
Summary
Well that pretty much covers it. Hopefully there are one or two new ideas here that you can use in your apps. Feel free to post any questions in the comments section below.
Tweet Log – 31-12-2011 to 06-01-2012
- NASA's open source portal http://t.co/3SBNhUoc ->
- Holy cow who knew Lego minifigs were worth so much??? http://t.co/lgldJ9J8 time to look at my pile of lego ->
- Dynamic face substitution http://t.co/98vZrOl7 ->
- 3888 timelapsed pictures condensed into a single pic http://t.co/rhuxAkob cool ->
- Big tech companies planning a joint blackout day to protest SOPA? http://t.co/lIGANWH5 ->
- Google chrome team screws up ad campaign, Google Webspam team demotes Chrome home page for 60 days ! https://t.co/t18G8WFw c ->
- Tinkering with ZBrush again.. came up with this: http://t.co/Q72T5QRm not sure WTF it is… ->
- IE 6 usage falls to under 1% in US http://t.co/tAT1OxPw ->
- Study: Our Brains Are Injured By Fat Consumption http://t.co/3wKd9wtf ->
- Embarrassing Dad has worn a different costume to wave goodbye to teen age son on the school bus for the last 170 days http://t.co/qmPEuK0M ->
- http://t.co/ZGoNCVvt cleanup your permissions ->
- Belarus makes foreign Internet use a criminal offense http://t.co/F23qMQCC ->
- Obama forced into siging NDAA ? http://t.co/cHCUNRO2 ->
- Turn your facebook, twitter and other social media posts into a physical printed journal http://t.co/uvQZ3pBp ->
- Darknet plan http://t.co/zfoEpvqC ->
- Happy new years everyone ->
- Build your own CyanogenMOD with no experience… http://t.co/We4dUI6y ->
