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.
Monday, November 16, 2009
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.
Use command "sudo freshclam" to update ClamAV database.
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 /
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:clamdscan -V
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 f. f 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 g. g 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 = g = t1 = 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
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.
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 f. f 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 g. g 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 = g = t1 = 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:
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.
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.
Tuesday, October 13, 2009
JavaScript Call Stack
This post explains how to get JavaScript Calls stack in Mozilla extension. You can also use jsdI interface hooks to get JS call stack. Pls refer jsdIDebuggerService on MDC.
You need to call the function callstack( ) to get the JSCall stack. From where to call this function is depend on need of user. You can call this function wherever you want to get JS call stack.
function callstack( ){
/* stackFrameStrings holds entire JS calls stack in string format */
var stackFrameStrings = new Error().stack.split('\n');
/* remove first two stack frames because they are frames of callstack() and error() functions */
stackFrameStrings.splice(0,2);
for (var i in stackFrameStrings) {
/*
A stack frame string split into parts. (example of stack frame string is:
href("http://www.comp.nus.edu.sg")@:0) Note 0 indicates native function call in Mozilla firefox, and 1 is for onclick, onmouseover functions, ie. JS event functions, otherwise the number is line number in source file and contains URL of source file. Anothe rexample of stack frame string is :
onclick([object MouseEvent])@file:///home/patilkr/Desktop/Html%20Test/js_http_test.html:1
*/
var stackFrame = stackFrameStrings[i].split('@');
if (stackFrame && stackFrame.length == 2) {
dump("\n stackFrame[0]=" + stackFrame[0] + " stackFrame[1]=" + stackFrame[1] );
} // end of if loop
}//end of for loop
} //end of callstack function
You need to call the function callstack( ) to get the JSCall stack. From where to call this function is depend on need of user. You can call this function wherever you want to get JS call stack.
function callstack( ){
/* stackFrameStrings holds entire JS calls stack in string format */
var stackFrameStrings = new Error().stack.split('\n');
/* remove first two stack frames because they are frames of callstack() and error() functions */
stackFrameStrings.splice(0,2);
for (var i in stackFrameStrings) {
/*
A stack frame string split into parts. (example of stack frame string is:
href("http://www.comp.nus.edu.sg")@:0) Note 0 indicates native function call in Mozilla firefox, and 1 is for onclick, onmouseover functions, ie. JS event functions, otherwise the number is line number in source file and contains URL of source file. Anothe rexample of stack frame string is :
onclick([object MouseEvent])@file:///home/patilkr/Desktop/Html%20Test/js_http_test.html:1
*/
var stackFrame = stackFrameStrings[i].split('@');
if (stackFrame && stackFrame.length == 2) {
dump("\n stackFrame[0]=" + stackFrame[0] + " stackFrame[1]=" + stackFrame[1] );
} // end of if loop
}//end of for loop
} //end of callstack function
Wednesday, October 7, 2009
Mozilla Firefox about:config Tweaks
Accessing your about:config page
In your Firefox, type about:config in the address bar.
Disable Delay Time When Installing Add-on
Config name: security.dialog_enable_delay
Default: 2000 (in msec)
Modified value:
There are two configuration need to be made:
Config name: view_source.editor.external
Default: False
Modified value: True ( enable view source using external text editor)
Config name: view_source.editor.path
Default: blank
Modified value: insert the file path to your editor here.
Autohide Toolbar in Fullscreen mode
Config name: browser.fullscreen.autohide
Default: True (always autohide)
Modified value: False (always show the toolbar)
In your Firefox, type about:config in the address bar.
Disable Delay Time When Installing Add-on
Config name: security.dialog_enable_delay
Default: 2000 (in msec)
Modified value:
- 0 – start installation immediately
- any other value (in msec)
There are two configuration need to be made:
Config name: view_source.editor.external
Default: False
Modified value: True ( enable view source using external text editor)
Config name: view_source.editor.path
Default: blank
Modified value: insert the file path to your editor here.
Autohide Toolbar in Fullscreen mode
Config name: browser.fullscreen.autohide
Default: True (always autohide)
Modified value: False (always show the toolbar)
Friday, October 2, 2009
90/10 and Self assement Principals
This is a non-technical post. It is about, how to improve yourself. How to improve your thinking and your life. Principals describe here, if you applied in your life then, they will surely help you to feel satisfaction.
First principal is 90/10 Rule:
What is 90/10 Principal? Well, it is very simple. 10% of life is made of what happens to you and 90% of life is decided by how you react to things happens in your day to day life.
Let me explain this in more detail:
We really have NO control over 10% of incidences that happens to us.
For example, We cannot stop plane from arriving late, we cannot stop mechanical devices from breaking down. We cannot control this 10% of incidences happens to us, However, over the 90% of incidences we have control and our reaction to the situation is the key factor which plays an important role in deciding 90% of our life.
If someone says something negative about you, do not be a sponge or do not lose your tamper.
Let the attack roll off like water on glass. You do not have to let the negative comments affect you.
React properly and it will not ruin your day. A wrong reaction could result in losing a friend, or getting stressed out.
Remember the 90/10 Principle and don’t worry about life.
You are told you lost your job. Why lose sleep and get irritated? It will work out.
Use your worrying energy and time to find a new job.
Millions of people are suffering from stress, problems and headaches.
We all must understand and apply the 90/10 Principle.
It can change your life! You will lose nothing if you apply it.
Second Principal is Self Assessment:
Self assessment means do a regular review of your daily activity/reaction/behavior at the end of day. It helps to make judgment about our own actions.
If you apply this two principals in your life, you will surely be get benefited from it, without lossing anything. You will observe its good effect in you life by yourself.
Friday, September 18, 2009
How to access other VMs and Internet on VirtualBox
VirtualBox supports NAT, host-only, Internal network and Bridged network options.
When Network card of VirtualBox VM is configured with "NAT" option then VM can access host machine and can access Internet, but cannot access other VMs. When I looked at IP address of VM's, I found that they all have same IP address.
VirtualBox assigns same IP to all virtual machine (for example, 10.0.2.15) when NAT is configured. That is, it treats all VM as they on different physical network.
When Network Card of VirtualBox VM is configured with "Internal Network" option then VM can access other VMs but cannot access Internet. In this case, all VM are on same physical network.
If you want to access other VMs as well as Internet, then the simplest solution is install two network cards in VM and assign one to NAT and another to internal network. Then login to all VMs and assign unique address to internal network card of each VM. Note that, you have to assign address to network card which is configured for "Internal Network" in VirtualBox.
That's it. Done. Now you can access Internet as well as other VMs.
Object Oriented Programming
Struct is use to define data types and group them into one object. Struct does not contain methods or functions, and its data members are all public. Struct are useful when we want sets of element with different data types. Struct is a group of data elements grouped under one name. Those data elements are know as members and can have differnet type and different lengths. Struct creates a new type. Once a struct is created a new type with the name of struct is created. It can be used later on in the program to create objects of struct.
A Class have both data members and functions/methods associated with it. A class can contain sever variables and functions/methods, those are called members of class. Bydefault all its members are private.
Class can define its member as private, protected, public. Protected has a special meaning to inheritance. Protected members are accessible in the class that defines them as well as in the classes that inherit from that base class or friend of it.
Class can contain special member functions called as constructors or destructors. Constructors cannot be explicitly called like regular member functions. They are automatically executed when new object of class is created.
In principal, private and protected members of a class cannot be accessed from outside the scope of the same class in which they are declared. However this rule does not affect friends. Friendship is no transitive and it is not bidirectional.
Inheritance is a key feature of C++ class. It allows to create a class which is derived from other classes, so it can automatically include/inherit members of base class. When class inhertis from another class the members of derived class can access only the public/protected members of base class, but cannot access private members of base class.
In principal, a derived class inherits every member of base class except its constructor, destructor, and its friends.
Virtual function/member: A member of class can be redefined in its derived classes is know as a virtual member.
When the type of pointer is pointer to base class but it is pointing to an object of th derived class, virtual keyword in-front of member functions allows a member function of a derived class with the same name as one in base class to be called from base class pointer to derived class object.
A class that declares or inherits a virtual function/member is called a polymorphic class.
Abstract base class is a class that lacks implementation of atleast one member. Therefore, we cannot create object of that class (cannot create object of ABC - Abstract Base Class). These are the main differences between abstract class and a regular polymorphic class. The function which lacks implementation is called as pure virtual function. for example, virtual int function_name() = 0; However, pointers of ABC (Abstract Base Class) can be used to point to objects of derived classes.
Templates are special types that can operate with generic types. Templates allows us to create a function template whose functionality can be adapted to more than one type without repeating the entire code. That is, we don't need to write the same functionality code for different types such as int, float, char, etc. This allows generic programming, bocz it access any type object.
Vector better than Array and works as Array
Vector is a template class and it allows programmers to create a dynamic array of elements of one type per instance.
Vector is conceptually same as arrays in C. However, vector size can expand to hold more elements and can shrink when fewer will suffice.
Note: Accessing members of vector or appending elements does not depend on vector size and takes fixed amount of time, however, locating a specific value element or inserting value element into vector takes the amount of time directly proportional to its location in vector.
//////////////////////////////////////////////////////////////////////
// Standard Template Library (STL)
//
// Vector Functions:
//
// vector::push_back - Appends (inserts) an element to the end of a
// vector, allocating memory for it if necessary.
//
// vector::pop_back - Erases the last element of the vector.
//
// vector::size - Returns number of elements in the vector.
//
//////////////////////////////////////////////////////////////////////
#include
#include <vector >
using namespace std ;
int main()
{
// Dynamically allocated vector begins with 0 elements.
vector<int>
// Add one element to the end of the vector, an int with the value 1.
// Allocate memory if necessary.
theVector.push_back(1) ;
// Add two more elements to the end of the vector.
// theVector will contain [ 1, 2, 3 ].
theVector.push_back(2) ;
theVector.push_back(3) ;
int tmp;
cout << "\n Enter new element on new line. press Ctrl +D to terminate " <
while (cin >> tmp)
theVector.push_back(tmp);
// Erase last element in the vector.
theVector.pop_back();
theVector.pop_back();
// Print contents of theVector.
cout << "theVector [" ;
for (int k =0; k < theVector.size(); k++)
cout <<" " << theVector[k];
cout << " ]" << endl ;
}
Subscribe to:
Comments (Atom)
