Vmware Problem with ubuntu 13.10

I installed Vmware it was working well, i updated/upgraded OS firmware, now it’s not working. i googled it and found the solution. before telling the solution i wanna tell why this is coming.

VMware Player has a nice auto-detection of kernel changes, and requests the user to compile the required modules in order to load them. This happens from time to time after a regular update of your system. Usually, the dialog of VMware Kernel Module Updater pops up, asks for root access authentication, and completes the compilation.

In theory this is supposed to work flawlessly but in reality there are pitfalls occassionally. With the recent upgrade to Ubuntu 13.04 Raring Ringtail and the latest kernel 3.8.0-21 the actual VMware Kernel Module Updater simply disappeared and the application wouldn’t start as expected. When you launch VMware Player as super user (root) the dialog would stall.

Solution is :

sudo vmware-modconfig --console --install-all

This solution worked for me.

My machine was VMware Player 5.0.2 build-1031769

Counting Digits from given Range

Imagine you sell those metallic digits used to number houses, locker doors, hotel rooms, etc. You need to find how many of each digit to ship when your customer needs to number doors/houses:
1 to 100
51 to 300
1 to 2,000 with zeros to the left
The obvious solution is to do a loop from the first to the last number, convert the counter to a string with or without zeros to the left, extract each digit and use it as an index to increment an array of 10 integers.
I wonder if there is a better way to solve this, without having to loop through the entire integers range.
GitHub Link
Thanx to mathematician’s Post that helped me to understand the complexity of problem, i just understood the equation and converted it to code. Enjoy !

Bash script not working with `sh`

I was testing a simple script and I was wondering why it works fine when executed from directory: ./test.sh but when I try with “sh” command sh test.sh it’s not working:
test.sh: 3: test.sh: [[: not found
test.sh: 7: test.sh: [[: not found
Script:

#!/usr/bin/env bash

if [[ $1 = one ]]
        then
        printf "%b" "two\n" >&2
        exit 0
elif [[ $1 = two ]]
then
        printf "%b" "one\n" >&2
        exit 0
else
        printf "%b" "Specify argument: one/two\n"
        exit 1
fi

I goggled and found this link
Summary

sh is a different program than bash.

Detail

The problem is that the Bourne shell (sh) is not the Bourne Again shell (bash). Namely, sh doesn’t understand the [[ pragma. In fact, it doesn’t understand [ either. [ is an actual program or link to /bin/test (or /usr/bin/[, /usr/bin/test).

$ which [
/bin/[
$ ls -lh /bin/[
-r-xr-xr-x  2 root  wheel    42K Feb 29 17:11 /bin/[

When you execute your script directly through ./test.sh, you’re calling the script as the first argument to the program specified in the first line. In this case:
#!/usr/bin/env bash
Often, this is directly the interpreter (/bin/bash, or any number of other script interpreters), but in your case you’re using env to run a program in a modified environment — but that follow argument is still bash. Effectively, ./test.sh is bash test.sh.
Because sh and bash are different shells with different syntax interpretations, you’re seeing that error. If you run bash test.sh, you should see what is expected.
More info
Others have pointed out in comments that /bin/sh can be a link or other shell. Historically, sh was the Bourne shell on the old AT&T Unix, and in my mind the canonical descent. However, that is different in BSD variations and has diverged in other Unix based systems and distributions over time. If you’re really interested in the inner workings (including how /bin/sh and /bin/bash can be the same program and behave totally differently), read the following:
[1] [2]

As noted: /bin/sh typically (though not always) invokes a POSIX-compliant Bourne shell. Bash is Not Bourne.
Bash will attempt to emulate Bourne when invoked as ‘sh’ (as when /bin/sh symlinks or links to /bin/bash), or if $POSIXLY_CORRECT is defined in the invoking environment, when invoked with the –posix invocation option, or when ‘set -o posix’ has been executed. This enables testing a Bourne shell script / command for POSIX compliance.
Alternately, invoke scripts / test commands with a known POSIX-compliant shell. ‘dash’ is close, the Korn shell (ksh) IIRC offers a POSIX compliant option as well.

Minimum cost flow House coloring with three colors

There are a row of houses, each house can be painted with three colors red, blue and green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color. You have to paint the houses with minimum cost. How would you do it?

Note: Painting house-1 with red costs different from painting house-2 with red. The costs are different for each house and each color.

Approach:
Dynamic Programming solution:
we can paint the i’th house with blue, red or green.

Enter No. of Houses to paint : 6
1 4 5
1 3 9
6 7 2
9 6 4
3 5 2
6 7 4

Minimum Cost to paint all houses are 20
#include <stdio.h>
#include <stdarg.h>
#define COLOR 3
#define MAX(a,b) ((a) > (b) ? a : b)
#define MIN(a,b) ((a) < (b) ? a : b)
#define R 0
#define B 1
#define G 2
#define Color 3


int min( int num, ... )
{
    va_list arguments;
    int min=0;
    int tmp=0;
    /* Initializing arguments to store all values after num */
    va_start ( arguments, num );
    /* Sum all the inputs; we still rely on the function caller to tell us how
     * many there are */
    min = va_arg ( arguments, int );
    //printf("\n1st|%d|\n",min);
    for ( int x = 1; x < num; x++ )
    {
		tmp = va_arg(arguments,int);
		min = MIN(min,tmp);
    }
    va_end ( arguments );
    // Cleans up the list
	//printf("\nMin is %d", min);
    return min;
}
typedef struct {
    int  color;
    int cost;
    //struct nodee *root;
}node;
int main()
{
	node cost[3];
	int house = 3;
	printf("Enter No. of Houses to paint : ");
	scanf("%d",&house);
	int color[house][COLOR];
//	int ji=0;
	for(int i=0; i<house;++i){
		for(int j=0; j<COLOR;++j){
				scanf("%d",&color[i][j]);
//				color[i][j]= ++ji;
			}

		}
	//cost[0].cost=color[0][R];cost[1].cost=color[0][B];cost[2].cost=color[0][G];
	for(int i= 0; i< Color ;i++){
			cost[i].cost=color[0][i];
			cost[i].color = i;
		} // Initial Submission of values, and colour
//	printf("\nA.cost\t%d(%d)\tB.cost\t%d(%d)\tC.cost\t%d(%d)\n",cost[0].cost,cost[0].color,cost[1].cost,cost[1].color,cost[2].cost,cost[2].color);
	//A.color = R; B.color = B; C.color = G;
	int tmp_B=0,tmp_G=0,tmp_R=0;
	//printf("\nR_cost\t%d\tB_cost\t%d\tG_cost\t%d\n",R_cost,B_cost,G_cost);
	for(int i=1; i<house;++i)
		{
			for(int j= 0; j< Color ;j++){
				if(cost[j].color == R){
						if(color[i][B] < color[i][G]){
							cost[j].cost = cost[j].cost + color[i][B];
							cost[j].color = B;
							//add_linked_list();
							//cost[j].root = malloc(sizeof(struct node));
							//cost[j].root->next = 0;
							//cost[j].root->x = color[i][B];
						}else{
								cost[j].cost = cost[j].cost + color[i][G];
								cost[j].color = G;
						}
					}else if(cost[j].color == B){
							if(color[i][R] < color[i][G]){
								cost[j].cost = cost[j].cost + color[i][R];
								cost[j].color = R;
							}else{
									cost[j].cost = cost[j].cost + color[i][G];
									cost[j].color = G;
								}
						}else{
								//Case for G
								if(color[i][R] < color[i][B]){
									cost[j].cost = cost[j].cost + color[i][R];
									cost[j].color = R;
									}else{
											cost[j].cost = cost[j].cost + color[i][B];
											cost[j].color = B;
										}
							}
//			printf("\nA.cost\t%d(%d)\tB.cost\t%d(%d)\tC.cost\t%d(%d)\n",cost[0].cost,cost[0].color,cost[1].cost,cost[1].color,cost[2].cost,cost[2].color);
			}
			/*
			if(A.color == )
			//R_cost = min(2,color[i][B],color[i][G])+R_cost;
			if(color[i][B] < color[i][G]){

				tmp_B = R_cost + color[i][B];
				}else{
						tmp_G = R_cost + color[i][G];
					}

			//B_cost = min(2,color[i][R],color[i][G])+B_cost;
			if(color[i][R] < color[i][G]){

				tmp_R = B_cost + color[i][R];
				}else{
						tmp_G = B_cost + color[i][G];
					}
			//G_cost = min(2,color[i][B],color[i][R])+G_cost;
			if(color[i][R] < color[i][B]){

				tmp_R = G_cost + color[i][R];
				}else{
						tmp_B = G_cost + color[i][B];
					}
			R_cost = tmp_R;
			B_cost = tmp_B;
			G_cost = tmp_G;
			//printf("\n G %d:%d",color[i][B],color[i][R]);
			*/
//			printf("\nA.cost\t%d(%d)\tB.cost\t%d(%d)\tC.cost\t%d(%d)\n",cost[0].cost,cost[0].color,cost[1].cost,cost[1].color,cost[2].cost,cost[2].color);
		}
	printf("\nMinimum Cost to paint all houses are %d\n",min(3,cost[0].cost,cost[1].cost,cost[2].cost));
}

First Version of RegextoWord

Hello Guys. I have been working in Perl from last 5 moths and while writing Regular Expressions i face difficulty to understand or write the Regular expressions. Well now it’s ok, but i thought can we covert the RegEx to understandable language.
So i started an project, here is the first version of the RegExtowordV1.0.

It can accept(Parse) Strings like

^arun
^[arun]
^[a-z]
^[A-Z]
^[a-zA-Z0-9]
^[a-zA-Z0-9]Arun
^[a-zA-Z0-9]A\^\%run
[arun]
(A|R|U|N)

Basically in first version it can parse string (any word , digit special character, ^ ,[] () ).
please do give some feedback about it.

Increment decrement problem in c

Hello guys let's we have an syntax and related values let's see how this works. Evaluate the given syntax 
z = ++x + y-- - ++y - x-- - x-- - ++y - x--
where x = 7 y = -3
z = ((((((++x + y--) - ++y) - x--) - x--) - ++y) - x--)
so first(++x + y--) will be evaluated
 (++x + y--)
   8 + (-3)        x=8 y = -4
 z = (((((5 - ++y) - x--) - x--) - ++y) - x--)
 (5 - ++y)
  5 - ( -3)  x=8 y = -3

 z = ((((8 - x--) - x--) - ++y) - x--)
 (8 - x--)
  8 - 8      x =7 y = -3 
 z = (((0- x--) - ++y) - x--)
 (0- x--)
  0 - 7      x =6 y = -3
 z = (((-7 - ++y) - x--)
 (-7 - ++y)
  -7 - (-2)  x = 6 y = -2
 z = (-5 - x--)
 -5 -6       x =5 y -2
 z = -11

So answer is -11

connecting to archive.ubuntu.com takes too long

I have a Ubuntu 13.04 that I just installed fresh. Now if I try to do anything with apt-get, it tries to connect to archive.ubuntu.com .. It stays at [Connecting to archive.ubuntu.com (2001:67c:1360:8c01::1a)] phase for like 2 minutes, after which it actually starts to communicate and download stuff …

Eventually it always connects, but in waits at the [Connecting to archive.ubuntu.com (2001:67c:1360:8c01::1a)] phase everytime for like 2 minutes !

I didn’t have this problem previously on Ubuntu 13.04, right after reinstalling the OS ..

Solution:

I figured out the problem. Posted below as an answer!

Running the following command in Terminal tells if IPv6 is enabled or not:

cat /proc/sys/net/ipv6/conf/all/disable_ipv6

0 means its enabled, while 1 means its disabled.

To disable IPv6 from within Terminal, enter the following and reboot:

echo "#disable ipv6" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.all.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.lo.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf

After boot, re-run the first command, and it should be 1 now, after running this run

sudo sysctl -p

all output should be 1, now ipv6 is disable here.

Intel@ GM965 Driver problem while installing Bluestack

Hello guys ,i was trying to install bluestacks for my laptop compaq presario 785tu ,which one have Intel @ GM965 integrated graphics card so , it was giving me graphics error to update the graphics driver but my driver was upto date still it was giving me error .

Error_img_bluestack

to i googled it more then i tried this Intel’s Graphics  Accelerator then

downloadmirror.intel.com/18223/a08/win7_1512754.exe
bluestacks started to work !!
all the best guys

How to recover your blog password

Hello , Friends

i have a website which is hosted be wordpress  , i updated my wordpress from 3.5 to newer version but from that time i was not able to access the my wp-admin menu .

i googled a little bit then i didn’t get any thing then  i tricked with my website ……

1. i downloaded everything from my hosting place to my computer through filezila

2. the i made some changes in files  “admin.functions.php” in “upgrade-functions.php”  .

changes was i added

wp_set_password('password',1);

Put in your own new password for the main admin user. The “1” is the user ID number in the wp_users table.

3. Upload the modified file back to your site.

4. After you then are able to login, make sure to go back and remove that code. It will reset your password on every page load until you do.

 

Cheers !!!

 

Hi Guys

Hi Guys , December was the holiday time , in this  winter i decided to studied Python ,that is very Good Scripting LAnguage , this helps us in very different ways … i will put some lecture videos and some assignments this will help you guys .

 

All the BesT !! 🙂