Wednesday, May 27, 2009

UNIX Quick Reference Sheet

1 Log In Session

1.1 Log In

Enter username at login: prompt. Be carefull - Unix is case sensitive.
Enter password at
password: prompt.

1.2 Change Password

passwd

1.3 Log Out

logout or exit

2 File System

2.1 Create a File

cat >  file      Enter text and end with  ctrl-D
vi  file         Edit  file  using the  vi  editor 

2.2 Make a Directory

mkdir   directory-name

2.3 Display File Contents

cat   file    display contents of  file 
more  file    display contents of  file one screenfull at a  time.
view  file    a read only version of vi. 
less  file    similar to, but more powerfull than more. 
              See the man page for more infomation on  less.

2.4 Comparing Files

diff file1 file2   line by comparison
cmp file1 file2    byte by byte comparison

2.5 Changing Access Modes

chmod mode file1 file2 ...
chmod -R  mode dir (changes all files in  dir  )
    Mode Settings
 
 u  user (owner)
 g  group
 o  other
 
 +  add permission
 -  remove permission
 
 r  read
 w  write
 x  execute

Example: chmod go+rwx public.html adds read, write, and execute permissions for group and other on public.html.

2.6 List Files and Directories

ls        list contents of  directory
ls -a     include files with "." (dot files)
ls -l     list contents in long format (show modes)

2.7 Move (or Rename) Files and Directories

mv src-file dest-file    rename src-file to  dest-file
mv src-file dest-dir     move a file into a directory
mv src-dir dest-dir      rename src-dir,  or move to dest-dir
mv -i src dest           copy & prompt before overwriting

2.8 Copy Files

cp src-file dest-file    copy src-file to   dest-file
cp src-file dest-dir     copy a file into a directory
cp -R  src-dir dest-dir   copy one directory into another
cp -i src dest           copy & prompt before overwriting

2.9 Remove File

rm file      remove (delete) a file
rmdir dir    remove an empty directory
rm -r dir    remove a directory and its contents
rm -i file   remove file, but prompt before deleting

2.10 Compressing files

compress file       encode file, replacing it with file.Z
zcat file.Z         display compressed file
uncompress file.Z   decode file.Z, replacing it with file

2.11 Find Name of Current Directory

pwd    display absolute path of working directory

2.12 Pathnames

simple:

One filename or directory name for accessing local file or directory.
Example:
foo.c

absolute:

List of directory names from root directory to desired file or directory name, each separated by /.
Example:
/src/shared

relative:

List of directory names from working directory to desired file or directory name, each separated by /.
Example:
Mail/inbox/23

2.13 Directory Abbreviations

~           Your home (login) directory
~username   Another user's home directory
.           Working (current)  directory
..          Parent of working directory
../..       Parent of parent directory

2.14 Change Working Directory

cd /                           go to the root directory
cd                             go to your login (home) directory
cd ~username                   go to username's login (home) directory
                               not allowed in the Bourne shell
cd ~username/directory         go to username's indicated directory
cd ..                          go up one directory level from here
cd ../..                       go up two directory levels from here
cd /full/path/name/from/root   change directory to absolute path named 
                               note the leading slash
cd path/from/current/directory change directory to path relative to here. 
                               note there is no leading slash

3.0 Commands

3.1 Date

date    display date and time

3.2 Wild Cards

?    single character wild card
*    Arbitrary number of characters

3.3 Printing

lpr file            print file on default printer
lpr -Pprinter file  print file on printer
lpr -c# file        print # copies of file
lpr -d file         interpret file as a dvi file
lpq                 show print queue (-Pprinter also valid)
lprm -#             remove print request # (listed with lpq)

3.4 Redirection

command > file         direct output of command to file instead of
                       to standard output (screen), replacing current 
                       contents of file

command > > file       as above, except output is appended to the current 
                       contents of file

command < file         command receives input from file instead of
                       from standard input (keyboard)

cmd1 | cmd2            "pipe" output of cmd1 to input of cmd2

script file            log everything displayed on the terminal to file; 
                       end with exit

4 Search Files

grep string filelist           show lines containing string in any file 
                               in filelist
grep -v string filelist        show lines not containing string
grep -i string filelist        show lines containing string, ignore case

5 Information on Users

finger user or
finger user@machine    get information on a user
finger @machine        list users on machine
who                    list current users

6 Timesavers

6.1 Aliases

alias string command     abbreviate command to string

6.2 History: Command Repetition

Commands may be recalled

history    show command history
!num       repeat command with history number num
!str       repeat last command beginning with string str
!!         repeat entire last  command line
!$         repeat last word of last command line

7.0 Process and Job Control

7.1 Important Terms

pid            Process IDentification number.  See section 7.2.
job-id  Job identification number. See section 7.2.

7.2 Display Process and/or Job IDs

ps       report processes and pid numbers
ps gx    as above, but include "hidden" processes
jobs     report current jobs and job id numbers

7.3 Stop (Suspend) a Job

ctrl-Z    NOTE:process still exists!

7.4 Run a Job in the Background

To start a job in  background add & to the end of the command. 
Example: xv foo.gif &


To force a running job into the background:

ctrl-Z    stop the job
bg        "push" the job  into the background

7.5 Bring a Job to the Foreground

fg              bring a job to foreground
fg %job-id      foreground by job-id (see 7.2)

7.6 Kill a Process or Job

ctrl-C                 kill foreground process
kill -KILL pid#        see 7.2 for 
kill -KILL %job-id#    displaying  pids & job-ids 

8.0 Mail Handler (MH)

MH commands are issued directly to the terminal.

inc        incorporate new mail
scan       show list of mail  messages
show       show  current message
next       show next message
prev       show previous message
repl       reply to current message
forw       forward current message
comp       compose a mail message
rmm        remove current mail message
cmd -help  print help on mh commmand cmd 

The file .mh_profile is used to enable/disable MH features. man mh-profile for more information.

9.0 On-line Assistance

On-line Documentation

man command-name   display on-line manual pages
man -k  string     list one-line summaries of manual pages containing string

 

Wednesday, May 13, 2009

Unable to find manifest signing certificate in the certificate store.

Unable to find manifest signing certificate in the certificate store.

1.         To solve, I went to the "Signing" tab of the project properties and unchecked "Sign the ClickOnce manifests".

2.         Go to Project -> project Proprietes -> Signin and then go to Create Test Certificate,and just give a simple password.And then enjoy publish it .

Monday, May 11, 2009

Data Flow Diagram Symbols


Data Flow Diagram Symbols

Data Flow Diagrams Symbols

There are some symbols that are used in the drawing of business process diagrams (data flow diagrams). These are now explained, together with the rules that apply to them. Flow diagrams in general are usually designed using simple symbols such as a rectangle, an oval or a circle depicting a processes, data stored or an external entity, and arrows are generally used to depict the data flow from one step to another. A DFD usually comprises of four components. These four components can be represented by four simple symbols. These symbols can be explained in detail as follows: External entities (source/destination of data) are represented by squares; Processes (input-processing-output) are represented by rectangles with rounded corners; Data Flows (physical or electronic data) are represented by arrows; and finally, Data Stores (physical or electronic like XML files) are represented by open-ended rectangles.


External Entity

An external entity is a source or destination of a data flow which is outside the area of study. Only those entities which originate or receive data are represented on a business process diagram. The symbol used is an oval containing a meaningful and unique identifier.

Process

A process shows a transformation or manipulation of data flows within the system. The symbol used is a rectangular box which contains 3 descriptive elements:

Firstly an identification number appears in the upper left hand corner. This is allocated arbitrarily at the top level and serves as a unique reference.

Secondly, a location appears to the right of the identifier and describes where in the system the process takes place. This may, for example, be a department or a piece of hardware. Finally, a descriptive title is placed in the centre of the box. This should be a simple imperative sentence with a specific verb, for example 'maintain customer records' or 'find driver'.

Data Flow

A data flow shows the flow of information from its source to its destination. A data flow is represented by a line, with arrowheads showing the direction of flow. Information always flows to or from a process and may be written, verbal or electronic. Each data flow may be referenced by the processes or data stores at its head and tail, or by a description of its contents.

Data Store

A data store is a holding place for information within the system:

It is represented by an open ended narrow rectangle. Data stores may be long-term files such as sales ledgers, or may be short-term accumulations: for example batches of documents that are waiting to be processed. Each data store should be given a reference followed by an arbitrary number.

Resource Flow

A resource flow shows the flow of any physical material from its source to its destination. For this reason they are sometimes referred to as physical flows.

The physical material in question should be given a meaningful name. Resource flows are usually restricted to early, high-level diagrams and are used when a description of the physical flow of materials is considered to be important to help the analysis.

Data Flow Diagrams - The Rules

External Entities

It is normal for all the information represented within a system to have been obtained from, and/or to be passed onto, an external source or recipient. These external entities may be duplicated on a diagram, to avoid crossing data flow lines. Where they are duplicated a stripe is drawn across the left hand corner, like this.

The addition of a lowercase letter to each entity on the diagram is a good way to uniquely identify them.

Processes

When naming processes, avoid glossing over them, without really understanding their role. Indications that this has been done are the use of vague terms in the descriptive title area - like 'process' or 'update'.

The most important thing to remember is that the description must be meaningful to whoever will be using the diagram.

Data Flows

Double headed arrows can be used (to show two-way flows) on all but bottom level diagrams. Furthermore, in common with most of the other symbols used, a data flow at a particular level of a diagram may be decomposed to multiple data flows at lower levels.

Data Stores

Each store should be given a reference letter, followed by an arbitrary number. These reference letters are allocated as follows:

'D' - indicates a permanent computer file
'M' - indicates a manual file
'T' - indicates a transient store, one that is deleted after processing.

In order to avoid complex flows, the same data store may be drawn several times on a diagram. Multiple instances of the same data store are indicated by a double vertical bar on their left hand edge.

Relative Data Flow Diagram Resource

Data Flow Diagram Software

UML Diagram Software

Code Composer Studio Tutorial



Code Composer Studio Tutorial

Module by: Deania Fernandez

Summary: A brief tutorial on how to get started using Code Composer Studio.

Introduction

This is a brief tutorial over Code Composer Studio which is a programming environment used to implement various algorithms and load code onto a DSP. If you would like a more in-depth tutorial, please feel free to click on Help -->Tutorial in Code Composer.

Starting Code Composer Studio

Before starting, it would be a good idea to create a folder where you will be saving your project files. Label the folder ELEC424_Tutorial.

To open Code Composer Studio in a Windows 2000 system, click on Start and select Programs --> Texas Instruments --> Code Composer Studio DSK Tools 2 ('C2000) --> Code Composer Studio.

Figure 1
Figure 1 (SelectingCodeComposer.jpg)

You should see the following screen:

Figure 2
Figure 2 (CodeComposerWorkEnvironment.jpg)

Creating a File

To create a new source code file, click on File --> Source File. A window titled 'Untitled1' will appear within the Composer environment:

Figure 3
Figure 3 (CreatingANewFile.jpg)

You can double-click on the 'Untitled1' window to make it larger.

To save your file, click on File --> Save. The following prompt will appear:

Figure 4
Figure 4 (SavingAFilePrompt.jpg)

There are several Save as type… options. Choose the appropriate one for your code. It will give your file the proper file extension. It is also lets the linker know when you compile your code what kind of language the file is written in.

When you are done, click Save.

Creating a New Project

After you have finished creating the files you need to run on the DSP, you will now want to create a project that will include all the files. Select Project --> New…

The following prompt will appear:

Figure 5
Figure 5 (ProjectCreationDialog.jpg)

Fill in the project name in Project Name. Browse to the folder you created for the project in Location. Make sure you select Executable (.out) in Project Type, and select TMS320C28XX in Target. When you are done, click Finish.

Example.pjt will appear in the left-hand side of the Composer environment. Click on the '+' to expand the project:

Figure 6
(a) Before expanding project (b) After expanding project
Figure 6(a) (BeforeExpandingProject.jpg) Figure 6(b) (AfterExpandingProject.jpg)

Adding New Files to the Project

In order to add new files, select Project --> Add Files to Project… The following prompt will appear:

Figure 7
Figure 7 (AddingFilesPrompt.jpg)

Select the file you want to add. To make it easier, you can narrow your search of a particular file by choosing which type of file you want in the Files of type…

When you are done, click Open.

You should now see the file after clicking on the '+' in the left-hand window:

Figure 8
Figure 8 (ExpandingSource.jpg)

Compiling Files and Building Projects

Once you have added all the files you want to be included in your project, you will now need to build your project. Select Project --> Rebuild All. You should see the following window at the bottom of the Code Composer Studio Environment:

Figure 9
Figure 9 (AfterCompilingWindow.jpg)

If there are errors in your code, they will be listed with the corresponding line numbers. Correct them and rebuild your project.

Loading/Reloading Programs

After your code has been successfully compiled and built, you must now load your program onto the DSP. Select File --> Load Program… You will see the following prompt dialog:

Figure 10
Figure 10 (LoadProgramPrompt.jpg)

When you rebuild your project, Code Composer Studio is set at default to create a new folder in your directory called Debug. This is where the executable file is created. Double-click on the Debug folder and you should see your *.out file:

Figure 11
Figure 11 (SelectingOutFilePrompt.jpg)

After you select your file, click Open.

Executing, Halting, or Stopping Your Program

To execute your program, select Debug --> Run or press the F5 key:

Figure 12
Figure 12 (SelectingDebugRun.jpg)

Your program will then begin to run. You will see the following at the bottom left-hand corner of the Code Composer Studio environment:

Figure 13
Figure 13 (CPURunning.jpg)

To stop running your code, select Debug --> Halt:

Figure 14
Figure 14 (SelectingHaltCPU.jpg)

You should then see the following at the bottom left-hand corner of the work environment:

Figure 15
Figure 15 (CPUHalted.jpg)

To resume running your code, press the F5 button.

Debugging Your Code

Since there are few of us that can get our code working right the first time, you will probably have to debug your code. To figure out what could be wrong, there are several methods you can use to break the problem down.

Setting Breakpoints

To execute your code a little at a time or to stop it after a certain point, you can place breakpoints. You can do this by placing the cursor on the line you want to set the breakpoint on, highlighting it by clicking once, and double-click. You should see a solid red circle on the left:

Figure 16
Figure 16 (SettingBreakpoint.jpg)

You can set as many as you like. Rebuild and reload the program. Execute it. The DSP will stop at the first breakpoint. To get to the next breakpoint, press the F5 button to run the DSP again.

To remove the breakpoint(s), place the cursor on the line, highlight it by clicking once, and double-click. The solid red circle should disappear:

Figure 17
Figure 17 (RemovingBreakpoint.jpg)

Watching Variables

To see what values your variables, constants, and/or registers are getting, you can view them in a watch window. Select View --> Watch Window. You should see the following appear in the Code Composer Studio environment:

Figure 18
Figure 18 (WatchWindows.jpg)

Click on the 'Watch 1' tab:

Figure 19
Figure 19 (ClickOnWatchWindow.jpg)

To add a variable, double-click on the row under the 'Name' column:

Figure 20
Figure 20 (SettingAWatchVariable.jpg)

Type in the name of the variable and press the Enter key:

Figure 21
Figure 21 (EnteringAWatchVariable.jpg)

You can change the base of the value by clicking on the 'Radix' column and selecting how you want to view the value.

Figure 22
Figure 22 (ChangingBaseInWatchWindow.jpg)

Profiling Sessions

You can benchmark your code by profiling a session. To do this, you can set one breakpoint at the line where you want the counter to start counting and another breakpoint at where to stop.

Select Profiler --> Start New Session… You will see the following dialog:

Figure 23
Figure 23 (ProfileSesionNameDialog.jpg)

Type in a name for your profile session and click OK.

A window will appear at the bottom:

Figure 24
Figure 24 (ProfileWindow.jpg)

To profile a function, you need to add it to the profile session you just created. Double-click on the file you want to do this in, and place the cursor on any line inside the function and right click. Choose Profile Function --> in (session-name) Session.

Execute the code. When the CPU stops, click on the 'Functions' tab to see the result of the profiling.

Counting Clock Cycles

If you just want to count the cycles and do not need all the stats from profiling, you can just view the clock. SelectProfiler --> View Clock:

Figure 25
Figure 25 (SelectingViewClock.jpg)

The following window should appear at the bottom:

Figure 26
Figure 26 (ClockWindow.jpg)

After setting up your breakpoints, reset the PC to start at the beginning of your code by selecting Debug --> Reset. Run your code. Clear the clock by double-clicking on it, and then run it again. The number of clock cycles will appear in the clock window.

Troubleshooting

If you are having any trouble, sometimes it is best to reset the CPU. You can do this by selecting Debug --> Restart CPU. You will have to reload the program.

Another option is to simply quit Code Composer Studio by selecting File --> Quit and restart the application.

Saturday, May 9, 2009

JavaScript : Open Window in Same location

To open a URL in same window use as below.

 window.location.href=theUrl;  

Java Script : Open Window


To open a new window, you will need to use yet another ready-made JavaScript function. Here is what it looks like:

window.open('url to open','window name','attribute1,attribute2')

This is the function that allows you to open a new browser window for the viewer to use. Note that all the names and attributes are separated with a comma rather than spaces. Here is what all the stuff inside is:

  1. 'url to open'
    This is the web address of the page you wish to appear in the new window.

  2. 'window name'
    You can name your window whatever you like, in case you need to make a reference to the window later.

  3. 'attribute1,attribute2'
    As with alot of other things, you have a choice of attributes you can adjust.

Window Attributes

Below is a list of the attributes you can use:

  1. width=300
    Use this to define the width of the new window.

  2. height=200
    Use this to define the height of the new window.

  3. resizable=yes or no
    Use this to control whether or not you want the user to be able to resize the window.

  4. scrollbars=yes or no
    This lets you decide whether or not to have scrollbars on the window.

  5. toolbar=yes or no
    Whether or not the new window should have the browser navigation bar at the top (The back, foward, stop buttons..etc.).

  6. location=yes or no
    Whether or not you wish to show the location box with the current url (The place to type http://address).

  7. directories=yes or no
    Whether or not the window should show the extra buttons. (what's cool, personal buttons, etc...).

  8. status=yes or no
    Whether or not to show the window status bar at the bottom of the window.

  9. menubar=yes or no
    Whether or not to show the menus at the top of the window (File, Edit, etc...).

  10. copyhistory=yes or no
    Whether or not to copy the old browser window's history list to the new window.

Friday, May 8, 2009

Learn how to write a Regular Expression:


Learn how to write a Regular Expression:
---------------------------------------------------------------

What Regular Expression?
A regular expression is a pattern that can match various text strings, used for validations.

Where and when to use Regular Expression?
It can be used in the programming languages which supports or has regular expression class as in built or it supports third party regular expression libraries.

Regular expressions can be used to valid different type of data without increase the code with if and case conditions. A number of if conditions can be omitted with single line of regular expression checking.

Benefits of Regular Expression:
The following are benefits (not all included) of use of Regular Expression.
a) # line of code can be reduced.
b) Speed Coding.
c) Easy maintenance (you don’t need to change if validation criteria changes, just check the regular expression string).
d) Easy to understand (you don’t need to understand the programmer logic on large if statements and case statements).

Elements of Regular Expression:
Here are the basic elements of regular expression characters/literals, which can be used to build big regular expressions:

^ ---->Start of a string.
$ ---->End of a string.
. ----> Any character (except \n newline)
{...}----> Explicit quantifier notation.
[...] ---->Explicit set of characters to match.
(...) ---->Logical grouping of part of an expression.
* ---->0 or more of previous expression.
+ ---->1 or more of previous expression.
? ---->0 or 1 of previous expression; also forces minimal matching when an expression might match several strings within a search string.
\ ---->Preceding one of the above, it makes it a literal instead of a special character. Preceding a special matching character, see below.
\w ----> matches any word character, equivalent to [a-zA-Z0-9]
\W ----> matches any non word character, equivalent to [^a-zA-Z0-9].
\s ----> matches any white space character, equivalent to [\f\n\r\v]
\S----> matches any non-white space characters, equivalent to [^\f\n\r\v]
\d ----> matches any decimal digits, equivalent to [0-9]
\D----> matches any non-digit characters, equivalent to [^0-9]

\a ----> Matches a bell (alarm) \u0007.
\b ----> Matches a backspace \u0008 if in a [] character class; otherwise, see the note following this table.
\t ---->Matches a tab \u0009.
\r ---->Matches a carriage return \u000D.
\v ---->Matches a vertical tab \u000B.
\f ---->Matches a form feed \u000C.
\n ---->Matches a new line \u000A.
\e ---->Matches an escape \u001B

$number ----> Substitutes the last substring matched by group number number (decimal).
${name} ----> Substitutes the last substring matched by a (? ) group.
$$ ----> Substitutes a single "$" literal.
$& ----> Substitutes a copy of the entire match itself.
$` ----> Substitutes all the text of the input string before the match.
$' ----> Substitutes all the text of the input string after the match.
$+ ----> Substitutes the last group captured.
$_ ----> Substitutes the entire input string.

(?(expression)yes|no) ----> Matches yes part if expression matches and no part will be ommited.


Simple Example:
Let us start with small example, taking integer values:
When we are talking about integer, it always has fixed series, i.e. 0 to 9 and we will use the same to write this regular expression in steps.

a) Regular expression starts with “^”
b) As we are using set of characters to be validated, we can use [].
c) So the expression will become “^[1234567890]”
d) As the series is continues we can go for “-“ which gives us to reduce the length of the expression. It becomes “^[0-9]”
e) This will work only for one digit and to make it to work for n number of digits, we can use “*”, now expression becomes “^[0-9]*”
f) As with the starting ending of the expression should be done with “$”, so the final expression becomes “^[0-9]*$”

Note: Double quotes are not part of expression; I used it just to differentiate between the sentences.

Is this the way you need to write:
This is one of the way you can write regular expression and depending on the requirements and personal expertise, regular expression could be compressed much shorter, for example above regular expression could be reduced as.

a) Regular expression starts with “^”
b) As we are checking for the digits, there is a special character to check for digits “\d”
c) And digits can follow digits , we use “*”
d) As expression ends with “$”, the final regular expression will become
"^\d*$”

Digits can be validated with different ways of regular expressions:

1) ^[1234567890]*$
2) ^[0-9]*$
3) ^\d*$

Which one to choose?
Every one of above expressions will work in the same way, choose the way you are comfort, it is always recommended to have a smaller and self expressive and understandable, as these will effect when you write big regular expression.

Example on exclude options:
There are many situation which demands us to exclude only certain portion or certain characters,
Eg: a) Take all alpha numeric and special symbols except “&”
b) Take all digits except “7”
then we cannot prepare a big list which includes all instead we use the symbol of all and exclude the characters / symbols which need to be validated.
Eg: “^\w[^&]*$” is the solution to take all alpha numeric and special symbols except “&”.

Other Examples:
a) There should not be “1” as first digit,?
^[^1]\d*$ ? this will exclude 1 as first digit.

b) There should not be “1” at any place?
^\d[^1]*$ ? this will exclude the 1 at any place in the sequence.

Note: Here ^ operator is used not only to start the string but also used to negate the values.

Testing of Regular expression:
There are several ways of testing this
a) You can write a windows based program.
b) You can write a web based application.
c) You can even write a service based application.


Windows base sample code:
Here are steps which will be used for regular expression checking in dotNet:

a) Use System.Text.RegularExpression.Regex to include the Regex class.
b) Create an Regex object as follows:
Regex regDollar= new System.Text.RegularExpressions.Regex("^[0-9]*$ ");
c) Call the IsMatch(string object) of the Regex call, which will return true or flase.
d) Depending on the return state you can decide whether passed string is valid for regular expression or not.]

Here is the snap shot code as function:

Public boolean IsValid(string regexpObj, string passedString)
{
//This method is direct method without any exceptional throwing..
Regex regDollar= new System.Text.RegularExpressions.Regex(regexpObj);
return regDollar.IsMatch(passedString);
}
With minor changes to the above function it can be used in windows or webbased or even as a service.

Another way -- Online checking:
At last if you are fed up with above and you have internet connection and you don’t have time to write sample, use the following link to test online

http://www.regexplib.com/RETester.aspx

 

Creating Threads in C#

Creating Threads


Creating a thread in C# is close to trivial, but not quite. The only non-trivial thing about
creating a thread is dotNet delegate-classes. Let me explain in few words what is a
delegate class. The delegate is a wrapper around a code construct in the dotNet. The code
construct could be an object instance, an instance method or a static method. Delegates
are used when you want to pass one of the three code constructs as a parameter to
another method.
When creating a new thread you have to use the ThreadStart delegate class to wrap the
instance method that will be executed in the newly created thread. The instance method
must return void and must not have any parameters.


void ThreadStart()
To create a new thread, first create a new ThreadStart object, passing the instance method
of the thread procedure in the constructor. The new delegate object is then passed to the
constructor of the Thread.


Thread thread = new Thread(
new ThreadStart(obj.ThreadStart));


You’ve now created a new thread, but the thread is not yet started. To start the thread,
you call the Thread.Start instance method.
thread.Start();

 

using System;

using System.Threading;

namespace ConsoleApplication1

{

    class Class1

    {

        static void PrintHelloFromThreadName()

        {

            Console.WriteLine("Hello, from thread {0}",

            Thread.CurrentThread.Name); // {0}

        }

        public void ThreadStart()

        {

         PrintHelloFromThreadName();

        }

 

        static void Main(string[] args)

        {

            Thread.CurrentThread.Name = "Main thread";

            Class1 obj = new Class1();

            Thread thread = new Thread(

            new ThreadStart(obj.ThreadStart));

            thread.Name = "Forked thread";

            thread.Start();

            PrintHelloFromThreadName();

        }

     }

 }


A nice feature of dotNet threads, and for that matter any dotNet object, is the ability name
the object. If you name your threads, then the debugger will pick up those names and
you’ll have a much easier time debugging

 

 

 

C# - Get Basic knowledge from this video

Regular Expression for non standard characters

When parsing large text files. Some of them have non standard characters.

We just want to parse a file and replace anything that is not found on a keyboard.

Use this Regular Expression for above problem

Regex rx = new Regex("[^\x20-\x7E]");


Difference between Cluster and Non-cluster index?

Difference between Cluster and Non-cluster index?

Clustered index - the index order matches the order of physically stored data.

Cluster index can be used on table that doesn’t get changes frequently.

Using DML statements on cluster index column have performance issues since it has to update the index each and every time a DML gets executed.

Cluster advantageous in searching a range of values.
Non-cluster - index order doesn’t match with the physical stored order.

There can be only 1 Clustered index in a table.

whereas non clustered index can be up to 249 .

Overall to say:

The difference is that Clustered index is unique for any given table and we can have only one clustered index on a table. The leaf level of a clustered index is the actual data and the data is resorted in case of clustered index. Whereas in case of non-clustered index the leaf level is actually a pointer to the data in rows so we can have as many non-clustered indexes as we can on the db.

Oracle Script to extract data from a table to a file - Putty | UNIX .

Oracle Script to extract data from a table to a file in Putty .

Save below script in to a file let me name it as extract.sql .

Latter follow below steps to run above file.

Sqlplus username/password@databaseName

You will login in to this database and just use below syntax to run it.

@extract.sql

Depending on the data whatever size it may be it will be saved in to the file (given in the file)

SCRIPT:

set head off verify off termout off echo off feedback off pagesize 0 linesize 30000 trimspool on

set colsep |

define fname=filename.log

spool &fname

select 'Custname||'|'||Custaddress||'|'||Custaddress2||'|'||Custsubmittedname||'|'||Custsubmittedaddress1||'|'||Custsubmittedaddress2||'|'||Custaddress_error' from dual;

select Custname||'|'||Custaddress||'|'||Custaddress2||'|'||Custsubmittedname||'|'||Custsubmittedaddress1||'|'||Custsubmittedaddress2||'|'||Custaddress_error from CustomerAddressTable

spool off

How to UNLOCK a table in MS SQL ?

Follow this steps to UNLOCK the sql table which has been LOCKED  by some other process/script.



 1.  sp_lock      --Run this  
 2.  sp_who2     --Run this  
 3.  Look for Status column and the DBName column.  
 4.  Get the session Id from SPID.  
 5.  Kill <SPID>    --Run this  

Code Formater

Paste Here Your Source Code
Source Code Formatting Options
1) Convert Tab into Space :
2) Need Line Code Numbering :
3) Remove blank lines :
4) Embeded styles / Stylesheet :
5) Code Block Width :
6) Code Block Height :
7) Alternative Background :
Copy Formatted Source Code
 
Preview Of Formatted Code