Monday, October 24, 2011

Download Youtube clip, Convert to MP4 and OGG for HTML 5 video tag

I am working with Mac. One of my tasks was ... "36613, put this youtube video on our website !! using latest fancy portable HTML 5 !!"


"Yes. My Lord! " ... HTML 5 is not really being supported by all latest browser yet. and some of them only support some particular encoding schemes. So, what I had to do for this task was ...

  1. Download the video from youtube
  2. Convert the video to .mp4
  3. Convert the video to .ogg
  4. Write little HTML(5) code

I am going to talk about the freeware converters I used on Mac only. They are all real free, no watermark, no limited functions, no trial expiry date.

If you want to write a video tag that support all browsers, visit the following post: http://henriksjokvist.net/archive/2009/2/using-the-html5-video-tag-with-a-flash-fallback. It talked about including .mp4, .ogg and also .flv in order to support all browsers.



1. Download the .flv video from youtube

"Firefox" and Firefox Add-on "Ant Video Downloader": https://addons.mozilla.org/en-US/firefox/addon/video-downloader-player/

Usage:
  1. Use Firefox, go to the youtube video page you want to download.
  2. click the Ant video button next to the address bar.
  3. select the video name in the dropdown list.


2. Convert the .flv to .mp4

MPEG Streamclip: http://www.squared5.com/

Usage:
  1. Open the downloaded .flv file using MPEG Streamclip
  2. Choose Export to MPEG-4 in the menu
  3. Select the resolutions you want (usually defaults are alright).


3. Convert the .flv to .ogg

ffmpeg2theora: http://v2v.cc/~j/ffmpeg2theora

Usage:
  1. run the following command to convert the .flv file:
  2. ffmpeg2theora DownloadedYoutubeVideo.flv

Wednesday, September 21, 2011

Using javascript to solve mobile browser position:fixed; issue

One of the website I am working on is using Clearbox to generate the lightbox effect. But because most of the mobile browsers does not work with position:fixed, so, when user browse the website from iPad or Android, the dialog box always popup at the top of the page (outside the current viewport). The same issue happens to every javascript library using position:fixed property.

There is no easy workaround yet.

So, I have to run the following script after every scroll event in order to update the "top" style of the popup window (keep updating even before the user click the lightbox link).

(include this script right before the </head>)

Friday, September 16, 2011

Using Keynote for presentation slides

Keynote has a really nice feature to share the slides online in iwork.com, but it requires Safari browser to see all the animations and transitions.

http://public.iwork.com/document/?d=WebScraping.key&a=p1074597799

This sharing is about writing Web Scraper, the audience are HKUST students in Social Media course.

Friday, September 9, 2011

am visiting HKUST occasionally ... sitting lessons

Was visiting HKUST occasionally, and attended a random class. It is really tempted to sit more lessons for free ! I think one day I will keep attending university classes when I don't have full time job.

Here is the list of course pages:
http://www.cse.ust.hk/pg/courses

Here is the class schedule search application to check the class date time and room number:
http://tinyurl.com/425oygn



Some interesting ones ... (not all of them available this semester):


COMP 5211     Advanced Artificial Intelligence     [3-0-0:3]
[Previous Course Code(s): COMP 521] This advanced AI course will cover advanced concepts and techniques in AI. The major topics will be: problem solving, knowledge and reasoning, planning, uncertain knowledge and reasoning, learning, and robotics.


COMP 5531     Green Computing     [3-0-0:3]
[Co-List with ENEG 5450] This course will exam "Green Computing" from a system perspective, meanwhile, students will study issues related to energy saving form multiple disciplines such as mechanical engineering, industrial ecology, and economics. We will explore energy efficient system designs ranging from datacenters to embed devices, such as sensor networks and RFID devices. We will perform Life Cycle Analysis on some of these systems, evaluating the carbon footprint of manufacturing, use, and disposal of each design. Exclusion(s): ENEG 5450


COMP 5711     Introduction to Advanced Algorithmic Techniques     [3-0-0:3]
[Previous Course Code(s): COMP 570] This is an introductory graduate course in algorithmic techniques. Topics include: advanced data structures; graph algorithms; amortization; approximation algorithms; on-line algorithms; randomized and probabilistic analysis. Background: COMP 3711, COMP 3721


COMP 5712     Introduction to Combinatorial Optimization     [3-0-0:3]
[Previous Course Code(s): COMP 572] An introduction to the basic tools of combinatorial optimization, including network flow and the max-flow min-cut theorem, linear programming, matching, spanning trees and matroids, dynamic programming, algorithms and data structures, graph algorithms. Background: COMP 3711 or equivalent, linear algebra


COMP 6211     Advanced Topics in Artificial Intelligence     [3-0-0:3]
[Previous Course Code(s): COMP 621] Advanced topics in artificial intelligence including neural networks, natural language processing, logic programming, image understanding, robotics and others. Background: An appropriate 500-level course.


COMP 6511     Topics in Computer Systems Analysis     [3-0-0:3]
[Previous Course Code(s): COMP 651] Advanced topics in computer systems analysis; issues in the development and solution of system models; model parametrization, verification and validation; recent developments in techniques and tools for system evaluation.


COMP 6611     Topics in Computer and Communication Networks     [3-0-0:3]
[Previous Course Code(s): COMP 660] Advanced topics in communication networks, including issues in high speed networking, ATM, multimedia communication, network interconnection, network management, and protocol verification and testing.


COMP 6612     Topics in Computer Engineering     [3-0-0:3]
[Previous Course Code(s): COMP 680] Selected topics in computer engineering of current interest to the Department and not covered by existing courses.


COMP 6613     Topics in Applications of Computer Science and Engineering     [3-0-0:3]
[Previous Course Code(s): COMP 685] Selected topics in applications of computer science not covered by existing course. Credits earned by taking this course can only be used to satisfy the breath requirement of the research area of Software and Applications.


COMP 6711     Topics in Theoretical Computer Science     [3-0-0:3]
[Previous Course Code(s): COMP 670] Selected topics in theoretical computer science not covered by existing courses, including, but not limited to, computational complexities and computability, graph algorithms and combinatorial optimization.

Monday, September 5, 2011

Wednesday, August 31, 2011

Solving (Workaround) ruby_core_source.rb:57 'initialize': not in gzip format (Zlib::GzipFile::Error)


saw this error when one of my colleagues could not bundle install nor gem install linecache19:

ruby_core_source.rb:57 'initialize': not in gzip format

We are all using the same Gemfile to do bundle install, and it only happens to his laptop. After trying everything we found in google / stackoverflow, it still not working. Most of the suggestion were about cleaning the cache files in the rvm directories.


After digging into the source code of ruby_core_source.rb, I found out that the code did a gunzip and then tar extract on a tar file. So, that's the problem of the package storing on the ftp server: (ruby_core_source.rb:50)

uri_path = "http://ftp.ruby-lang.org/pub/ruby/1.9/" + ruby_dir + ".tar.gz"


I am not sure why the .gz file on the server is not gzip-ed.

But then the workaround is obvious. Go to gem directory and modify the source. my ruby_core_source.rb is here: ~/.rvm/gems/ruby-1.9.2-p180@not_gzip_format_error/gems/ruby_core_source.gem/lib/ruby_core_source.rb



More coding details here: https://gist.github.com/1183048


Note: this is a different issue from tar_input.rb 'initialize': not in gzip format (Zlib::GzipFile::Error)


Friday, August 5, 2011

Code Jam at boot.hk

Yeah ~ organizing our first code jam. We have total 13 ppl confirmed coming ! We have different expertises: Drupal, UX, RubyOnRails, Java, etc. Must be fun !!


Although the project is mainly PHP and Drupal, there are many areas non-PHP coders could help. Infrastructure, UI, online marketing, user experience, pair programming, etc.


To make Hong Kong a better place to develop technology products, Code Jam is really an important part. Knowledge and skills are exchanged. Stronger linkage between several coder communities is built. People will be more confident about investing money on local talents and the creative technology industry. I am sure we will have more and more Code Jam coming ~


More info about the Code Jam: