Wednesday, February 6, 2013

Mac: Change root password without old password


If you don’t have access to an administrator already, you need to acquire root access.

If you don’t have admin access, boot the computer into Single-User Mode by holding CMD+S on startup, mount the drive, and type the command:

Wait until you see a bunch of white writing scrolling by on a black screen. You can release the keys, and you are now in Single-User mode. The computer is ready to continue when you see localhost:/ root# or something similar as the very last line on the screen.

Then follow the steps to reset admin password without old password
 /sbin/fsck -fy
        This command is a 'File System Consistency Check' and works very much the same way as Disk Utility's 'Repair Disk' function.
  /sbin/mount -uw /
        The mount command gives us access to the files on the system so we can make changes.
   
 launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist

 and finally:
 passwd
        Then, enter your new root password when prompted twice. After the password has been reset, type:
       
 reboot
        this command restarts the computer.

Friday, January 25, 2013

Android: Solution to catch that the Home button was pressed

Home Button is like an emergency escape button.
Pressing Home twice will always take a user back to the center panel of the Home Screen, so whatever application they're running, it's easy for a user to get back to somewhere they know. You shouldn't really be overriding this unless you're producing a full Home replacement.

Don't  permanently override the Home button without the user confirming it.

We need to do follow three steps here...
1. Override onKeyDown and compare keycode with KeyEvent.KEYCODE_HOME
2. Override onAttachedToWindow()
3. add category to the activity because
CATEGORY_HOME : This is the home activity, that is the first activity that is displayed when the device boots.
<category android:name="android.intent.category.HOME"/>

Solution:  Source Code Here

Friday, January 11, 2013

Eclipse Widows 7: cntrl+space is not working

Issue:
In windows 7, eclipse content assist (ctrl + space) is not working.

Problem:
In Windows 7, "CTRL+Space" is used to switch the language. So its overriding the key of eclipse.

 Solution:
 1.       Windows key+R, type regedit and click Ok.
2.       Navigate to HKEY_CURRENT_USER/Control Panel/Input Method/Hot Keys 
3.       Select the key named: 
4.       00000070 and 00000010
o    Key Modifiers designate  (02c00000).
o    Virtual Key designates (20000000).
5.       In the right sub-window, there are three subkeys.
6.       Change the first byte in Key Modifiers from 02 to 00
7.       Change the first byte in Virtual Key from 20 to FF
8.       Log off and log back on.
9.       Do not change the Hot keys for input languages in Control Panel, unless you want to do this all over again.