Friday, April 28, 2017

Checking the memory Leaks of a mac application using alias

alias memoryLeak='function _memoryLeak(){ pgrep "$1" | xargs leaks | grep "total leaked bytes"; };_memoryLeak'

Tuesday, October 9, 2012

Create Dynamic Graphs in Excel

1. Convert each column of data into Table :
  • Select a column then click Insert->Table

2. Define a name for first column.
  • Go to to Formulas->Define Name and then give a name for the Table.
  • For selecting the table just click on the header of the column.
3.Create a Drop-down list for selecting field for the chart
  • Go to Data->Data Validation. In the Allow field select List.
  • While selecting the source press F3 and then select the desired list (Table name given in step 2)
4.Create a row where data will change based on drop-down selection
  • Select a blank row in the sheet for providing data for the chart
  • Type the following formula
            =INDEX(<source data table column 1>,MATCH(<drop-down list cell location>,<source table of the drop-down list>,0));

5.Repeat step 4 for each column.
6.Make a chart and select the data source as this new data row.

Vi Editor shortcuts

dd
delete the line
u
Undo
U
Undo all changes on a line
CTRL+R
Redo
/
Search
n
Search the same phrase again
N
Search in the opposite direction
?
Search in backward direction(use instead of /)
CTRL+O
Go back to where we came from
CTRL+I
Go to newer position
%
Move the cursor to the matching parenthesis
:s/old/new/ge
Replace all occurrences of old with new
ge in above command
Find every occurrence in the whole file, with a prompt whether to substitute or not
CTRL+G
Displays your current location in the file and file status
G
Moves to the end of the file
<number>G
Moves to that line number
gg
Moves to first line
:!<command>
To execute a shell command from within the shell
v
Select line
:r!dir
Reads the output of the command and put it below cursor
y ->
Copies text (y -yank)
p ->
Pastes text (p -paste)
:set xxx

Sets search option xxx where options are:
ic :- ignore case
is  :- incsearch -->show partial search
h|s :- highlight all matching phrases

Saturday, September 15, 2012

Restore windows bootloader without installation disc

  • Download MBRFix from Sysint, and extract the archive.
  • Navigate to the archive through the command line and run the following command, substituting mbrfix with mbrfix64 if you are on a 64-bit system.
          mbrfix /drive 0 fixmbr /yes

For more details see the  MBRFix documentation

Tuesday, September 11, 2012

Implementation of getch() and getche() in Linux

#include <stdio.h>
#include <termios.h>
   
    int getch()
    {
        struct termios initialrsettings, newrsettings;
        char ch[2];
        tcgetattr(fileno(stdin), &initialrsettings);
        newrsettings = initialrsettings;
        newrsettings.c_lflag &= ~ECHO;
        newrsettings.c_lflag &= ~ICANON;
        if(tcsetattr(fileno(stdin), TCSAFLUSH, &newrsettings) != 0)
            fprintf(stderr,"Could not set attributes\n");
        else
        {
        fgets(ch,2,stdin);
        tcsetattr(fileno(stdin), TCSANOW, &initialrsettings);
        return ch[0];
        }
    }
   
    int getche()
    {
        struct termios initialrsettings, newrsettings;
        char ch[2];
    
        tcgetattr(fileno(stdin), &initialrsettings);
        newrsettings = initialrsettings;
        newrsettings.c_lflag &= ~ICANON;
        if(tcsetattr(fileno(stdin), TCSAFLUSH, &newrsettings) != 0)
            fprintf(stderr,"Could not set attributes\n");
        else
        {
        fgets(ch,2,stdin);
        tcsetattr(fileno(stdin), TCSANOW, &initialrsettings);
        return ch[0];
        }
    }