I often use a tool called Enounce Myspeed to change the speed of Flash videos, it works very well and allows me to watch videos at any speed I want. This is often useful to watch tutorials at double speed to see if its worth watching and then slow it down to half speed when I need to focus on how something was done.
The problem is youtube randomly displays video in Html5, even although I have disabled the Html5 beta test.
This was rather annoying as I have become so used to playing video in double speed that going back to the normal speed seems rather slow.
So after a few google searches and trial and error I managed to make my own chrome bookmark which will allow me to pick the playback speed of the html5 video. just create a new chrome bookmark with the following in the url box:
javascript:(function(){varvideoNumber=prompt("Which video number (0 to x)","0");varplaybackSpeed=prompt("Playback speed?","2.0");document.getElementsByTagName("video")[videoNumber].playbackRate=playbackSpeed;})();
Give it a title such as “Change video speed” and add it to the chrome bookmarks bar.
Now anytime you are on a site with html5 video, you can easily change the playback speed by entering which video and what speed you want it to play at.
Sadly it doesn’t work on iOS since the playbackRate isn’t supported, but hopefully one day, I will test on android later on (hopefully chrome for android will support it).
The following list is from the google I/O talk in 2008 called “Dalvik Virtual Machine Internals” its a list of ways to loop over a set of objects in order from most to least efficient:
(1) for (int i = initializer; i >=0; i--) //hard to loop backwards
(2) int limit = calculate_limit(); for (int i= 0; i< limit; i++)
(3) Type[] array = get_array(); for (Type obj : array)
(4) for (int i =0; i< array.length; i++) //gets array.length everytime
(5) for (int i=0; i < this.var; i++) //has to calculate what this.var is
(6) for (int i=0; i < obj.size(); i++) //even worse calls function each time
(7) Iterable list = get_list(); for (Type obj : list) //generic object based iterators slow!
The first 3 are in the same territory of efficiency, avoid 7 if possible.
This is mainly advice to help battery life but could potentially help Java SE code too.
Another piece of advice he gives is to avoid memory allocation as much as possible, especially in loops!
While watching "Google I/O 2008 - Dalvik Virtual Machine Internals" (http://www.youtube.com/watch?v=ptjedOZEXPM) they demonstrated a great example of how a simple bytecode interpreter is implemented. Since I am fascinated by the inner workings of compilers and VM/interpreters I thought I would share the example here for anyone else that is interested.
The first example is the simplest version, a simple for loop that loops over each byte and depending on the value of each byte it will execute a different command, this version is very portable as it doesn't use any low level assembly code, so this example can be compiled for many different platforms.
/*
Google I/O 2008 - Dalvik Virtual Machine Internals
The next example whos a much more efficient implementation: the gcc way! It removes a number of the branches required in the last example, so right after executing the op code code it can go staright into the enxt opcode! Rather than the first example where it had to branch to the end then to the next for loop iteration etc. So it is alot more efficient!
There is also an assembly example which is even more efficient, since there are still come cases where humans can write more efficient assembly than compilers.
For a new project I needed to parse a prewritten xml file and extract information, instead of going to the bother of setting up a c++ xml library I decided to try out Java’s built in class library for xml parsing.
First you will need to include the standard xml packages that we will use for simple xml loading:
Next you will probably want to get all elements with a certain tag name, you can do this like so:
NodeList packageList = doc.getElementsByTagName(“package”); //get all package elements
Now simply loop over all the package elemetns it found:
for(inti=0;i<packageList.getLength();i++){...}
Inside each package are subnodes so I would like to loop over them too (inside the loop above):
Node resNode = packageList.item(i);
NodeList packageDetails = resNode.getChildNodes();
for (int ii = 0; ii < packageDetails.getLength(); ii++) { ..}
Now I would like to print out only the nodes called name inside the package, so first check if the current node in the loop is called name:
if (detailNode.getNodeName().equals("name")) {...}
Now that we know this is the name node lets print the contents of the contents:
System.out.println("Name of package:"+detailNode.getTextContent());
Very simple indeed, although this is a simple example its amazing the information you can use from xml files using this simple method!
Best free front websites!
Recently I have been looking for more interesting fonts for a couple of projects I am working on, the default fonts get old very quickly, even for very quick programmer art I like to have a font which blends with the theme of the game or website. In general I find typography very hard, i'm not a natural artist/designer, my main goal is to hack together graphics which look very pleasing to the eye but with the hope that an artist would eventually redo in order to give the wow factor. I'm really interested in learning about typography and how to make pleasant looking titles and GUI elements for games and websites so hopefully I will have some typography tutorial summaries on this blog very soon!
This post will be updated as I find
Anyway, here is the list of free font sites that I have come across which offer very nice looking fonts for the even better looking price of free!
Font Squirrel: http://www.fontsquirrel.com/ - Found this through a nettuts+ tutorial and thought it looks like an excellent resource.
Font leech: http://fontleech.com/ - Another great looking font website which I will have to take a closer look into
In fact while browsing for similar sites I found this excellent blog post on the top font sites which contains quality fonts for absolutely nothing, check it out!
A Mac PDF Text To speech application for quick reading of PDF files, ideal for quickly taking notes on academic and technical papers which ProductivePDF reads the text aloud at high speeds. Too slow at reading? Find your mind wandering when reading boring documents? Find it hard taking notes? This application is for you!