Monday, November 16, 2009

How to Reset Sansa Mp3 Player when it Freezes

I got 2GB Sansa Mp3 player, as a complementary accessaries with Nikon CoolPix L20.
My Mp3 Player freezes, when I am charging it and accedentally unplug it, witout ejecting it. Some time it hungs while plying Song.

After couple of try I found few solutions that can reboot Sansa MP3 Player, and it works with my Sansa MP3 player.

1.  Turn ON the Hold switch. (move hold button to Hold Position)
2.  Press and hold Menu and Rec buttons at the same time until the Sansa MP3 player reboots.

Alternate Solution is :
Hold Menu (Power) button for atleast 20 seconds. Sometimes this trick works.

Hard Reset
To perform hardware reset on the Sansa Express, press and hold the "Select" button while pressing the Volume UP (+) buttons simultaneously once.

How to use ClamAv Antivirus on Ubuntu?

This tutorial will explain you, how to Install and use ClamAv Antivirus on Ubuntu. ClamAv antivirus is a free antivirus, available in ubuntu repository.

To install ClamAv antivirus and GUI to manage it on ubuntu 9.10,  use Ubuntu Software Center to install "KlamAV".  KlamAV is an anti-virus manager for the KDE desktop. It allows virus scanning, software/update databases, etc.

I am using "KlamAV" as a GUI tool to manage and use ClamAV antivirus.  You can also use "clamtk" as a GUI to use CLAMAV in Gnome or KDE.
Use following command to install "clamtk"
sudo apt-get install clamtk

Once it is installed on your machine,  then install anti-virus updater, so that you can get  latest update of ClamAV from Internet.
sudo apt-get install clamav-freshclam

Use command "sudo freshclam" to update ClamAV database. 
To check the version of ClamAV use following Command:
clamdscan -V

To do command line scanning:
1.  To scan specific folder:
     sudo clamscan -r /home/directoryname/subdirectory
     Above command will display the name of files in subdirectory on the screen. You can use -i parameter to display only infected files. 
2.  To scan all files on your computer
      sudo clamscan  -r   --bell  -i   /
     Above command will display only infected files and will bell the ring when virus found.
3. To remove infected file from your computer
    sudo clamscan -r -remove /

Friday, November 13, 2009

Lambda Calculus Type inference examples

1] \ x -> x
 Above function takes one argument and returns the same argument as result, therefore type of argument and return value must be same.

type: a - > a

2] \ x y -> x
Above function takes two arguments and returns the first argument as result, therefore type of first argument and return value must be same.

type: a -> b -> a

3] \f g -> g (f g)
Above function takes two parameter f and g.

To solve this, my algorithm is as follows:

First look at function body from right-to-left. Function body is g(f g)

Assume type of g is t1. That is,  ( g = t1).

Now, take next variable from function body, which is ff is a function that take g as argument and return value of any type, say return type is a. So far, there is no restriction of return value of f.  assume type of f is t1-> a. That is,  (f = t1 -> a).

Now, take next variable, which is gg is a function that takes return value of function f as a argument (a), and returns value of any type, say return type is b. So far there is no restriction of type of value return by g.  But we already assume g is of type t1.  Now, we found that g is function so, t1 is a - > b.
That is, (g = gt1 = a -> b).

Now replace t1 in f with (a -> b). So f becomes f = (a -> b ) -> a

we have done with function body. Now look at function declaration syntax. It takes two arguments f and g, and f is first argument, g is second argument, and return value is of same type of return value of g.

So type of function \f g -> g (f g) is as follows:

((a -> b) -> a) -> ( a -> b) -> b

4] \ x f g -> f g (x g)

 Above function accepts three arguments x, f and g
 Assume g is of type a. that is, (g = a).
 Now, x takes g as a argument and returns any type of value. So far there is no restriction on type of value returned by x, say return type of value is b
Therefore, x = a -> b

Now, f takes two argument g and return type of x. Return type of f has no restriction, so say it is of type c
Therefore, f = a -> b -> c

(Note: For simplicity as assume g as a variable. And is of type a. However, you can consider it g as a function then you have to unify a = d->e and replace all occurrences of a with d->e)

  Return type of f is the return type of this function.

Now look at function definition and arrange its type accordingly.

\ x f g -> f g (x g) type is as follows:

(a -> b) -> (a -> b -> c) -> a - > c 

5] \ f g x -> f ( g x)

Above function takes three arguments, namely, f , g ,and x.

Assume x is of type a., That is ( x = a)

Now g takes x as argument and returns a value. Assume return type of g is b.
Therefore, (g = a -> b)

Now f takes return value of g as argument (that is, b) and returns a value.
Therefore, ( f = b -> c)

So type of \f g x -> f (g x) is:
Now, look at function declaration: \f g x

(b -> c) -> (a -> b) -> a ->c

6] \x y f -> f (x (\w -> f w)) (y f x)

Above function takes three arguments, x y and f.

Now look at Function body, and assume type for each variable.
Let w = a
       x = t1
       y = t2
       f  = t3

 Observe the function body, f will be applied to on first argument (x (\w -> f x)),  and then it will be applied on second argument (y f x).

Go inside \w function,

 f = t3 = a - > b

Therefore, x = t1 = (a -> b) -> c

Return type of x is c, which will become the argument of f, therefore unification is possible here, and c = a;

Hence, x = t1 = (a->b) ->a

Now we examine ( y f x) part,

y = t2 = (a -> b) -> (a->b->a) -> d

d is the return type of y.

After applying the first argument (x(\w->f w)), f returns b.

Therefore, d is parameter of b.

b should take d as argument and return a value, That is, b = d -> e

Now replace each occurrence of b with d -> e

f = a -> b = a -> d -> e

x = (a ->b -> a ) = ((a -> d -> e)- > a)

y = (a ->d -> e) -> ( a -> d -> e) -> a) -> d

Hence type of entire expression is, (arrenge according to function definition:

((a -> d -> e)- > a) ->
 (a ->d -> e) -> ( a -> d -> e) -> a) -> d ->
(a -> d -> e) -> e

e is the return type of entire expression which is also the return type of f.


Wednesday, November 4, 2009

Plugins Vs Extension

Extension and plugins often confused people. And Mostly people believe both are same.
However, there is subtle difference between Extension and Plugin.  Extensions are mostly written in JavaScript and/or XUL and relies on XPCOM APIs to access resources. Whereas, plugins are binary applications and they make use of operating system and can do interaction with operating system or access events from OS.

Securing plugins is more complex than extension.  Extension are individual identity so one extension needs one set of privileges, whereas plugins are more complicated and needs to identify privileges for each application runs plugins rather than a whole plugin.