The power of the web is just starting to pick momentum. There are lots of signs that companies want to leverage HTML5 in order to by more productive and everywhere (desktop, laptop, tablet, mobile etc’). It’s not only Facebook, Netflix and others that got to understand that with HTML5 you can have web apps that will give the user a very close feeling to what they are getting today in native apps. He are three quick videos that explain what is a web app, what is Chrome Extension and why you want to have Chrome book…
What is Chrome OS? or why you (might) want to have one
What is a web app? Here is the short answer
What is a Chrome extension?
And last but not least, with more then 1.2M views… Chrome and Gaga video
It will give you the ‘power’ of the IDE you like to live in… (well, more or less not 100%). You can get it and install it in this one line: curl -L https://github.com/downloads/jezdez/textmate-missingdrawer/MissingDrawer_2010-11-28.zip | tar -xf - && open MissingDrawer.tmplugin
Some more good bundles to start with are:
HAML & SASS Bundles – These are perhaps the most common bundles to be installed. If you work in HAML & SASS you’ll want these badly.
GIT Bundle – If you use GIT for your version control, then this is a bundle you can’t be without. It allows you to manage your repository from within TextMate, do blame checks and much more. There’s also an SVN Bundle if that’s more your thing.
CSS & HTML Bundles – Although TextMate comes with some of it’s own, you’re going to want to grab the ones from Minimal Design. They add fantastic tab triggers to virtually eliminate most typing.
jQuery Bundle – A great bundle for working with jQuery. Features tab triggers for many functions and some pretty good syntax highlighting.
WakaTime – A plugin to quantify your coding with automatic time tracking. I’ve not tested it myself but it’s looking useful for developers that wish to learn from each project and gain stats.
Shortcuts
^D – Duplicate Line/Selection (just like yy in VIM).
⌘T – Go to File – This shortcut is truly second to none. Instead of trawling through your project drawer or going through the folders in your finder, use this to quickly jump straight to any file you wish to be in.
⇧⌘T – Go to Symbol – This works in the same way as Go to File but for within a specific file. Trying to find a set method or a global variable? Look no further good sir, this is what you need. Especially useful for when you’re working with a massive user model!
⌘L – Go to Line – If you’re debugging a stack trace, you’ll want to remember this one. Jump to an exact point within a file to squash that nasty bug!
⇧⌘L – Select Line – Select the entire line of code you’re working on. Chances are you may want to follow it up with…
⌃⌘ + ARROW – Move Code – Move the selected code around the file, helps when doing some refactoring of that nasty functional code.
⇧⌃⌥V – Send selected to Pastie – This one is pretty unknown but handy. Send the selected code over to Pastie with a private URL for sharing the code – great when you need some feedback from a fellow developer.
⌃S – Simple Search – Most folks know about ⌘F as it’s the same in most applications. However in TextMate it loads up an additional window for find and replace which isn’t always what you want. This shortcut allows you to do a quick search in the current file iteratively.
⌘] and ⌘[ – Block indentation – Indenting manually can be a pain – use these functions to indent blocks of code quickly and easily.
⇧⌃T – To-do list – This feature scans the project for code marked as ‘FIXME’, ‘TODO’ and ‘CHANGED’. It provides an informative list of them along with comments.
There are many technology improvements that are pushing the web forward.One of them is WebGL. Web what?
Well.. it’s a shortcut for: Web-based Graphics Library which is a software library that extends the capability of the JavaScript programming language to allow it to generate interactive 3D graphics within any compatible web browser. Most of the leading browsers today got ‘some’ support for it. This New (amazing) video clip that was design for Chrome is showing the power that artist, developers and users got today under their belt (or their chrome…)
Or just check the source at ROME (Pss… do it from Chrome and not other good browsers).
HTML5 technology is harnessing developers with a very unique way to be ‘everywhere’.
Unlike, the old Java days (1996-1997) where we thought that ‘write once run everywhere’ is going to be the future. This time, all the major browsers (yes, Firefox, Chrome, Safari and even IE) are supporting it. You can build today web apps that looks and act like ‘native’ apps by using HTML5 features. Not only, you get the option to target iOS, Andriod, PalmOS, Windows7 phones etc’ with great user experience you code base should be ‘write once’. It’s not only the smart decision for start ups and independent developers but rather for all type of companies. Even gorillas like Netflix is taking this direction. Main features that you might want to checkout are:
Geo location
Video (without flash…) – I’ve told you… it’s 2011.
Audio (again – I know you don’t believe me but try it with out flash).
File Access is an API for reading file content in JavaScript. Here is a good article about the subject “Exploring the FileSystem APIs“. It give you all the nice simple examples to start handling files from your Chrome browser and soon… you will be able to do the same with your ChromeBook, nice ahh?!
WebGL – games/games/games and more amazing stuff from Google earth.
SVG – just like in iOS.
Application cache, localStorage e.g. localStorage["name"] = username;. Unfortunately, present implementations only support string-to-string mappings, so you need to serialise and deserialise other data structures. You can do so using JSON.stringify() and JSON.parse().
More ‘real life’ option to store stuff locally: Web SQL Database gives you all the power – and effort – of a structured SQL relational database. Indexed Database is somewhere in between Web Storage and Web SQL Database. Like Web Storage, it’s a straightforward key-value mapping, but it supports indexes like those of relational databases, so searching objects matching a particular field is fast; you don’t have to manually iterate through every object in the store.
If you want to dive into this new world, I recommend two strong sites:
Both are giving very good explanations, tutorial and examples, so have fun. For the full experience you might want to use Chrome browser.
This year, Google I/O was around two main subjects: Andriod and Chrome. I’ve went to see some talks on both themes. Here are some good Google I/O Talks I’ve been this year are:
Another good video for gamers “WebGL Techniques and Performance” and if you like to see what is going to be the next gen of HTML5 games (and you live in the bay area) – come check out this event.
I’ve needed to harness my new mac with some apps/tools I’m using daily. There are lots of good options today in the apple mac store. However, you might want to find some cool apps that are not there. Here is the list I’ve made:
Basic Apps
Quicksilver – Quicksilver is an excellent multi-application launcher. Quicksilver is a handy app and folder launcher has quickly.
Sparrow – mail app for the ones that are still not using gmail web interface…
VLC – VLC is a free and open source cross-platform multimedia player.
Dropbox – a free service that lets you bring your photos, docs, and videos anywhere and share them easily.
Google earth – lets you fly anywhere on Earth to view satellite imagery, maps, terrain, 3D buildings, from galaxies in outer space to the canyons of the ocean.
Picasa – helps you organize, edit, and share your photos. It’s free, and easy to use.
EverNote – works with nearly every computer, phone and mobile device out there.
Adium – Open source multi-protocol instant messaging client for Mac OS X, supports MSN, Jabber, Yahoo! and other networks.
Seashore – is an open source image editor for Mac OS X’s Cocoa framework. It features gradients, textures and anti-aliasing for both text and brush strokes.
Pixelmator – Excellent image editor that give you more then Seashore (and less then photoshop).
Eclipse – Good IDE for Java/GWT/Google App and many more.
Netbean – Fully-featured Java IDE written completely in Java, with many modules available, such as: debugger, form editor, object browser, CVS, emacs integration etc’. It’s a good IDE (as eclipse) but I even more like their php/JS support.
MAMP – Install Apache, PHP and MySQL with few clicks under Mac OS X.
Zend Server/Framework – in case you live in PHP world.
Sequel pro – Sequel Pro is a fast, easy-to-use Mac database management application for working with MySQL databases.
Have I forgot something? Any other ‘killer app’ that should be part of each mac?
I had a good busy day today at the #IObootCamp overall, there were lots of good sessions and it is great to meet so many familiar developers. I didn’t had too much time to put all my notes. But here is a quick list I’ve took from few great sessions. In one hands on session I had the fun to hack this ‘awesome to-do list‘. Is it the best to-do list on the web today, or what? (only on Chrome you will get the ‘awesomeness’). It’s all based on @jeromegn work for a demo of backbone.js
CSS3 New Features
CSS3 patterns – so many option to get very nice background that are pure CSS based.
HSL play tool – change and play with HSL (shh… you can get similar stuff in chrome dev tools by clicking on the right side bar (the one that show you the CSS attributes). You can click on the background-color and it will change between the different methods to define it.
Web Fonts – No more the 8 old (=boring) fonts that we have in browsers… you can (and should) use in your sites/apps a wide range of fonts.
CSS3 Please – let you change/edit the page and see the nice element on the top right corner change in real time. Good tool for beginners. You can get the same ‘feature’ if you use chrome dev tools… (and it’s better because it will record your history of changes both to the CSS and scripts).
yepnope – It is an asynchronous conditional resource loader that’s super-fast, and allows you to load only the scripts that your users need.
MVC (yep in JS) – Backbone supplies structure to JavaScript-heavy applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing application over a RESTful JSON interface.
and let’s not forget the new API discovery tool that Google release today. It’s a good starting point to any project these days.
Have fun and I hope to have lots of new notes/posts during the up coming week.
In the past few months, we (=HighGearMedia.com) have been thinking a lot about mobile and APIs. It’s no secret that the mobile spaces is growing very fast. In fact, we think more and more users will consume most of their ‘web’ using their mobile devices in the (near) future. On top of the ‘mobile movement’ we want to create creative mash-ups that harness other features in order to build new cool tools. Here is a list of APIs I would like to keep an eye on:
Social/Geo
First – the ‘family’ (big big family) of Google Map APIs It’s not only the most popular api on the web today… but I guess it’s the most useful and mature one as well.
Combine it with personalized recommendations tailored specifically for you (=Hunch API) and you get some interesting possibilities. Here is one example of a mobile app that I’ve build using hunch and HGM APIs: find me a car base on my tweets – check it out from your iPhone/Andriod phone…
For fun local/geo/social exploration 4sq is a good place to check things. http://wms.jpl.nasa.gov/ and some more info at: http://www.programmableweb.com/api/nasa
last but not least, there are these 2 frameworks that any one that is going to take seriously her mobile front should keep a close eye on:
http://jquerymobile.com – this is probably the best framework today to build modern mobile apps that will work on lots of phones (iOS, Andriod, PalmOS and even Windows).
http://www.phonegap.com – the framework that let you take your JS,CSS,HTML5 and compile from them a native application.
First good 28min are on few smart techniques to improve the performance of your web app. Paul Irish (from jQuery fame and now with Google chrome team) describes:
CSS re-flows and how to avoid them – single re-flow is better because the browser won’t need to repaint all the elements. Batch the DOM changes before any re-flow-triggering actions is one of the good ways to do it. you can learn a lot from using http://www.browserscope.org/
Hardware accelerated CSS – psss… add css property to your element: translate4d(0,0,0) or translateZ(0) and the browser will do hardware accelerated.
Animation optimization
Web workers – move computation out of the UI thread. Without web workers you can’t… but lucky it’s 2011 and you have them (here and there). I’ve put a simple example in the end of this post. I saw it long time ago (a week?) on Mozilla site – on how to use web workers.
Benchmarking and build scripts.
Last but not least, try about:flags in chrome… lots of good stuff under the hood.
BTW, his (last?) project html5 boilerplate is great for any developer that want to write efficient web sites/apps that will score more then 90 on page spped and will get an A on y!slow. This project is an ANT ‘build script’ that harness you with:
Cross-browser compatible – IE6 and others IE specific classes for maximum cross-browser control.
HTML5 ready. Use the new tags with certainty.
Optimal caching and compression rules for grade-A performance
Best practice site configuration defaults
Mobile browser optimizations
Progressive enhancement with graceful degredation
A full, hooked up test suite is waiting for you.
iOS, Android, Opera Mobile-adaptable markup and CSS skeleton.
Simple example on web workers var results = [];
function resultReceiver(event) {
results.push(parseInt(event.data));
if (results.length == 2) {
postMessage(results[0] + results[1]);
}
}
function errorReceiver(event) {
throw event.data;
}
onmessage = function(event) {
var n = parseInt(event.data);
if (n == 0 || n == 1) {
postMessage(n);
return;
}
for (var i = 1; i <= 2; i++) {
var worker = new Worker(“fibonacci.js”);
worker.onmessage = resultReceiver;
worker.onerror = errorReceiver;
worker.postMessage(n – i);
}
};
I love books. It is due to my parents, that put in me from the age of 4 or 5 this passion to the written word. It might be (also), my literature teacher from high school, that took the only subject I really didn’t like (yep… I enjoyed math, physics and computers but hated literature) and made his course a pure adventure full of joy. I remember lots of moments when you finish a book but keep thinking on the subjects/point of views/heroes years and years after the 4th time you reading it. In a way, my kindle is a wonderful device but I still really like to hold a ‘real’ book.
Last weekend, I’ve decided to ‘sort’ my mobile (=kindle) books. Since I’ve had them (all 1,073) on one big folder, I wrote this little script that build a list of their names and then use amazon to get their rating. From here, the path to a spreadsheet with the data is very short. Now, I know what are the best ones, by harnessing the ‘wisdom of the crowds’.
Happy reading!
Here is the code (or if you like a better version try it on github)
/**
* Description: read a list of books (from a collection on your hard drive)
* and use amazon review to rank them. This is helpful if you have lots of books.
* It's good to put the best one on your kindle for the next vacation/conf etc'.
*
* @author Ido Green
* @date 4/24/2011
* @see https://greenido.wordpress.com/
* http://amazon.com
* http://gskinner.com/RegExr/ - to handle regex IF you want to get ranking from the html
*
*/
class scanAmazon {
private $books = array();
private $newRankList = array();
/**
* Ctor
* @param type $dir - the path to your directory of books
*/
function __construct($dir) {
$this->buildList($dir);
}
/**
* Run on all the books and get the rating, then, save them to a CSV file.
*/
public function run() {
$this->getRating();
$this->saveToFile("booksRanking.csv", implode("\n", $this->newRankList));
}
/**
* build a list of books' name from the file names
* @param type $dir - the path to your directory of books
*/
private function buildList($dir) {
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
//echo "$file\n";
$name = substr($file, 0, strlen($file) - 5);
if (strlen($name) > 2) {
array_push($this->books, $name);
}
}
closedir($handle);
sort($this->books);
}
}
/**
* Get the rating of the books
* we are looking for this pattern: Rated 4.7 out of 5.0
* 1. Use google results: http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=site%3Aamazon.com+BOOK-NAME
* 2. Use amazon directly: http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dstripbooks&field-keywords=BOOK-NAME
*/
private function getRating() {
echo "Working on " . count($this->books) . " books\n";
$i = 1;
foreach ($this->books as $book) {
$searchUrl = 'http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dstripbooks&field-keywords=' . urlencode($book);
// this is the pattern "alt="4.3 out of 5 stars"
$resPage = file_get_contents($searchUrl);
$matches = array();
$ind2 = strpos($resPage, "out of 5 stars");
$ind1 = $ind2 - 4;//strripos($resPage, '"',$ind2);
//google: $ind1 = strpos($resPage, "Rated") + 5;
//google: $ind2 = strpos($resPage, "out of", $ind1);
if ($ind2 > $ind1 && ($ind2-$ind1) newRankList, $rank . "," . str_replace(",", " ", $book) . ",".
$searchUrl);
echo "{$i}) {$book} - Ranking: {$rank} out of 5.0\n";
}
else {
echo "{$i} ERR - {$book} got no rating url: {$searchUrl}\n";
}
$i++;
sleep(5); // let not overload amazon server :)
// $found = preg_match('/Rated (\d\.\d) out of 5.0/gi', $resPage, $matches);
//if ($found && count($matches) > 0) { $rank = $matches[0]; }
}
}
/**
* simple saver of data/string to file
* @param $fileName
* @param $data
* @return false when we could not save the data
*/
function saveToFile($fileName, $data) {
try {
$fh = fopen($fileName, 'w');
fwrite($fh, $data);
fclose($fh);
} catch (Exception $exc) {
error_log("Err: Could not write to file: {$fileName
} Trace:" . $exc->getTraceAsString());
return false;
}
return true;
}
}
// start the party
$scanner = new scanAmazon("PATH TO YOUR BOOKS");
$scanner->run();
Here is a set of commands I found using… There might be a lot of other useful commands.
Setting up a Git project
If you want to work with an existing project, clone it:
$ git clone <url> - for example: git clone https://greenido@github.com/greenido/html5-boilerplate.git
If you do not have an existing git project, create one:
$ cd project/
$ git init # initializes the repository
$ git add . # add those 'unknown' files
$ git commit # commit all changes, edit changelog entry
$ git rm --cached <file>... # ridiculously complicated command to undo, in case you forgot .gitignore
Git will look for a file named .gitignore in the root of your repository which contains a set of shell patterns to ignore in file paths.
Branching and merging
$ git checkout -b linux-work # create a new branch named "linux-work"
$ <make changes>
$ git commit -a
$ git checkout master # go back to master branch
$ git merge linux-work # merge changesets from linux-work (Git >= 1.5)
$ git pull . linux-work # merge changesets from linux-work (all Git versions)
Importing patches
$ git apply < ../p/foo.patch
$ git commit -a
Exporting a patch
$ <make changes>
$ git commit -a -m "commit message"
$ git format-patch HEAD^ # creates 0001-commit-message.txt
# (HEAD^ means every patch since one revision before the
# tip of the branch, also known as HEAD)
Network support
# clone from the primary Git repo
$ git clone git@github.com:greenido/html5-boilerplate.git
$ cd git
# pushing changes to a remote repo with SSH
$ git push user@github.com:my-repository.git/
# fetch changes to a remote branch into a local branch
$ git fetch user@example.com:my-repository.git/ remote-branch:local-branch
# merge changes from a remote machine
bar$ git pull git://foo/repo.git/ branch
# Serve repository via git protocol
$ cd /my/repository/
$ touch .git/git-daemon-export-ok
$ git daemon # now others can fetch from git://your.machine/my/repository/.git/
# Set up a bare (= without working directory) repository (e.g. on a webserver)
$ mkdir my-repo.git
$ cd my-repo.git
$ git --bare init
$ chmod a+x hooks/post-update # this is needed for HTTP transport
# you need to populate this repository via push
Inspecting revisions
# inspect history visually
$ gitk # this opens a Tk window, and shows you how the revisions are connected
# inspect history
$ git log # this pipes a log of the current branch into your PAGER
$ git log -p # ditto, but append a patch after each commit message
# inspect a specific commit
$ git show HEAD # show commit info, diffstat and patch
# of the tip of the current branch
Referring to revisions
# by name
$ git log v1.0.0 # show history leading up to tag "v1.0.0"
$ git log master # show history of branch "master"
# relative to a name
$ git show master^ # show parent to last revision of master
$ git show master~2 # show grand parent to tip of master
$ git show master~3 # show great grand parent to tip of master (you get the idea)
# by output of "git describe"
$ git show v1.4.4-g730996f # you get this string by calling "git describe"
# by hash (internally, all objects are identified by a hash)
$ git show f665776185ad074b236c00751d666da7d1977dbe
$ git show f665776 # a unique prefix is sufficient
# tag a revision
$ git tag v1.0.0 # make current HEAD known as "v1.0.0"
$ git tag interesting v1.4.4-g730996f # tag a specific revision (not HEAD)
Comparing revisions
# diff between two branches
$ git diff origin..master # pipes a diff into PAGER
$ git diff origin..master > my.patch # pipes a diff into my.patch
# get diffstat of uncommitted work
$ git diff --stat HEAD