Upon installing visual studio 2012 in windows 7 you may notice that it gives compatibility warning on running visual studio. It fix is plain simple. Just go to the following link and download and install the patch. And get cracking :D
http://www.microsoft.com/en-pk/download/confirmation.aspx?id=36020
Friday, May 2, 2014
Friday, April 4, 2014
Purple screen on windows start when dual booting with ubuntu
Recently i installed Ubuntu alongside windows 7 on my Dell 15R 5537. Initially everything worked fine but after some update perhaps; windows stopped working. On selecting windows from the boot menu, it would show a purple screen, however i could hear windows boot and its start screen. Googled for days but did not find an exact solution. Here is what I did
First try doing this
On the grub menu highlight the windows menu item using the keyboard and then press 'e' to the end of the line that begins with "set root= *******" add 'quiet splash' so that it becomes
"set root= ******* quiet splash"
now press ctrl + x
Does it solve the problem? If it did now you proceed to make the change permanent
Start ubuntu
press ctrl + alt + t to open up terminal
type 'sudo gedit'
in the editor navigate to /boot/grub/grub.cfg and open the file
In the file select the menu entry for windows and copy it
Now open the file /etc/grub.d/40_custom
Paste the menu entry that you copied previously after the comments on a new line
In the menu entry add the "quiet splash" as done before
Save the file
Now run
sudo update-grub
Reboot, enjoy!
First try doing this
On the grub menu highlight the windows menu item using the keyboard and then press 'e' to the end of the line that begins with "set root= *******" add 'quiet splash' so that it becomes
"set root= ******* quiet splash"
now press ctrl + x
Does it solve the problem? If it did now you proceed to make the change permanent
Start ubuntu
press ctrl + alt + t to open up terminal
type 'sudo gedit'
in the editor navigate to /boot/grub/grub.cfg and open the file
In the file select the menu entry for windows and copy it
Now open the file /etc/grub.d/40_custom
Paste the menu entry that you copied previously after the comments on a new line
In the menu entry add the "quiet splash" as done before
Save the file
Now run
sudo update-grub
Reboot, enjoy!
Sunday, January 13, 2013
Root HTC Wildfire S
Wasted a day of my life trying out links that never worked.
This link was a life saver
http://forum.xda-developers.com/showthread.php?t=1702542
Saturday, January 12, 2013
Missing power option in Ubuntu 12.04
There is a feature/bug in Ubuntu 12.04 that does not let you choose actions on critical battery. I finally found a solution to the problem
As it turns out the option can be set if you use the non-GUI method. For those who wish that the laptop suspends instead of hibernate (defult action). You should use
NOTE: sudo is not required
gsettings set org.gnome.settings-daemon.plugins.power critical-battery-action 'nothing'
gsettings set org.gnome.settings-daemon.plugins.power critical-battery-action 'suspend'
Labels:
Bugs,
hibernate,
power options,
suspend,
terminal,
ubuntu 12.04
Saturday, December 15, 2012
How to make a bootable Windows USB under any LINUX version
There are a lots of softwares available for making bootable and live USB's but they all fail at one distro or another.
So here is a magic bullet that fits all.
All you need is a bootable OR live distro's iso image file. If you have a live distro you'd get a live USB, if you only have bootable iso image you would get a bootable USB only.
First locate your USB
Then run this, replace path-to-iso with the path to where the iso file is on your disk and the ? with drive letter for your USB
Dont forget the sync command at the end to flush the usb-cache. Example
Note: Do not include the numeric number e.g. its /dev/sdc and NOT /dev/sdc1!
sudo fdisk -l
Then run this, replace path-to-iso with the path to where the iso file is on your disk and the ? with drive letter for your USB
dd if=/path-to-iso of=/dev/sd? sync
Dont forget the sync command at the end to flush the usb-cache. Example
dd if=/home/me/ubu.iso of=/dev/sdc sync
Sunday, October 7, 2012
Generating random numbers in c++
#include "stdafx.h"
#include <iostream>
#include <time.h>
using namespace std;
int main()
{
int c;
srand(time(NULL));
while(1)
{
cout<<rand();
}
return 0;
}
Lets have an in depth look at the code. The actual random numbers are generated by the rand() function. The numbers that it generates are not random but are pseudorandom i.e. they appear to be random but are not. In actual the rand() function generates a predictable series of numbers. The series however can be initialized with a seed value which in the above code is being done using the srand() function. The srand() needs only be called once during a typical program. However given a same seed value the program will generate the same random numbers every time the program is run. In order to avoid this repetition across program executions. We have passed the time(NULL) as an argument to the srand() function. Which will initialize the srand with a new value every time the function is called, hence now the numbers generated by rand() would appear to be random.
Saturday, October 6, 2012
Using the arrow keys in c++ using scan codes
As a programmer you may have been tempted to use the arrow keys to take input from the user, did you get frustrated and gave up because it was not as trivial as it should be?
Well it is a piece of cake but to eat it you have to earn it.
Wait no further....
For those in a hurry here is the code
Lets examine the code step by step. Before diving into details lets have a look at the background. Any key pressed from the key board generates a unique code (think of it as a number stored as a HEX value), this code is known as Scancode Generally each code is one byte in size but some keys (keys with special functions) generate two or more bytes and this code is referred to as extended Scancodes
The following keys fall under the extended category
If an arrow key is pressed it generates two bytes, one the code for the key pressed prefixed with an 0xE0 or decimal 224 (scan code for left shift release) on most systems. The corresponding scan codes for the keys are
Well it is a piece of cake but to eat it you have to earn it.
Wait no further....
For those in a hurry here is the code
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int c;
while (1)
{
c = getch(); // first call gets the 0xE0 byte or decimal 224
switch(c) // lets just waste the value
{
case 0:
case 224:
switch (getch()) //Here the actual code for the key is got
{
case 72: cout << "up arrow\n"; break;
case 75: cout << "left arrow\n"; break;
case 77: cout << "right arrow\n"; break;
case 80: cout << "down arrow\n"; break;
default: cout << "extended key " << c << "\n";
}
}
}
return 0;
}
Lets De-magicify
And here is the treat for the geeks.Lets examine the code step by step. Before diving into details lets have a look at the background. Any key pressed from the key board generates a unique code (think of it as a number stored as a HEX value), this code is known as Scancode Generally each code is one byte in size but some keys (keys with special functions) generate two or more bytes and this code is referred to as extended Scancodes
The following keys fall under the extended category
- Arrow keypad
- Home keypad
- Right Alt
- Right Ctrl
- keyboards with the arrow pad, home pad and number pad
If an arrow key is pressed it generates two bytes, one the code for the key pressed prefixed with an 0xE0 or decimal 224 (scan code for left shift release) on most systems. The corresponding scan codes for the keys are
- Up 72
- Down 80
- Left 75
- Right 77
Scancodes c++ and the getch function
The getch function gets a single character from the console, since extended scan codes, especially the arrow keys generate two bytes, you can already judge why we'd need two calls to getch(), the first call gets the code 224 and the next one gets the actual code for the key pressed. The rest is plain c++ switch statements. Enjoy your programming :)
Subscribe to:
Posts (Atom)