Monday, October 18, 2010

Show Line numbers in VIM

To show line numbers in vim while editing document, run the following command :

Press Esc and write

:set number

Saturday, October 16, 2010

Print on the same line, python

sys.stdout.write()

Convert a tuple to String

one_big_string = ''.join( xyz )
print one_big_string

reading from a pickled file, python

import pprint, pickle

pkl_file = open('data.pkl', 'rb')

data1 = pickle.load(pkl_file)
pprint.pprint(data1)

data2 = pickle.load(pkl_file)
pprint.pprint(data2)

pkl_file.close()

How long time does your code take to run in Python ?


def test():
    "Stupid test function"
    L = []
    for i in range(100):
        L.append(i)

if __name__=='__main__':
    from timeit import Timer
    t = Timer("test()", "from __main__ import test")
    print t.timeit()

Monday, October 11, 2010

Can't search through google chrome address bar

If this happens to you, then probably your default search engine is NOT chosen. So all you need to do to click on SettingPreferences, and then Basic, Default search.
The value of default search should be set as Google(or any other search engine you like).

Friday, September 17, 2010

process all the files under a directory & its sub-directories, C#

public void processDir(string sourceDir, string searchForText, string replaceWithText)
        {
            // Process the list of files found in the directory.
            string[] fileEntries = Directory.GetFiles(sourceDir);
            foreach (string fileName in fileEntries)
            {
                // do something with fileName
                Console.WriteLine(fileName);
            }
            // Recurse into subdirectories of this directory.
            string[] subdirEntries = Directory.GetDirectories(sourceDir);
            foreach (string subdir in subdirEntries)
            // Do not iterate through reparse points
            if ((File.GetAttributes(subdir) &
                FileAttributes.ReparsePoint) !=
                FileAttributes.ReparsePoint)
            {
                processDir(subdir, searchForText, replaceWithText);//recursive function
                recursionLvl += 1;
                Console.write ("Changing at deepness level : " + recursionLvl.ToString() + "\n");
            }

using Regular Expressions in C# to find a phrase in a text and replace it with another

This is an example on how to find & replace a phrase in a string, the easy way in C# :

            
            using System.Text.RegularExpressions;
            ....
            if (Regex.IsMatch(content, searchText, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
            {
                display.Text += "Found match in " + filePath +" ***\n";
                content = Regex.Replace(content, searchText, replaceText);
            }

folderBrowserDialog, C#

Example on how to get a path to work on it later on from folderBrowserDialog in C#

          DialogResult result = folderBrowserDialog1.ShowDialog();
            if (result == DialogResult.OK)
            {
                thePath = folderBrowserDialog1.SelectedPath;
                pathLabel.Text = folderBrowserDialog1.SelectedPath;
            }

Find & Replace requested text in all files application

This small C#.Net application finds & replace the requested text with desired text in all files under one folder & sub-folders. This application was made according to needs of some changes at webpages at work.
The application is under development to be stable enough for release ...

Tuesday, September 14, 2010

HOWTO, uneditable text box in C#

If you want a uneditable text box, then ReadOnly properties on the text box should be set as True.

Wednesday, September 08, 2010

Different arrays in C#, Jagged vs. Multi dimensional

Jagged array :
bool[][] myBools = new bool[2][];


Multi dimentional array : 
double[,] myDoubles = new double[2, 2];


One of the differences between jagged arrays and a multi-dimension array is that a multi-dimension array will allocate memory for every element of each dimension, whereas a jagged array will only allocate memory for the size of each array in each dimension that you define. Most of the time, you'll be using multi-dimension arrays, if you need multiple dimensions, and will only use jagged arrays in very special circumstances when you are able to save significant memory by explicitly specifying the sizes of the arrays in each dimension.


Monday, July 19, 2010

Learn Python in 10 minutes !!! It is true :-)

Yes, it is true. I did teach me Python in 10 minutes. Although later I had to come back and search other pages for details but this page really gives you a quick kick-start. Enjoy :-)

http://www.korokithakis.net/tutorials/python

Tuesday, July 06, 2010

How to get Dell Photo 964 to work on Windows 7 64 bit

The R146813(click on the link to download)driver works on Windows 7 64 bit enterprise(Tested by me). Follow the following steps exactly, or it will not work. This is how I got the AIO 964 printer to work in Windows 7 from start to finish.

1. Open device manager and uninstall the printer making sure to tick the "Delete the driver software for the device" box.
2. Unplug the USB cord for the printer.
3. If you have previously tried installing the dell drivers using the setup.exe make sure to uninstall the printer drivers and supporting application. if not disregard this step.
4. Run the clean up patch (R166225.zip)
5. Reboot
6. Right click on the installer and go to the "Compatibility" tab. Check "Run this program in compatibility mode" and choose "Windows Vista" Finally check the "Run as Administrator" option. Click Apply and OK.

7. Install the R146813 drivers plugging in the printer when prompter by the installer.

Your 964 will be working on your Windows 7 64 bit :-)

Wednesday, June 23, 2010

posting from my android :-)

hehe it's cool to blog from HTC desire ...

Published with Blogger-droid v1.3.6

Sunday, June 13, 2010

Trash bin on Ubuntu Desktop

Run Terminal & write the following command to run the Configuration Editor :

  • $ sudo gconf-editor

Then go to apps/nautilus/desktop and select 'trash_icon_visible'.

Sunday, June 06, 2010

Take a snapshot of an area on your Desktop

This command ran in the terminal allows you to select an area on the desktop and have a snapshot of it ... very handy for making guides :-)

  • user@computer:~$ import test.png
After this you will have a file called test.png created on your desktop which contains a snapshot of selected area.