Sunday, April 30, 2006

Split in SQL

Split list of numbers ('1, 2, 3, 4, 67, 87') to table.

Input: : List of numbers (0;1;5;45;...)

Ouput:

0 1545...

A using: SELECT * FROM Split('0;1;5;45;',';')

CREATE FUNCTION Split
(

@list varchar(8000), -- List of integer with any delemiter

@delimiter CHAR(1) -- Delimetr

)
RETURNS
@list_int TABLE (item int) --list of integer

AS
   BEGIN
  DECLARE @position int, @itemvarchar(20)

   WHILE @list <> ''
   BEGIN
     SET @position = CHARINDEX(@delimiter, @list)
     IF @position = 0
     SET @position = LEN(@list) + 1

     SET @item=LEFT(@list, @position - 1)
     INSERT INTO @list_int VALUES(CAST(@itemAS int))
     SET @list = STUFF(@list, 1, @position, '')
    END
RETURN
END

Use of conditional attributes in .NET

Attribute Conditional serves for creation of conditional methods, i.e. methods which are carried out only when the parameter of attribute is the symbolical constant certain by the instruction *define or is registered in properties the project.
Simple example. A conclusion of the message about trial version and about the registered version depending on attribute.

Open new Console Project.

Add a reference
using System.Diagnostics;

Add 2 methods to class:
[Conditional ("TRIAL")]
public static void Remind()
{
  Console.WriteLine("Please register your version!" );
  Console.ReadLine();
}
and

[Conditional ("FINAL")]

public static void Hello()

{
  Console.WriteLine("Thanks for registration!");
  Console.ReadLine();
}

Add to project properties -> Build -> Conditional compilation constants :

DEBUG;TRACE; TRIAL "COLOR: #ff0000">or DEBUG;TRACE; FINAL
Compile and Run.

Tuesday, April 25, 2006

Google advanced operators

Target/Task

links

Uses operators

What Google site writes about blog?

site:google.com inanchor:blog

site: inanchor:

Find car BMW in UK

Results from all word: BMW

Result from UK and other link:

BMW UK

Results from UK only:

inurl:co.uk intitle:BMW

Inurl:

Find info about bugs

Any bugs: Bugs

Any bugs except of computer bugs: Bugs -computer

Exclusion

Understand the DOT.NET dataset class structure

dataset

Google images

What Blog is?

Define: blog

define

Find info about mobile/cellular phones

Intitle: phones intitle:~mobile

Synonyms(~)

Find PowerPoint presentation about cars/auto

~car filetype:ppt

Synonyms(~), filetype

Find any installation guide in flash

"installation guide" filetype:swf

Exact match(""), filetype

Find middle Vladimir Putin name

"Vladimir * Putin"

Asteric(*)

Effect of incomming links

Click here (Adobe, XE, Macromedia)


List of operators:

Intitle,allintitle


Inurl, allinurl


Filetype


Allintext


Site


Link


Inanchor


Daterange


Cache


Info


Related


Phonebook


Rphonebook


Bphonebook


Author


Group


define


Msgid


Insubject


Stocks


Sunday, April 23, 2006

Exact measurement of performance in Dot.Net

Utils.PerfMeter - unpretentious class for exact gauging performance in Dot.Net.
Measures much more precisely than Environment.TickCount. Environment.TickCount has accuracy 10 milisecond,
that for measurement of short sites does not approach.
Use QueryPerformanceCounter allows to provide very high accuracy.
To use so:
//Define variable
PerfMeter timer = new PerfMeter();

timer.Start();

// A code for test.......

//Print result to console
Console.WriteLine("Execution time in seconds: {0:### ### ##0.0000}"
timer.End());

//You can to use one variable several times

Class code:
using System;
using System.Runtime.InteropServices;

namespace Utils
{

/*This structure allows to count up speed of performance of a code one of the most exact of ways. Actually calculations are made in steps of the processor, and then translated in miliseconds (the decimal part is shares of second).
*/

  public struct PerfMeter
  {
  Int64 _start;

  /// Start timer
  public void Start()
  {
  _start = 0;
  QueryPerformanceCounter(ref _start);
  }
  /// Finished calculation time executions and returns time in seconds.

  /*Return: Time in seconds spent for performance of a site of a code. The   decimal part reflects shares of second */
  public float End()
  {
  Int64 end = 0;
  QueryPerformanceCounter(ref end);

  Int64 frequency = 0;
  QueryPerformanceFrequency(ref Frequency);
  return (((float)(end - _start) /(float)freq));
  }

  [DllImport("Kernel32.dll")]
  static extern bool QueryPerformanceCounter(ref Int64 performanceCount);

  [DllImport("Kernel32.dll")]
  static extern bool QueryPerformanceFrequency(ref Int64 frequency);
  }
}

BIOS error signals

During inclusion of a computer the sound signal is always audible, but sometimes it is more, than a lonely signal. You what is it? Ask, and the answer will be not pleasant - there was a problem with hardware. This signal publishes BIOS, and values of signals are resulted in tables below:

AMI

Signals

Problem


- *

Power Supply is out of order

2 short

Clock memory error

3 short

Error in first 64kb of memory

4 short

System timer error

5 short

CPU is out of order

6 short

Keyboard controller is out of order

7 short

Motherboard is out of order

8 short

VGA card is out of order

9 short

Test BIOS error

10 short

Can not write to CMOS

11 short

Motherboard cache memory is out of order

1 long + 2 short

VGA card is out of order

1 long + 3 short

Same

1 long + 8 short

The monitor is not connected.


AWARD

Signals

Problem


2 short

little errors**

3 short

Keyboard conroller error

1 long +1 short

Memory error

1 long + 2 short

VGA card is out of order

1 long + 3 short

Keyboard initialization  error

1 long + 9 short

Read error from ROM

short, recurrent

Power Suplly is out of order

long, recurrent

Memory problem

continual

Power Suplly is out of order


* - a absence of any signal.


** - Problem in CMOS Setup or motherboard.

Hello, Word

Today I open the blog. I shall publish to become connected with development & computers. Examples of code, tools and other items. Problems of OS, illumination and comparison of new hardware, and also tips and tricks devoted to a computer.