Tuesday, February 19, 2013

Remove standy Linux


xset s off
xset s noblank
xset -dpms

to the ~/.X.d/xset file has worked for me.

Monday, January 7, 2013

forgot Mac OS X account password

If you have forgot Mac OS X account password then there is a tricky method which let you create a new administrator account on Mac OS X and through that admin account you can reset password of previous account.
So, let’s see how to create an administrator account on Mac while you lost your Mac passwords. This guide written using Mac OS X Snow Leopard.

Creating new Mac OS X account to recover old account

Step 1

Restart system and hold “Cmd + S” keys from keyboard until it shows Terminal.
Startup terminal

Step 2

Now type the following commands one after one and press “Enter” button after each command to execute it individually
/sbin/mount -uaw
rm /var/db/.applesetupdone
reboot
Run commands

Step 3

“Reboot” command will restart the Mac and you will see the “Welcome wizard” after beautiful welcome messages animation.
Mac OS X welcome wizard
Follow all the wizard instructions, until you see the following screen to create new account. Fill all entries and hit Continue button.
Create mac account
This will create a new administrator account and automatically log into it.

Reset old user account password

Now you can reset the password of your old Mac OS X account using this new account, here is the process.

Step-4

Click on “Apple icon” and then “System Preferences”
Mac system preferences
Click on “Account”s icon
Accounts

Step-5

Here you can see all Mac OS X user accounts are listed, new account “TrickyWays” that we have created and “Susan” the old one that we want to recover.
Click on lock icon to enable prev. account “Susan” and reset its password.
Click lock to make changes
Enter the Password of current user account and hit OK button
Type User password

Step-6

Now your prev. account is enabled for changes, select that and hit the “Reset Password” button
Reset password
Enter “New password”, “Password hint” and hit “Reset Password” button to reset account password.
Enter new password for account
Now log off and log in to your prev. account “Susan” and you can delete the account “TrickyWays” that we have created to recover prev. account “Susan”.

Monday, November 19, 2012

Get and set with C#


You don't need to use set or get. You could write functions named setFoo or getFoo instead of using a property Foo:
  1. class Point {
  2. double x, y;
  3. public Point(double x, double y) {
  4. this.x = x;
  5. this.y = y;
  6. }
  7. public double GetX() { return x; }
  8. public void SetX(double x) { this.x = x; }
  9. public double GetY() { return y; }
  10. public void SetY(double y) { this.y = y; }
  11. }

But that's a real pain -- you'd rather write pt.Y = 3; and be able to write things like pt.Y += 5; , instead of pt.SetY(pt.GetY() + 5); .
So instead C# has properties:
  1. class Point {
  2. double x, y;
  3. public Point(double x, double y) {
  4. this.x = x;
  5. this.y = y;
  6. }
  7. public double X {
  8. get { return x; }
  9. set { x = value; }
  10. }
  11. public double Y {
  12. get { return y; }
  13. set { y = value; }
  14. }
  15. }

Inside the setter, the keyword 'value' is the variable containing the value that is getting assigned to the property Y.
The pattern of having properties directly backed by fields is so common that in C# 3, shortcut syntax was added.
  1. class Point {
  2. public Point(double x, double y) {
  3. X = x;
  4. Y = y;
  5. }
  6. public double X { get; set; }
  7. public double Y { get; set; }
  8. }

There are a few reasons to use properties, instead of public fields. One is that properties can be virtual. Another is that you can make the setters for a property private. Another is that properties have a 'special' meaning to things that inspect classes at runtime. There are frameworks for conveniently talking to databases and for reading and writing objects to and from XML and all sorts of other things -- and they automatically look at the object's properties (and not private fields or other things) to see how to do their job.

Friday, November 16, 2012

Free Javascript Obfuscator and Free PHP Obfuscator


Free Javascript Obfuscator

http://www.javascriptobfuscator.com/default.aspx



Free PHP Obfuscator

http://www.pipsomania.com/best_php_obfuscator.do
http://www.mobilefish.com/services/php_obfuscator/php_obfuscator.php

Monday, November 5, 2012

This example calls the ToInt32(String)

This example calls the ToInt32(String) method to convert an input string to an int . The program catches the two most common exceptions that can be thrown by this method, FormatException and OverflowException. If the number can be incremented without overflowing the integer storage location, the program adds 1 to the result and prints the output




static void Main(string[] args)
{
    int numVal = -1;
    bool repeat = true;

    while (repeat == true)
    {
        Console.WriteLine("Enter a number between −2,147,483,648 and +2,147,483,647 (inclusive).");

        string input = Console.ReadLine();

        // ToInt32 can throw FormatException or OverflowException. 
        try
        {
            numVal = Convert.ToInt32(input);
        }
        catch (FormatException e)
        {
            Console.WriteLine("Input string is not a sequence of digits.");
        }
        catch (OverflowException e)
        {
            Console.WriteLine("The number cannot fit in an Int32.");
        }
        finally
        {
            if (numVal < Int32.MaxValue)
            {
                Console.WriteLine("The new value is {0}", numVal + 1);
            }
            else
            {
                Console.WriteLine("numVal cannot be incremented beyond its current value");
            }
        }
        Console.WriteLine("Go again? Y/N");
        string go = Console.ReadLine();
        if (go == "Y" || go == "y")
        {
            repeat = true;
        }
        else
        {
            repeat = false;
        }
    }
    // Keep the console open in debug mode.
    Console.WriteLine("Press any key to exit.");
    Console.ReadKey();    
}
// Sample Output: 
// Enter a number between -2,147,483,648 and +2,147,483,647 (inclusive). 
// 473 
// The new value is 474 
// Go again? Y/N 
// y 
// Enter a number between -2,147,483,648 and +2,147,483,647 (inclusive). 
// 2147483647 
// numVal cannot be incremented beyond its current value 
// Go again? Y/N 
// Y 
// Enter a number between -2,147,483,648 and +2,147,483,647 (inclusive). 
// -1000 
// The new value is -999 
// Go again? Y/N 
// n 
// Press any key to exit.

C# - DataGridView - Confirmation Dialog on Row Delete

            if (!e.Row.IsNewRow)
            {
                DialogResult dialogResult = MessageBox.Show("Do you want to delete ?", "Delete", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {

                }
                else
                {
                    e.Cancel = true;
                }

            }

Sunday, November 4, 2012

How to change the height of a combobox from designer view?

Change DrawMode property to OwnerDrawVariable, and then change the ItemHeight property. You may need to change IntegralHeight property to false.