29 Nov 2014

Unable to Disable DASH in YouTube Center in firefox

The new YouTube feature DASH, has disabled the ability to buffer the entire video, instead now it buffers only a small block. Dont know exactly why YouTube added this feature?, but may be they wanted to help mobile phone users who have 2G/3G Internet Data Connection because they are billed for the data usage by Moblile Service Operators.

Anyway this sucks for the desktop users who have unlimited download Internet Service Connection because:
  • If you want to rewind the video, YouTube has to redownload it again
  • If  you pause the video, YouTube will not continue with the download of the video.
Luckily there is a workaround in disabling this YouTube's  DASH feature, by using YouTube Center, a browser extension that is availble for Firefox, Chrone, Safari and Opera.

Install YouTubeCenter  in Firefox

YouTubeCenter Addon

  1. Download this addon https://addons.mozilla.org/en-us/firefox/addon/youtube-center/
  2. Click on "Add to Firefox" button to install.
  3. Press "Allow" on the permission to install.
  4. After installation is complete, goto "Options" of  YouTubeCenter and then configure the settings.

Disable DASH in YouTubeCenter in Firefox

Some users who have previously installed this addon are not able to disable DASH after the latest update, its because this setting doesn't work well in HTML5 Player mode. For more technical info on Why DASH doesn't work with HTML5 player.

 The following settings will help users to disable the DASH in YouTube.

1. Click on YouTubeCenter "Options" . (Click on Firefox Settings Firefox Settings button >Add-ons >Extensions>YouTubeCenter Options )

2. Disable "DASH Playback" . (Goto "Player" left menu > "General" Tab > "DASH Playback" )
3. Set "Player type" to "Flash".
4. Set "Flash WMode" to "Direct".

5. Disable "Prevent auto-buffering" . (Goto "Player" left menu > "Auto Play" Tab )
6.  Disable "Prevent playlist auto-buffering" . 
7.  Disable "Prevent tab playlist auto-buffering" . 

8. Set "Auto resolution" to anything other than "1080p" and "480p". (Goto "Player" left menu > "Resolution" Tab) . You can set values  to {144p | 240p | 360p | 720p }

9.   Disable "DASH Playback" . (Goto "External Players" left menu > "Embed" Tab > "DASH Playback" ) Likewise repeat the same steps as in step 2 - 8 for "Embedded External Player"

10.  Disable "DASH Playback" . (Goto "External Players" left menu > "Channel" Tab > "DASH Playback" ) Likewise repeat the same steps as in step 2 - 8 for "Channel External Player"

11. Close the YouTubeCenter Settings and Restart the Firefox.

Now start buffering videos in YouTube like the old times.

UPDATE (07-Jan - 2015)
With the latest update of Firefox to 34.0.5 version, this process is not working. We have to wait for new patch update from the Youtube Center Developer

5 Nov 2014

Alert Box in codenameone

Dialog.show("Title", "Main content", "Yes", "Exit");
Dialog.show("Title", "Main content", "Yes", "Exit");

Delay code in Java

try {
 Thread.sleep(2000); //in milliseconds.
} catch(InterruptedException ex) {
try {
 Thread.sleep(2000); //in milliseconds.
} catch(InterruptedException ex) {

18 Jul 2014

Online Generator tool for Code Syntax formatting

With this tool you can quickly generate the styled html for your source code.  It generate styles for different IDE's like Eclipse, Emacs, Django, etc.  It supports 25 programming languages like Java, HTML, PHP, CSS, Scala, Groovy, etc.

In this new version of Code Syntax Highlighter (v3.0), it uses more modern and minimal styled UI's.

Advantages of Code Syntax Format Tool

  1. Loads vey quickly your styled code rather losing time generating the code via javscript for every time the user visits your site.
  2. It displays the formatted code even if the Javascript is disabled.
  3. Never shows your code in blant plain format initially when your page is loaded.
  4. Simple UI to config the settings
  5. It supports many languages and themes.

To check out the Online Generator follow this link, Online Code Syntax Generator tool

Steps to Generate the Formatted Code Syntax.

  1. Insert the source code to the text area.
  2. Select the Language
  3. Select the Theme style
  4. Click on the Get Formatted HTML  button
  5. Copy the HTML generated and paste it in your website.
  6. Add the external Theme CSS and Javascript library to your website.
<script type="text/javascript" src="http://ajblk.github.io/SyntaxHighlightGenerator-v3.0/scripts/sh-v3.0-min.js"></script>
For the CSS file, choose from the Themes at the bottom of this blog.
  1. Add the below <script> snippet before the </body> end tag.
<script type="text/javascript">

Advanced Options

When Show Gutter  and Show ToolBar  is enabled

img of gutter and toolbar when its enabled in code syntax generator

When Collapse All  is enabled
img of collapse all, when this config is enabled in code syntax generator
The source code is hidden and it is displayed when expand source is clicked

When Start Line number = 8,  Title Above Code = Simple Demo  and
When Line no. padding = 3, the line number is padded with zeros for 3 digits.

img of code with padding of 3 digits and title above the code

Link to Try out the Generator - Online Code Syntax Format Generator

13 Jul 2014

Regular Expression to hack a source code

There are many quality open source code available in github and code.google . Now if we wish to hack some source code, the best way to learn how it works is to see a log where the function name is displayed in the order it is executed.

Insert Debug Code using Regular Expression

By this technique, we can find the function using regular expression and insert our debug code inside each function.

Lets illustrate with a Javascript  Source Code and Notepad++ IDE

Regular Expression to Find functions


Debug Code to insert inside each functions


Regular Expression to Insert Debug Code inside Functions

$1 \n\tconsole\.log\("$2"\)\;

A sample Javascript before inserting Debug code
var SyntaxHighlighter = function() {
    var sh = {
        all: function(params)

Javascript code after inserting Debug code using Regular Expression
var SyntaxHighlighter = function() {
    var sh = {
        all: function(params)

Note: Please enable "Regular expression" and ". matches newline" in Search Mode in Replace box in Notepad++ for inserting inside more than 1 function using regular expression.

How this Regular Expression Works

Find Regex :
Replace Regex:
$1 \n\tconsole\.log\("$2"\)\;

6 Jul 2014

Why Use Spring Framework?

  1. Dependency Injection
  2. Coding to Interface
  3. Aspect Oriented Programming

 What is Dependency Injection?

Dependency Injection is used to decouple the dependence between the objects within a class and to provide the dependency (i.e. instantiation, initialization) from outside configuration to the class.

Factory Design Pattern is used in Spring Framework.  Means instead of directly instantiating an object, we ask the particular Object Factory to manage (create, maintain lifecycle, destroy) the object and pass to us a reference of the object.

Spring uses:
1. BeanFactory
2. ApplicationContext

5 Jul 2014

Online Source Code Syntax Formatter

We can use source code syntax highlighter to format the code style to put in online media's like for e.g: blog or website. One common method is to use javascript to format the source code whenever the page is loaded. ( like SyntaxHighlighter )

SyntaxHighligher has very modern looking code syntax styles and  supports lot of programming languages like  Java, Javascript, PHP, C#, C++, CSS, HTML,  XML, SQL, VB, Python, Ruby.

The only issue with the javascript method is that it takes time to generate the code syntax styles and load the page every time. Its because  javascript tries to search the code for keywords and then renders and build the styles for each page request on the fly.

This issue can be solved, by using Code Syntax Highlight Generator, it builds the source code style only one time and then just simply reuse the rendered style for each page request. This technique notably decreases the load time of the page.

For Online Code Syntax Highlight Generator, visit this link : Online Tool for Syntax Highlight Generator

Steps to use Source Code Syntax Highlight Generator

  1. Insert the source code to the online generator.
  2. Configure the language and display style options
  3. Place the generated HTML to the your desired blog or website.
  4. Add the below CSS and Javascript  library to your blog.
  1. Add the below <script> code snippet  just before the </body> close tag
<script language='javascript'>
var args={presourcecode:"presourcecode",highlighterMainDivId:"highlighterMainDiv"};
//dp.SyntaxHighlighter.BloggerMode(); //Uncomment for Google Blogger.

A Sample Template:

<html> <head> <link type="text/css" href="stylesheets/css/stylehighlighter01.css" rel="stylesheet"/> <script type='text/javascript' src='javascripts/js/sh-min.js'></script> </head> <body> <!-- Insert The Generated HTML Below This --> <!-- Insert The Generated HTML Above This --> <script language='javascript'> var args = { presourcecode: "presourcecode", highlighterMainDivId: "highlighterMainDiv" }; //dp.SyntaxHighlighter.BloggerMode(); //Uncomment for Google Blogger. dp.SyntaxHighlighter.Initialize(args); </script> </body> </html>