Monday, December 29, 2008

Non Monotonic Reasoning

Artificial Intelligence : Natural Language Processing : Slides

Artificial Intelligence : Resolution : Slides

Artificial Intelligence : Knowledge Representation : Slides

Saturday, December 20, 2008

Wednesday, December 17, 2008

Sample Copyright Text

Copyright © 2005 xyz.com

Installing Equation editor for MS Office

Source

Installing Microsoft Office Equation Editor


Introduction:

Equation Editor can be installed on any Windows XP/2000 faculty/staff computer on campus. To install Equation Editor for Microsoft Office XP, follow the instructions below.


To Install Equation Editor:

  1. Before starting, make sure the Excel is closed by going to the File menu > Exit.

  2. Go to the Start menu > Control Panels > Add or Remove Programs.

  3. Click on Microsoft Office XP Professional to select it.

  4. Click on the Change button.

    Add or Remove Programs Window Image

  5. In the Office XP Setup window, select Add or Remove Features.

  6. Click Next.

    Setup Window Image

  7. In the next window, scroll down until you see Office Tools and click on the plus sign next to it to expand it.

  8. Click on the little drive icon Drive Icon Image next to Equation Editor.

  9. Select Run All from My Computer.

  10. Click the Update button.

    Office Tools Window Image

  11. Office XP will install Equation Editor

    Update Window Image

  12. After it is done, click OK

    Finish Window Image

  13. Close the Add/Remove Programs and Control Panel windows

Starting out with xampp on Windows

1. Download it from here.
2. Extract it to C:\xampp
3. Go to the above folder and double click on setup_xampp.bat.
4. check that all the required ports are free by double clicking
on xampp-portcheck.exe. If yes, proceed, else, do some troubleshooting.
5. xampp_start.exe
6. go to your browser's address bar, and type : http://localhost
it should display something about xampp. if it does, your xampp
installations has been successful.
7. now go to the htdocs folder inside xampp, and create another
folder named 'check'.
8. inside this folder, create a filed named a.php
which contains the following :
<?php
phpinfo();
?>
it should display some info about your php installation.
if it does, then you have been able to run your first php
file on xampp.
Next, you should check out this php tutorial.

Tuesday, December 16, 2008

Disabling Tunnel Adapters in Windows Vista (teredo tunneling)

Source

Mounting Windows Partitions in ubuntu

Source

Ubuntu will automatically mount external drives, but for some reason it will not automatically mount internal drives. So this will show you how to mount (or make available for use) internal NTFS-formatted (i.e., Windows) drives in Ubuntu.

Mount Windows through the file browser


If you have your file browser window open, you should be able to double-click on the drive in the sidebar to mount it (or make it available for use). Unfortunately, at least as of Ubuntu 8.04, the drive is identified by its size (in this case, 2.0 GB), so that's how you'll have to figure out which one is the drive you're looking for.

Windows Vista : Requested operations requires elevation

Simply right-click the "Command Prompt" and choose to "Run as Administrator".
Source
OR
Open elevated command prompt by clicking on Start, click All Programs, click Accessories, right-click Command Prompt, and click Run as Administrator.
Source

Saturday, December 6, 2008

Removing dial up connection pop up on windows vista

Source
1>open vista control panel , click on the Control Panel link in the Windows Vista Start menu as shown below:-
http://windows.about.com/od/basictutoria...

2> select "internet option"

3>"connect" or "connections" tab in internet option

4>select "never dial a connection"

5> click "apply" and then "ok" button

done. Hope it solve the problem. Pls see, i use XP and not sure how vista display the screen.

Friday, November 21, 2008

Microsoft Excel : copying the same data to Other cells

Source
Copying (Filling) the Same Data to Other Cells
Another way to enter labels or values onto a sheet is to use the Fill feature. You can copy (fill) an entry into surrounding cells. For example, suppose you have a list of students on a worksheet, and they will each get 1 mark in an assignment . You can enter the once and then use the Fill feature to insert multiple copies of into nearby cells. To use the Fill feature for copying, follow these steps:
1. Click the fill handle of the cell (the small block in the lower-right corner of the cell) that holds the data that you want to copy

2. Drag the fill handle down or to the right to copy the data to adjacent cells. A data tag appears to let you know exactly what data is being copied into the cells.
3. Drag the fill handle to copy the contents of a cell into neighboring cells.
Release the mouse button. The data is "filled" into the selected cells.

Converting xlsx file to xls file

I had an xlsx file and MS-Office 2003 to view it. An xlsx file
is output by MS-Office 2007 and cannot be opened with Office
2003 directly. Nor can Google Docs handle it as of today.
So, if you have Office 2003 and an xlsx file, which you want to
view, Download Microsoft Office Compatibility Pack .

Wednesday, November 19, 2008

Chromatic Polynomial

Chromatic Polynomial :
For some reason, the topic of chromatic polynomials has
caught the fancy
of my students. And, in particular, the chromatic
polynomial of this graph:



In order to compute
C(G, λ) for the above, I suggested using
the decomposition
theorem. Remove the edge between b,d
and fuse the same vertices in
order to obtain G1 and G2.
G2 will be K3(complete graph with 3
vertices) and for G1,
use the decomposition theorem once
again(i.e. remove the edge between b,c and fuse the same vertices)
to obtain G3 and G4. Now, G4 will again be K3, whereas G3 will
be a simple path of 4 vertices.

After that, I have got two
different and correct solutions
from the students, both of which
don’t use decomposition
theorem.

Solution I :
Suppose, a can be colored in λ ways. Then b
can be colored in λ-1 ways, d in λ-2 ways and
finally c in λ-2 ways.
So, C(G, λ) = (λ)(λ-1)( λ-2)( λ-2)

Note that the order, in which the colors are being assigned,
is important. So, if we assign the colors in a different order, i.e.:
a,b,c,d , the above solution will no longer hold. That is what
confused a bunch of students and one of them(Garveet Parmar)
came up with this solution :

Solution II :
Suppose a can be colored in
λ ways, then b can be colored in
λ-1 ways and c in λ-1 ways. Now, in order to color d,
how many choices do we have? d is connected to all the 3
vertices,
so a casual answer might be : 3. But note that, a and c
can be of same colors. So there are 2 different cases :

Case 1:
a and c are of same colors :
a can be colored in λ ways, b in λ-1 ways, c in 1
way
and d in -2 ways.
C1(G, λ) =
(λ).( λ -1).1.( λ-2)

Case 2 :
a and c are of different colors :
a can be colored in λ ways, b in λ-1 ways, c in λ-2
ways
and d in λ-3 ways.
C2(G, λ) = λ(λ-1)( λ-2)( λ-3)

Take some time to grasp it and post a comment
if you don’t get it.
Now adding the polynomials C1 and C2, you should get
the final polynomial :
C(G, λ) = C1(G, λ) + C2(G, λ)
= (λ).( λ -1).( λ-2).[ λ-3+1]
= (λ).( λ -1).( λ-2).( λ -2)
which is same as our earlier answer.

Tuesday, November 18, 2008

Enabling hibernate option in Windows XP

Source

  • Make sure you're logged onto your PC as Administrator or as a user with Administrator rights.
  • You can check the status of your user account by going to Start Control Panel and selecting the User Account icon.
  • Your account should be listed there.
  • If it says Computer Administrator you have the rights to make this change.
  • To show the Hibernate option under shutdown, select Start Control Panel, and select the Performance and Maintenance icon.
  • Select the Power Options icon under "or pick a Control Panel Icon."
  • Select the Hibernate tab, and click on the Enable Hibernation box.

Chromatic Polynomial

Chromatic Polynomial :


The chromatic polynomial C(G,λ)of graph G denotes the different number of
colorings which are possible for G with at most λ colors. For example in the following Graph(K3), no coloring is possible for λ<=2 colors. With λ=3, 6 colorings are possible
which is equal to factorial(3). Since first vertex can be colored in λ


ways, second vertex in λ-1 and third vertex in λ-2 ways, so total number of colorings
possible is λ(λ-1)( λ-2).
Arguing in the similar fashion, we can arrive at following chromatic polynomials :

(i) C(G, λ) = λn for a null graph G with n vertices.


(ii) If G is an open path with n vertices :
C(G, λ) = λ .λn-1

(iii) If G is the complete graph Kn
C(G, λ) = λ(λ-1)( λ-2)….( λ-n+1)

(iv) If Gi, 1<=i<=k, are components of graph G,
then C(G, λ) = Πi=1k C(Gi, λ) = C(G1, λ).C(G2, λ)…C(Gk, λ)

Finding out chromatic number of a graph from its chromatic polynomial:
Remember what’s the chromatic number?
Minimum number of colors required in order to color a graph such that
none of its adjacent vertices are of same color.
Now, Chromatic number has to be an integer.
Also, Chromatic polynomial should always be >0.
So, the minimum value of λ for which the chromatic
polynomial is >0, is the chromatic number.
For e.g.,


for C(G, λ) = λ(λ-1)( λ-2)


the minimum positive integer value of λ for which the polynomial is >0
is 2. Which is indeed the chromatic number of K3.

Decomposition Theorem for chromatic polynomials :
If we obtain two graphs G1 and G2 from G in the following way :


(i) Obtain G1 by removing an edge (v1,v2) from G.
(i) Obtain G2 by fusing/collapsing v1,v2 in G.

Then :


C(G1, λ) = C(G, λ) + C(G2, λ)

For e.g.


Let G be the following graph :

then if I remove the edge (a,b) and obtain G1

chromatic polynomial for G1 is λ2 .
And if I fuse/collapse a and b to obtain G2 :

chromatic polynomial for G2 is λ.
In order to obtain C(G, λ),


C(G, λ) = C(G1, λ) – C(G2, λ)


= λ2 – λ = λ(λ -1),


which is indeed correct.

Similarly you can obtain the chromatic polynomial for the following
graph :



By observing that if you fuse/collapse b,d you obtain K3, whose
chromatic polynomial is known to you and if you remove the edge
(b,d) you obtain an open path with 4 vertices, whose chromatic
polynomial is also known to you.
You should get the following C.P. for the above graph :


C(G, λ) = λ(λ-1)( λ2 - 3λ + 3)


Tuesday, November 11, 2008

displaying newline space etc in vim

How do I display (view) all the invisible characters like space, tabs
and newlines in a file?

You can set the 'list' option to see all the invisible characters in your
file.

:set list

source

Saturday, November 8, 2008

Problem :
Hi,
I use a tablet PC(IBM) to teach my class. This tablet PC doesn't have a CD/DVD drive.
And I have a software on a DVD, which I have installed.
But this software doesn't run, if the DVD is not present in the DVD drive.
I tried to copy the DVD contents as am image file using ImgBurn, but there was this error :

---------------------------
ImgBurn
---------------------------
I/O Error!

Device: [1:0:0] HL-DT-ST DVDRAM GSA-T20L NC08 (F:) (ATA)

ScsiStatus: 0x02
Interpretation: Check Condition

CDB: BE 00 00 00 03 AD 00 00 01 10 00 00
Interpretation: Read CD - Sector: 941

Sense Area: 70 00 03 00 00 00 00 0A 00 00 00 80 10 90 00 00 00 00 00 00 00 00 00 00
Interpretation: Unknown (CRC or ECC Error) (0x10, 0x90)


I also tried to copy the CD contents as they are, but there is
a file named DATA.tsr, which is not being copied.
When I tried to copy through, Ctrl-C, Ctrl-V,
I got this :
"Cannot read from the source file or disk".

I got similar errors when I tried to copy through command line.

How to get around this?

Solution:
I just ignored the Data.tsr file and copied the rest of the contents.
Then created an image using Imgburn and I was able to load
and run it with Daemon tools correctly.

PS :
I had also tried ddrescue(sudo apt-get install ddrescue) on this dvd in Ubuntu, but it was not
the correct approach, since, apparently the DVD was kept
intentionally corrupt in order to prevent any copies.

A simple TCP/IP chat application

rough code in C :

client.c
sock1 = socket(..);
connect();
while(1)
{
printf("enter your message");
fgets();
write(sock1);
read();
}

server.c
socket();bind();listen;
sock2=accept();
while(1){
read();
printf("enter your message");
fgets();
write();
}

Echo server/client using tcp/ip sockets in c

2 files

1. client.c

#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>  
#include <arpa/inet.h>
#include <stdio.h>

#define PORT 2080

main()
{
        int sock1,sock2,clength;
        char str1[100],str2[100];
        sock1 = socket(AF_INET,SOCK_STREAM,0);
        struct sockaddr_in serv,cli;
        serv.sin_port = htons(PORT);
        serv.sin_family = AF_INET;
        serv.sin_addr.s_addr = inet_addr("127.0.0.1");
        connect(sock1, (struct sockaddr *)&serv,sizeof(serv));
        printf("client connecting\n");
        printf("enter a string\n");
        fgets(str1,100,stdin);
        write(sock1,str1,100);
        printf("\nString sent to server, waiting for reply");
        read(sock1,str2,100);
        printf("\nserver replied : %s",str2);
        return 0;
}


2. server.c :

#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>  
#include <arpa/inet.h>
#include <stdio.h>

#define PORT 2080

main()
{
int sock1,sock2,clength;
char recv[100];
sock1 = socket(AF_INET,SOCK_STREAM,0);
struct sockaddr_in serv,cli;
serv.sin_port = htons(PORT);
serv.sin_family = AF_INET;
serv.sin_addr.s_addr = inet_addr("127.0.0.1");
bind(sock1,(struct sockaddr *)&serv,sizeof(serv));

listen(sock1,5);
clength = sizeof(cli);
sock2 = accept(sock1,(struct sockaddr*)&cli,&clength);
printf("\n Client connected");
read(sock2,recv,100);
printf("\nClient said: %s",recv);
write(sock2,recv,100);
return 0;
}

A bunch of c files for file transfer using tcp/ip sockets

There are 2 files :
1. server.c
2. client.c


server.c :
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>  
#include <arpa/inet.h>
#include <stdio.h>
 
#define PORT 2080
 
main()
{
        int sock1,sock2, clength;
        sock1 =  socket(AF_INET,SOCK_STREAM,0);
        struct sockaddr_in serv,cli;
 
        serv.sin_family = AF_INET;
        serv.sin_port = htons(PORT);
        serv.sin_addr.s_addr = inet_addr("127.0.0.1");
        bind(sock1,(struct sockaddr *)&serv, sizeof(serv));
        listen(sock1,5);
        clength = sizeof(cli);
        int i=0;
        char buf[50];
        sock2 = accept(sock1,(struct sockaddr *)&cli,&clength);
        printf("\n Client Connected\n");
        FILE* fp = fopen("server.txt","r");
        while(!feof(fp)){
                bzero(buf,sizeof(buf));
                fread(buf,sizeof(char),50,fp);
                write(sock2,buf,50);
        }
        write(sock2,"quit1234",50);
        fclose(fp);
        return 0;
}
 
client.c :
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>  
#include <arpa/inet.h>
#include <stdio.h>
 
#define PORT 2080
 
main()
{
        int sock1;
        sock1 =  socket(AF_INET,SOCK_STREAM,0);
        struct sockaddr_in serv;
 
        serv.sin_port = htons(PORT);
        printf("%x %x\n",PORT,htons(PORT));
        serv.sin_family = AF_INET;
        serv.sin_addr.s_addr = inet_addr("127.0.0.1");
        printf("client connecting\n");
        connect(sock1, (struct sockaddr *)&serv,sizeof(serv));
        char buf[50];
        FILE* fp = fopen("client.txt","w");
        while(1){
                bzero(buf,sizeof(buf));
                read(sock1,buf,50);
                if(strcmp(buf,"quit1234")==0)
                {
                        break;  
                }
                fprintf(fp,"%s",buf);
        }
        fclose(fp);
}

Friday, October 24, 2008

Ubuntu forgot password

If you don't remember any of your Ubuntu passwords while logging in,
then,
from the boot menu,
select -> Recovery Mode(Ubuntu, not Windows),
then select -> drop root shell
You will get a shell where you would be logged in as root.
There type :
passwd <username>
and change the password.
Reboot.
done.

Thursday, October 23, 2008

Non recursive algorithm for Post Order Traversal

For Pre,Post and In order traversals of a Binary tree,
it is very easy to write recursive programs/algorithms.
But when it comes to a non-recursive solution, it becomes
rather difficult. Though pre-order and in-order traversals
have non-recursive algorithms, which are slightly easier
to implement/understand, post-order is a tough nut to
crack.

Not any more.
Here is an easy to understand non-recursive algorithm
for post-order traversal :
Fact I : Post order traversal(Left-Right-Root) is the exact opposite
of Root-Right-Left traversal(RoRiL)(Prove it!).
Fact II : And a non-recursive algo for Pre-order(RoLRi) is equally good
for RoRiL.

So, just use the non-recursive algo for RoRiL(which is similar to Pre-order)
and traverse it backwards.(that's the post order traversal)

(Pre-order Non Recursive Algorithm)

Monday, October 20, 2008

Rabbit poupulation Fibonacci sequence

Question :
A young pair of rabbits (one of each sex) is placed on an island. A pair
of rabbits does not breed until they are 2 months old. After they are
2 months old, each pair of rabbits produces another pair each month.
Find a recurrence relation for the number of rabbits on the island
after n months, assuming that no rabbits ever die.

Solution :
Suppose there are An rabbits after n months.
Then number of rabbits born in (n+1)th month is : An+1 - An.
An+2
= 2*number of rabbits in nth month + number of rabbits born in (n+1)th month.
= 2*An + An+1 - An
= An + An+1
= Fibonacci sequence

Fibonacci sequence, rabbit population

Question :
A young pair of rabbits (one of each sex) is placed on an island. A pair
of rabbits does not breed until they are 2 months old. After they are
2 months old, each pair of rabbits produces another pair each month.
Find a recurrence relation for the number of rabbits on the island
after n months, assuming that no rabbits ever die.

Solution :
Suppose there are An rabbits after n months.
Then number of rabbits born in (n+1)th month is : An+1 - An.
An+2
= 2*number of rabbits in nth month + number of rabbits born in (n+1)th month.
= 2*An + An+1 - An
= An + An+1
= Fibonacci sequence

Thursday, October 16, 2008

0 is same as '\0'

void main(){
char check[10];
check[0] = 'a';
check[1] = 'b';
check[2] = 0;
printf("%s\n",check);
}
will produce the same output as :

void
main(){
char check[10];
check[0] = 'a';
check[1] = 'b';
check[2] = '\0';
printf("%s\n",check);
}

since ascii code of '\0' is 0,
whereas ascii code of '0' is 48.

Sunday, October 12, 2008

php dom xml problem

Problem :
Warning: domdocument::domdocument() [domdocument.domdocument]: Entity: line 1: parser error : Start tag expected, '<' not found in C:\xampp\htdocs\xyz.php on line 8.

solution :
php_domxml.dll extension has to be commented in the php.ini file under apache/bin.(or
whatever php.ini file is loaded for you, find out through phpinfo()).

source.

Wednesday, October 1, 2008

Vim : stop making a tilda/tilde file

I came across two ways to do it:
(i) :set nobackup and :set nowritebackup
but it didn't work for me.

(ii) :set backupdir=$VIMRUNTIME/vim_backup
it worked for me. Bascially create a directory, where the backup files(tilda files)
will be created. Surprisingly, the backup files are not being created here.
And nowhere else.

I am using gvim on Windows btw.

A software for theorem proving

http://isabelle.in.tum.de/

Thursday, July 24, 2008

Flex and XML

Using ActionScript 3.0 it is difficult not
to get confused, which one to choose out of
XML or XMLNode or XMLDocument class.

Answer is XML.
XMLNode and XMLDocument exist only for the
sake of backward compatibility.

Friday, July 18, 2008

Google Account Authentication - flex example

This example works for normal gmail accounts as well
as hosted accounts for e.g. kyz@some_domain_hosted_at_google.com.


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="onAppInit()">

<mx:HTTPService id="requestClips"
url="https://www.google.com/accounts/ClientLogin"
result="handleHttpResponse(event)" method="POST" fault="handleFault()"/>

<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
private function onAppInit()
{
// "accountType=&Email=".$uname."&Passwd=".$password."&
//source=Movico-MediaBaron-2.0";

var params:Object = {};
//requestClips.url = "http://localhost/MPC/check.php";
params["accountType"] = "HOSTED_OR_GOOGLE";
params["Email"] = "";//for e.g. abc@gmail.com
params["Passwd"] = "";//you know it.
params["source"] = "Company-App-version";
requestClips.send(params);
}
import mx.controls.Alert;
private function handleFault()
{
Alert.show("Either your username/password is incorrect or Google is down");
}
private function handleHttpResponse(event:ResultEvent)
{
var check:String = event.result.toString();
console.text = check;
Alert.show("Authentication Successful !");
}
]]>
</mx:Script>


<mx:TextArea id="console" width="100%" height="100%"/>

</mx:Application>


Thursday, July 10, 2008

Adobe Flex tileList not getting refreshed

Recently I ran into a very tough problem.
I was using a tileList with a dataProvider,
but it wasn't getting refreshed even when
the dataProvider changed.

Complete description and solution is available
here . On this page, you will see a message
by Experts Exchange that the solution is
available only to premium members,
but if you scroll down, the solution
is actually displayed there.

Thanks to Dolly Sapra for the solution,
and saving hell lot of my time !

Tuesday, July 8, 2008

Extracting the subtitles from a srt file using Vim

Here is a sample snippet from a srt file(subtitles for Himalaya)

1
00:02:35,600 --> 00:02:37,900
Grandfather.

2
00:02:40,800 --> 00:02:44,500
This is for my family.

3
00:02:44,500 --> 00:02:47,600
An excellent harvest, Tsering.

4
00:02:49,200 --> 00:02:55,900
How long do you think it
will feed us?

5
00:02:55,900 --> 00:02:58,600
A very long time.

Now, I want to remove the numbers 1,2,3,4,5 etc. as well as the time
information using vim.
It's damn easy.
Step 1 :
:g/-->/d (remove all the lines matching -->)
Step 2:
:g/^\s*$/d (remove all the lines containing only white spaces)
Step 3:
:g/^[0-9]\s*$/d (remove all the lines containing only numbers - this might
delete some useful stuff too, but anyway).

that's it.

Monday, July 7, 2008

Flex : Accessing attributes in XML data passed as ArrayCollection

Suppose this is the XML data you get as
in response to your HTTService :


<?xml version="1.0"?>
<catalog desc="desc3">
<clip desc="desc1">
<title>check</title>
</clip>
<clip desc="desc2">
<title>check2</title>
</clip>
</catalog>



And then, you use the result as the dataprovider
of your datarenderer :

photoFeed = event.result.catalog.clip as ArrayCollection;


Then inside you data renderer, if you want to access the
attributes of a CLIP
node, you have to do this :

t.text = data["desc"];

Wednesday, July 2, 2008

flex reading data from XML url



This is how the Config.xml looks like:
<?xml version="1.0" ?>
<config channelName="zee" bgColor="0xcc0066"
gridNumRows="3" gridNumCols="3" />

This example shows how to read the attributes of
an XML node.



<mx:HTTPService id="readConfig"
url="Config.xml" resultFormat="xml"
result="showClips(event)"/>
<mx:script>
<![CDATA[
import mx.rpc.events.ResultEvent;

[Bindable]

[Bindable]
private var configParams:XML;

private function showClips(event:ResultEvent):void {
configParams = (XML)(event.result);
mainGrid.rowCount = (int)((int)(configParams.@gridNumRows)-(int)('0'));
mainGrid.columnCount = (int)((int)(configParams.@gridNumCols)-(int)('0'));
cnLabel.text = configParams.@channelName;
}

Tuesday, July 1, 2008

ffmpeg with h264

1. I built ffmpeg myself with x264, but it doesn't work properly.
May be I should try with Mingw in place of Cygwin.

2. I analyzed SUPER. It uses ffmpeg, which is not built with h264 support. But SUPER
can still encode files with h264, since it uses x264.exe separately. I wanted to know
the exact commands, so I replaced their ffmpeg with my ffmpeg, but SUPER didn't
even launch.

3. If you are not too keen on building ffmpeg yourself,
simply pick it from here. It works with -vcodec h264.
The latest version available here seems to be problematic.

Friday, June 27, 2008

Using libx264 codec with ffmpeg

This is the information about the input file :

$ ./ffmpeg.exe -i input.avi

Duration: 01:47:20.81, start: 0.000000, bitrate: 909 kb/s
Stream #0.0: Video: mpeg4, yuv420p, 560x304 [PAR 1:1 DAR 35:19], 23.98 tb(r)

Stream #0.1: Audio: mp3, 48000 Hz, stereo, 32 kb/s

then
$./ffmpeg.exe -i input.avi -ss 0 -t 20 -vcodec libx264 out.mpg

then I tried to play out.mpg with VLC, but it only played the audio only.
Winamp, Windows Media player couldn't even play it.
Uploading to Youtube : Failed (invalid file format)
Used as a source file to a videoDisplay object in Adobe Flex,
: unable to play the file.
Uploading to Vimeo : There was a problem converting this video. Please contact vimeo help !

Thursday, June 26, 2008

Building ffmpeg with libx264/h.264/x264 on Cygwin(Wiindows XP)

I am assuming here that you already have a build setup for ffmpeg
under Cygwin and looking for how to add x264 codec to it.
If you are new to ffmpeg build under cygwin, you might want to check this.

Now, you need to do this :
1. Install git for cygwin
2. $ git clone git://git.videolan.org/x264.git

Go inside the x264 folder and
remove these from the file "configure" :
"-mno-cygwin" (source)

./configure
./make

In my case it complained that nasm is missing, so I
downloaded and installed it for cygwin.

It will generate x264.h and libx264.a, which you have
to copy to /usr/include/ and /user/lib/ respectively.

Then inside the ffmpeg source folder :
./configure --disable-static --enable-shared --enable-memalign-hack --enable-libx264 --enable-gpl

then
./make

and that should be it.

------------------------------------------------------------------------

PS : Earlier I downloaded the x264 source code from here :
ftp://ftp.videolan.org/pub/videolan/x264/snapshots/

As it turned out, the version that is here and the version
that was expected by ffmpeg source code was different,
since after building x264 when I tried to build ffmpeg, I got these errors :

libavcodec/libx264.c: In function `X264_init':
libavcodec/libx264.c:151: error: structure has no member named `i_rc_method'

After which I tried to fetch some older versions from the SVN repository,
but for some reason it asked my username and password :

svn merge -rHEAD:280 x264.h
Authentication realm: df754926-b1dd-0310-bc7b-ec298dee348c
password for 'LENOVO':

It was then that I switched to the git repository of VLC.







Wednesday, May 7, 2008

Strange flex behavior

I have this function in flex.
It works correctly as it is.
But if I interchange the lines highlighted in bold,
it stops working.
strange but true.


public function playInTheMainPanel(event:MouseEvent):void{
mainVideo.source = (VideoDisplay)((Canvas)(event.currentTarget).getChildAt(0)).source;
mainVideo.stop();
mainVideo.play();
}

Monday, April 7, 2008

ffmpeg with vhooks built under Windows ! Using Cygwin .

All the DLLs can be downloaded from here.(download watermark.dll for ffmpeg)

Ok, so I have been able to build ffmpeg with vhooks on Windows.
As I mentioned in my previous post, vhooks couldn't be built
with Mingw, I needed Cygwin.

Still I couldn't build imlib2.dll,
only null.dll, fish.dll and watermark.dll.

That means I can use only images as watermarks.

Ok now, to build it on Cygwin, you need to have certain cygwin packages.

ust install your Cygwin with all the "Base" packages, plus the following "Devel" ones:

binutils, gcc-core, make, subversion

Do not install binutils-20060709-1 (they are buggy on shared builds); use binutils-20050610-1 instead.

Source for this cygwin info.


Then get the latest svn snapshot from ffmpeg site, that means
the latest ffmpeg source code.

Unzip it, and go inside it using Cygwin prompt.
and type this :

$ ./configure --disable-static --enable-shared --enable-memalign-hack --enable-vhook

Now I got an error that I don't have cmp.exe.
So I searched and found the solution here.
Solution is that you have to install diffutils on cygwin.

then
$ make


Next, I got two errors :

1. rtsp.c:1097: error: 'EPROTONOSUPPORT' undeclared (first use in this function)

Solutions are here.

What I did was replaced EPROTONOSUPPORT in rtsp.c with AVERROR_NOTSUPP
and it worked.

2. version.h:2: error: missing terminating " character.
I looked up version.h, it had a strange ^M character in it, which
I deleted and again

$ make


$make install

After building vhooks, now I had problems with using the watermark.
You can find the discussion that ensued on Experts-exchange here.

Saturday, April 5, 2008

ffmpeg vhooks on Windows

To watermark one's videos, there is a library called
vhooks, which can be used with ffmpeg.

But I could not locate precompiled vhooks for windows
(vhooks.dll) on net, so I decided to build it.

So I built ffmpeg on Windows using Mingw and following
the step-by-step guide here.

There was one problem though. That problem and its
solutions are listed here.

But it turned out that vhooks can't be built using Mingw.

Some links suggested that it might be built using Cygwin.
So, will try that next.

True Google Rank

Download

What it does is this :

Give as inputs a keyword or keywords, and a domain name or a web page
and the range in google results to search for. It will tell you where does your page/domain
appear in the search results in the 100 results starting from that result number. For e.g. if your domain name www.example.com is the
fifth result on 2nd page of google results for keyword=example, and 3rd result
on 4th page, output would be :

Found at these ranks : 15 33

There are two ways to use it :

Browser :
open first.html
for multiple keywords, simply enter them separated by spaces.
no support for phrases yet.
enter a url and result range to search

Command line :
Usage :
php.exe true_google_rank.php <keyword> < url >
< start result num between 0 and 999> 

for e.g.
php.exe true_google_rank.php dogra wikipedia 10


multiple keywords need to be entered inside " and ".
no support for phrases yet.

You will need php.exe and php5ts.dll for that, bundled
with this zip file .(on linux, I haven't tried yet)




Download


Warning : If you use this script too often(may be 5-6 times a minute),
you might get the dreaded sorry.google.com page. Google decides what
is too often.

License : GPL.

If you like this, contribute by clicking on the Donate button below :










Confesses Walley Rhines - Everything is Broken

Thus wrote Steve Leibson on EDN :

Rhines always gives a good speech. Good because he infuses what he says with history and facts, not just opinions, slogans, and sales pitches. When Rhines says he’s a student of EDA history, you can believe him. When he says that the EDA tool that breaks most frequently is place and route, you can believe him. And that’s exactly what he said in his keynote speech, which focused on what’s broken in EDA as we move into the 45nm era.

Read on for more here.

Wednesday, April 2, 2008

Useful communities for Flex/FMS developers/enthusiasts

Flash Media Server Developers group on LinkedIn
Flex India on Google Groups

One Pro and One Con for Php

Con : Each integer in a PHP array takes 68 bytes of storage


Pro : Java is losing the battle for the modern Web.

Excerpts :
Java EE (then called J2EE) was not built with the Web in mind but rather focused on enterprise integration, transaction management and other back-end processing. While Java EE has long supported Web development with servlets and JSP the companies driving the standards ignored the RESTful nature of the Web and rather continued to drive a general purpose platform.

In two separate surveys of one of the most popular Ajax Web sites, the Ajaxian.com, around 50% of Rich Internet Applications developers are using PHP.

Project Zero's Chief Architect is one of the first IBMers to admit in public that Java today can be considered as a system language and is not desirable for building RESTful Web applications which is Project Zero's goal.

Tuesday, April 1, 2008

Sorry.google.com

I wrote a script to send requests to google and fetch results.
I executed the script a bit too many times(around 30 requests per minute
for 3 minutes),
and I got this :

Sorry.google.com

Cool..

Also, google does not display more than 1000 results per query,
i.e. if you keep clicking next, next..., once you have reached the 100th
page, that's it. You can't go further.

JavaScript

A fantastic primer here.

More here.

Friday, March 28, 2008

OpenCds what next

Though I have successfully installed OpenCDS 5.0 on
Windows XP now, I don't know how to start distributing
content with it now. Let me know if anyone does know
what all do I need to start distributing mobile
content right away.

Finally Successful installation of OpenCDS5.0 on Windows

So finally I did it.
I have installed OpenCds 5.0 on Windows XP.

You can do it as well. Here is how :
1. Download binary for OpenCds 5.0.
2. After unzipping there would be another zip file,
unzip that as well.
3. follow the instructions in doc/5.0/DemoSetupGuide/html/DemoSetupGuide.html.

There are some thing which weren't listed
in the doc or which are listed there but
need to be highlighted. That's what I am
trying to fix here.

0. Remember that you HAVE TO install
Weblogic server on Windows. OpenCDS doesn't
support Sun Application Server on Windows
as of today.

1. Install WebLogic server as described in the doc.
Version 8.1 SP3. For free, you will only get its eval
version, but that is fine. It won't expire and it has
what you need.

2. Install only JDK 1.4. For Jdk 1.5 I got an
invalidclassException, quite late during installation.

3. Install Oracle 10g as described in the doc. If your
PC has DHCP enabled you will have to follow instructions
here.

3.1 When you edit DBConf.xml, Hostname should be set
to your ORACLE_HOST, according to the document
mentioned above, which I find very confusing.
It did not work until I set it to localhost. So the entry
looked like :

<hostname>localhost</hostname>


4. In the cds_home/cfg/my.cfg file you will have to change
the parameter jndi.url in the same way that you changed
*.internal.uri parameters. Otherwise you will get
java.net.unknownhostexception later in your installation.

5. You will have to change
snmp.manager.address
parameter in deployment/cds/conf/CDSSnmp.properties as well,
otherwise you will get java.net.unknownhostexception later
in your installation.

Visual mode for Gvim on windows

Using Gvim on Windows, for a long time I wasn't able
to figure out why does it happen that I press 'v' in the
escape mode but am not able to select any text visually.

Solution :
:behave xterm

most likely your _vimrc has
behave mswin

replace that with behave xterm,
by going to Edit->Startup settings

Wednesday, March 26, 2008

something like lsof for windows : openports.exe

Download from :
http://www.diamondcs.com.au/downloads/console/openports.exe

Many a times you want to know which port is being used by which process,
especially when you are installing many a softwares in a single day, all of
which use some port or the other, you might easily get confused.

openports.exe solves it.

Installing OpenCDS on Windows XP

Second Attempt :
Nimish on Momo Delhi suggested that I should try installing it on Linux rather than Windows.
As of now I don't have Linux so I thought I would make it work with Cygwin. As a first
step I installed Oracle 10g from scratch but soon thereafter
I realized that I am making a very basic mistake. I failed to read the following in the
documentation :
6] Currently, only WebLogic Server can be used with OpenCDS on Microsoft Windows platforms.
And I was trying to make it work with Sun Application server.
So now I have 3 options :

1. Get BEA weblogic server and retry for Windows.
There is a catch here, BEA weblogic server is not free and for
free I can download only its eval version. But since I just want
to get a feel of opencds it might be a good option, and also
it seems if I use WebLogic I might get rid of problems that I faced
in my first attempt with regard to broker.sh and deploymq.sh.

2. Try it on Vmware.

3. Try it on Linux.

I will start with 1. as of now.



First Attempt

Note : I haven't been able to install it yet. This is my first and failed attempt.
Note 2 : I don't find enough documentation available for it, so am not sure whether
it's a good idea to use it, since no one else seems to be using it.

I followed the instructions here :
Quick Start Guide.

It asks me to get Oracle 9g, but the documentation that comes
with the binary of opencds (doc\5.0\DemoSetupGuide\html\DemoSetupGuide.html)
asks to get Oracle 10g. And that has much more detailed setup instructions as
well so it's better to follow that.

Anyway, after installing Sun Application server and oracle 9g as mentioned above,
and following rest of the instructions, when I typed

cdsi deploy

it complained :
Files\cds_home"" was unexpected at this time.

The problem was that the path for CDS_HOME included a space, i.e.
C:\Program Files\cds_home
So I simply put it into C:\cds_home, reset CDS_HOME, and the commands worked.

After a few steps I am asked to execute
./deploymq.sh server
but hey, I am on Windows !! And it's a huge sh file, don't know if I would be
able to convert it to .bat.

So I decide to launch cygwin(lucky, that I have it) and run it from there.
There it asked for the license name : pe,try or unl.
I don't know what do these options mean, but it errored out for pe and try,
so I had to settle for unl.

Still, it complained :
imqpassword.txt : No such file or directory.

Now, I have no idea dude, I searched for this file in the Sun Appserver folder and opencds folder
but couldn't find it.

Later, I am asked to run broker.sh, which again is missing everywhere.
So, eventually when I tried cdse startserver, that didn't work either.

Now, here is what I am going to do next :
follow the instructions that came with my copy of opencds, rather
than following the online instructions.

And, rather that using Windows command prompt, I would use cygwin, but I
am pretty sure that wouldn't work either, since I cannot use variables like
/cygdrive/c/etc where I am expected to put C:/etc. So, most likely I won't
be able to install it ever.

but anyway, wish me luck.

Tuesday, March 25, 2008

Streaming a video file with Flash media server

It's simple.
It works exactly the same way as it does for Red5.
You can test it using JW FLV player.

There are two differences :

1. The folder where you have to place the media file :
For me it is :
C:\Program Files\Adobe\Flash Media Server 3\applications\live

2. RTMP connection URL :
rtmp://localhost/live/

In Red5 it was simply rtmp://localhost/.

For more read this post on how to stream it using Red5.

Colorzilla and YSlow

are two really useful firefox extensions, useful for web developers or enthusiasts.
Colorzilla can tell you RGB values for any pixel on the web page
and
YSlow is for analyzing the download time of the web page.

Monday, March 24, 2008

PHP - SetCookie problem and solution

I have these two files :

login.php :
--------------------
setcookie("qq_user","john",time()+604800);
require "function.php";
justPrint();
----------------------

and function.php :

--------------------------------
function justPrint(){
if((isset($_COOKIE["qq_user"]))){
echo "Log Out";
}
else{
echo "Log In";
}
}
-------------------------------



Now when I invoke login.php, it should simply print Log Out, but it
prints out Log In.

I don't know what could the reason be. I thought the delay wasn't enough
between setCookie and justPrint, but inserting a significant delay with
the help of sleep function didn't change anything either.

Finally this worked :
I added one more file new.php.

Now following are the contents of the above 3 files :
login.php :

------------------------
setcookie("qq_user","john",time()+604800);

require "function.php";
header('Location: new.php');
-------------------------------

function.php remains the same.

new.php :
<?
require "function.php";
justPrint();
?>


It's strange why does it work, but it does.

Wednesday, March 19, 2008

Cool Web Apps



Javascript based color picker :
This, you can use in your web page.
URL : http://johndyer.name/lab/colorpicker/



And, ScreebGrab for saving/capturing a webpage as an image. A ffox xtension.

Friday, March 14, 2008

Making Red5 work, Getting started with Red5, Installing Red 5

Step 1 : I am not sure how exactly does Red5 interact with Apache Tomcat and Java SDK,
but I followed the instructions here :

http://osflash.org/red5/windowstomcat

So the first step is to install Java 1.6 SE and Tomcat 5.5.
------------
Step 2 : Now, the link above talks about Red5.war, I couldn't find it.
So I downloaed setup-Red5-0.7.0.exe from http://osflash.org/red5 and installed
it. It installed without a problem.
------------
Step 3 : Start Red5 from the Program Menu and open http://127.0.0.1:5080/,
seemingly 5080 is the default port for Red5. Then go to http://127.0.0.1:5080/demos/ofla_demo.html and play with it.

In the Red5\webapps\oflaDemo\streams folder you can put an flv file and it will be visible on the page mentioned above.

------------
Step 4 :
I used JW FLV player with the following code to connect to a rtmp stream :
<div style="padding-left:40%" id="abc">
<a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
var s1 = new SWFObject("mediaplayer.swf","mediaplayer","250","170","7");
s1.addParam("allowfullscreen","true");
s1.addVariable("width","250");
s1.addVariable("height","170");
s1.addVariable("image","1.flv.jpg");
s1.addVariable('file', 'rtmp://localhost/oflaDemo');
s1.addVariable('id', 'airtel_ad_1');
s1.write("abc");

</script>
These 2 lines are important :
s1.addVariable('file', 'rtmp://localhost/oflaDemo');
s1.addVariable('id', 'airtel_ad_1');

note that the file I am trying to play is name "airtel_ad_1.flv", so ".flv"
extension is not needed. Also port number is not needed as well.
------------
Step 5 :
Once you click on the play button in the flv player, you will recieve a warning
whether you want to allow this file to access internet. You might be taken to
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html
where you will have to explicitly add the file you want to allow :
In my case : mediaplayer.swf

Making Red5 work, Getting started with Red5, Installing Red 5

Step 1 : I am not sure how exactly does Red5 interact with Apache Tomcat and Java SDK,
but I followed the instructions here :

http://osflash.org/red5/windowstomcat

So the first step is to install Java 1.6 SE and Tomcat 5.5.
------------
Step 2 : Now, the link above talks about Red5.war, I couldn't find it.
So I downloaed setup-Red5-0.7.0.exe from http://osflash.org/red5 and installed
it. It installed without a problem.
------------
Step 3 : Start Red5 from the Program Menu and open http://127.0.0.1:5080/,
seemingly 5080 is the default port for Red5. Then go to http://127.0.0.1:5080/demos/ofla_demo.html and play with it.

In the Red5\webapps\oflaDemo\streams folder you can put an flv file and it will be visible on the page mentioned above.

------------
Step 4 :
I used JW FLV player with the following code to connect to a rtmp stream :
<div style="padding-left:40%" id="abc">
<a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
var s1 = new SWFObject("mediaplayer.swf","mediaplayer","250","170","7");
s1.addParam("allowfullscreen","true");
s1.addVariable("width","250");
s1.addVariable("height","170");
s1.addVariable("image","1.flv.jpg");
s1.addVariable('file', 'rtmp://localhost/oflaDemo');
s1.addVariable('id', 'airtel_ad_1');
s1.write("abc");

</script>
These 2 lines are important :
s1.addVariable('file', 'rtmp://localhost/oflaDemo');
s1.addVariable('id', 'airtel_ad_1');

note that the file I am trying to play is name "airtel_ad_1.flv", so ".flv"
extension is not needed. Also port number is not needed as well.
------------
Step 5 :
Once you click on the play button in the flv player, you will recieve a warning
whether you want to allow this file to access internet. You might be taken to
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html
where you will have to explicitly add the file you want to allow :
In my case : mediaplayer.swf

Avid : Sound card not supported

Just got a free copy of this highly popular Video Editing software named Avid.
Found the following info as well needed for installation :

Serial Number: AvidFreeDV-31E3
Authorization Code: AF7R-XJ5C-UC7K-552H-KE7Q

On running after installation got this :

Exception ADM_DSOUND_MIXER_OPEN_ERROR

Searching on net revealed my sound card : Realtek is
not supported by Avid.

Which sound card should I buy?

Unable to kill inetinfo.exe

I had this nagging problem for past few hours.

I use xampp and that uses 80 as default port for Apache.
All of a sudden xampp failed to start since port 80 was
being used by some other process.

I ran xampp-portcheck.exe which showed Port 80 being used
by inetinfo.exe.

I went to task manager and killed it but it restarted within
a second. And it kept happening.

After many trials and errors I opened msconfig and in Services
tab disabled IIS Admin. Then I restarted my machine and everything
back to normal.

Though I don't know what had enabled it in the first place.

Monday, January 14, 2008

Thursday, January 3, 2008

Streaming video files online

Microsoft has a paper which compares two methods for streaming media files online.
It is a well written piece and I would recommend reading it.
Here I have tried to rephrase and summarize it for myself.
Others might find it useful too.

Basically the two approaches are
(a) A Normal Web-server (Also known as Progressive Download or HTTP Streaming)
(b) a specialized streaming server.

Normal web server uses existing infrastructure, whereas for (b) you need
to buy specialized software(not sure about hardware, but I guess an upgrade would be
needed).

(a) Uses the standard HTTP/TCP protocol set for transmitting the media file(s) but (b)
uses a customized variant of UDP or even TCP as the case might be. Hence (b) can
meet the real time requirements.

(a) is less secure as the browser stores the file in a cache which anyone can copy. With
(b) copying is not straightforward as of now ;-)

Due to specialized nature of (b) random access is supported even if the file
hasn't been downloaded completely. With (a) it's not possible.

Here is another useful article on the same topic.

PS : I just read about Rich Media Project, which claims to have several features
of a specialized streaming server but with much lower costs. It doesn't even need
any special software for that purpose.

Also, there is an open source streaming server called Red5 available as well, here.

Wednesday, January 2, 2008

Preserving is costly for movies in digital form

Here is the source.

"...To store a digital master record of a movie costs about $12,514 a year, versus the $1,059 it costs to keep a conventional film master.

Much worse, to keep the enormous swarm of data produced when a picture is “born digital” — that is, produced using all-electronic processes, rather than relying wholly or partially on film — pushes the cost of preservation to $208,569 a year, vastly higher than the $486 it costs to toss the equivalent camera negatives, audio recordings, on-set photographs and annotated scripts of an all-film production into the cold-storage vault."

Downloading Youtube videos played in Firefox - Is it legal?

First of all, how to copy a youtube video you just played in Firefox :
Source : Experts-exchange

"...
If you use Firefox, you can grab FLV files out of the cache.

In Windows XP, the Firefox cache is usually here:
C:\Documents and Settings\[your windows user name]\Local Settings\Application Data\Mozilla\Firefox\Profiles\[some number.default]\Cache

In the cache folder, switch to 'details' view. Once you play the video, a large file will appear at the top of your cache folder (you may have to refresh the view). Add the .flv extension and you're good to go. This should work with any site that plays video through Flash, including YouTube.

..."

But, is it legal?
No.
Source : Youtube terms
"...
Content on the Website is provided to you AS IS for your information and personal use only and may not be downloaded, copied, reproduced, distributed, transmitted, broadcast, displayed, sold, licensed, or otherwise exploited for any other purposes whatsoever without the prior written consent of the respective owners.
..."

Also See :

YouTube Threatens Legal Action Against Host of Video Download Tool

Blog Archive