Categories
Work

Avro Phonetic Web User Control for ASP.NET

The idea is pretty simple: A web user control for ASP.NET that loads the Avro Phonetic keyboard and binds the text inputs and text areas.

The control can be downloaded from: http://masnun.googlecode.com/files/Avro.zip

How to use it?

1) Extract Avro.zip and you shall get two files in the Avro folder: “Avro.ascx” and “Avro.ascx.cs”. First one is the user control and second one is the codebehind file.

2) Crate a new website project in Visual Studio or open your existing project.

3) Copy the above mentioned two files (NOT the entire directory, just the files) into your project. For better organization you might want to create a “Controls” directory (if you haven’t already). Paste the two files inside your desired directory.

4) Now, we add the controls to a web form. Open a page, say Default.aspx. Just below the Page directives, add the following Register directives to register the control:

<%@ Register Src="~/Controls/Avro.ascx" TagPrefix="asp" TagName="Avro" %>

Here, Src is the location to the Avro.ascx file. TagPrefix and TagName makeup the custom tag that loads the control. In this case, you now have a <asp:Avro> tag which you can use to load the control.

5) Let’s add the control:


The control accepts two attributes – “Bangla” and “Callback”. Setting Bangla to “true” or “false” enables or disables Bangla by default. The Callback attribute accepts the name of a Javascript function which is called when the keyboard state changes.

6) Let’s test the control by adding a text area and the defined callback function:


    

Load the web page in your browser. If you have Firebug installed in Firefox, the callback should print out state of the Bangla layout on the console.

For brevity, here is my entire Default.aspx file:

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Src="~/Controls/Avro.ascx" TagPrefix="asp" TagName="Avro" %>



    
    
    

Categories
Javascript PHP Work

Avro Phonetic Plugin for WordPress

Rifat vai has released an awesome jQuery plugin which adds Avro Phonetic layout to your text inputs. I converted it into a WordPress Plugin. Hats off to Rifat vai for the awesome job!

How to use it?

Click on the download link below. It should show you the raw php source of the plugin file. Save it as “avro-phonetic.php” and upload the file to “wp-content/plugins/” directory. Now go to your “Plugins” page from WP Dashboard. Activate the plugin.

Download: https://raw.github.com/masnun/Avro-Phonetic-WP-Plugin/master/avro-phonetic.php

Github Repo: https://github.com/masnun/Avro-Phonetic-WP-Plugin

Official Page: http://torifat.github.com/jsAvroPhonetic/

Knows Issues:

  • Doesn’t work with the Visual Editor (TinyMCE) of WordPress. Please use the HTML editor.
  • Doesn’t show any visual clue of which language (English or Bangla) is active.

    It now shows a black box with language identification

    Thanks to the Avro team for the nice icons.

  • Ctrl + M toggles between Bangla and English. It’s your responsibility to let the users know how to use it. The plugin doesn’t have any fancy instructions displayed to the users.

    It now has a widget. Add the widget to your sidebar.

  • Forces to load jQuery 1.7.2 without caring if an older version is already loaded. Had to do this because wp_enque_script() was not loading jQuery on some themes/setup.

    Thanks to Mehdi vai, the loading is now done using JS after checking if a version is loaded already! 🙂

Contribute:
Feel free to fork the codes on Github and send me pull requests. If you’re not used to Git, send me the modifications over email. I shall merge them and commit. My email address is available on masnun.com 🙂

Have fun!

Categories
PHP Work

PhpTube: A PHP Class to get download links from Youtube Watch URLs

THE API HAS BEEN BROKEN FOR A LONG TIME, AND I DON’T WANT TO FIX IT SINCE THERE ARE BETTER ALTERNATIVES LIKE “youtube-dl”.

Let me get to it straight: I wrote a php class that takes a youtube watch url (the typical url to watch a video, the url has a “watch” GET parameter in it) and returns the download links for different available formats of the video. Please note that these links will be valid for the requesting IP address. That is you can not download the videos from other IP addresses except the only one IP adress that actually originated the download request. So if you put it on your server and send these links to your users, they’ll certainly not be able to download from these links since their IP addresses will be different from your server IP address. In that case, you should first download it to your server and then link to those downloaded videos.

You can download the source codes from my github repo: https://github.com/masnun/phptube 🙂

An example:

getDownloadLink("http://www.youtube.com/watch?v=sesOnXMcaBk&feature=channel"));
?>

Output:

array
  0 => 
    array
      'ext' => string 'flv' (length=3)
      'type' => string 'Low Quality' (length=11)
      'url' => string 'http://o-o.preferred.btcl-dac1.v15.lscache7.c.youtube.com/videoplayback?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor&fexp=909702%2C912503&algorithm=throttle-factor&itag=5&ipbits=8&burst=40&sver=3&signature=69B3EB0AC93CA358375F6C56384CFB82314E8CFF.060F0B630A23F3DB1E07C173E1804D8059439D45&expire=1305637200&key=yt1&ip=180.0.0.0&factor=1.25&id=b1eb0e9d731c6819' (length=383)
  1 => 
    array
      'ext' => string 'flv' (length=3)
      'type' => string 'High Quality (320p)' (length=19)
      'url' => string 'http://o-o.preferred.btcl-dac1.v13.lscache5.c.youtube.com/videoplayback?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor&fexp=909702%2C912503&algorithm=throttle-factor&itag=34&ipbits=8&burst=40&sver=3&signature=4F52B91CBD47F3B048FFF72C7C8235CF8A5E2020.540EF6713BFD929EBA8FF7C3645BB9A367D716CF&expire=1305637200&key=yt1&ip=180.0.0.0&factor=1.25&id=b1eb0e9d731c6819' (length=384)
  2 => 
    array
      'ext' => string 'mp4' (length=3)
      'type' => string 'High Quality (480p)' (length=19)
      'url' => string 'http://o-o.preferred.btcl-dac1.v13.lscache6.c.youtube.com/videoplayback?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor&fexp=909702%2C912503&algorithm=throttle-factor&itag=18&ipbits=8&burst=40&sver=3&signature=30BCE104E535CEC7543D1CE859785C4927E96156.6B7EFB893086BBBDA499487F0720A744BB3FC5F2&expire=1305637200&key=yt1&ip=180.0.0.0&factor=1.25&id=b1eb0e9d731c6819' (length=384)