page 4 of 4
<<  prev  1 2 3 4 

How to Bring Up Task Manager During a Remote Desktop Session

August 08, 2007 • 9:38PM • permalink
This was something I'd wondered how to do for a long time. In Windows, all images (or exe files) that are started are created as children of the Winlogin.exe process, which is created when a user first logs in. As a [intentional] consequence of this, Winlogin.exe captures the Ctrl-Alt-Delete control key sequence which can't be overridden by another process.

Sometimes when connecting to another computer over the network, I might need to use Task Manager to suddenly terminate an application in order to free up either memory or reduce network latency from any applications that might have open connections. I'm used to using the Ctrl-Alt-Delete sequence, but since this is always hooked by the Winlogin.exe on the LOCAL computer, Remote Desktop can't transmit it over the connection.

Now that you know why - the solution! The control sequence Ctrl-Alt-End will act the same as a Ctrl-Alt-Delete when used in a Remote Desktop Session.


Repeating a Batch in SQL Server 2005

August 08, 2007 • 4:56PM • permalink
I haven't found this feature documented anywhere, but I picked it up from one of Itzik Ben-Gan's articles.

Normally, you use the keyword GO when you need to force the previous batch of code to immediately execute, such as when using DDL or CTEs, like so:


CREATE TABLE [dbo].[my_table]
(
   id INT
)

GO




While not useful in the case above, you can repeat a batch by placing an integer value immediately after the GO statement. This trick is very helpful when populating a table with random data or when doing repeated testing. So, for example, if we want to fill the above table with 1,000,000 rows of random integers, we can easily do it!



INSERT INTO [dbo].[my_table]
   (id)
VALUES
   (FLOOR(RAND() * 10000))

GO 1000000



.NET Interview Questions - Part 1

August 07, 2007 • 9:52AM • permalink
With MANY open .NET development positions in the Media Department, I've had many opportunities to refine my interview process. Below is a summary of my experience, including some of the general .NET questions we ask most job candidates at Demand Media (and why). Since we are constantly refining the interview process and adding new questions and since this is going to be a rather long entry, I'll split it up into several separate posts.


General Interview Notes


First, a couple of general caveats:

1) I try to give the interviewee the benefit of the doubt. A lot of the time, the people I talk to have more years of experience than I've been alive, so I understand that a lot of them are intimidated by my youth.

2) Look up something about the company on the Internet. Of course nobody has time to redo their entire resume to cater to a specific company, but look up something about the company and try to tune your responses to items that might relate.

3) Most interviews I've been on included the question: "Do you have any questions for me?" That's your cue. Ask any intelligent question without appearing to be a snob, but make sure you ask something (besides your compulsory question about which snacks are kept in which kitchen.) A few stand-by questions I used to use are: "Will I be able to continue my personal education and learn here?", "How quickly do you adapt to new technologies and upgrades to existing technologies?", "What is the team dynamic like?" and "How much room is there for career growth at XXXXXXX Company?"

4) Your resume is your first impression. Use it as a way to highlight your strengths, not as a laundry list of items you "used once in school". There are two main items in particular I see all the time: C++ and .NET 3.5 - usually only by candidates who can't explain ANY intricate features of either.

5) An interview should be a learning process, as well. If you don't understand a question or an answer to a question, ask!

6) TURN OFF YOUR CELL PHONE!!! For many people I've encountered during my career (including me), a cell phone going off during an interview is an instant death sentence. You can start juggling keyboards after that - it's not going to matter...

And now finally...


.NET Questions


1) Describe the difference between a reference type variable and a value type variable?

This is a good question we use to get rid of the riff-raff right away. If you can't form some semblence of an answer to this question, we won't even consider you a candidate for a job.

While we look for many keywords, a simple description of the fact that a value type stores the actual value of the data and the reference type stores an address or pointer to the data usually suffices.

If you don't somehow relate the reference and value types to their storage location on the stack and the heap, that will definitely become question 1b.


2) Describe the process of using an integer variable (of any size) as a bitmap for boolean flags?

This is a process I brought with me to Demand (inherited from Intermix Media, where I propagated the idea as well), but I think it's fairly clear why this is a simple, but vital idea. (Although, I'm assuming below a basic knowledge of binary numbers and bitwise mathematics.)

The idea is that any number can be viewed as a series of bytes and then bits. First I'll describe the process, then I'll demonstrate it in both basic C/C++/C# code and then using .NET additions.

As you should already know, any number can be represented in binary form, which means any number can be represented as a sum of one or more powers of two. We can show this number a number of ways:

123 (decimal) OR

(100 * 1) + (10 * 2) + (1 * 3) OR

(10^2 * 1) + (10^1 * 2) + (10^0 * 3) OR

(64 * 1) + (32 * 1) + (16 * 1) + (8 * 1) * (4 * 0) + (2 * 1) + (1 * 1) OR

(2^6 * 1) + (2^5 * 1) + (2^4 * 1) + (2^3 * 1) * (2^2 * 0) + (2^1 * 1) + (2^0 * 1) OR

1111011 (binary)


If the above binary number is extended to represent a 32-bit int,it would look like:

00000000000000000000000001111011

with the leftmost bit being bit 31 and the rightmost bit being bit 0.

This allows us to see the above as a series of 32 switches or Boolean (True/False) flags that can be accessed (counting from 0 and from the right) by taking a bitwise AND of the number and the "on" value.

As you can see from the above representation, the fourth bit from the right is in the 2^3 position. So, if we take the bitwise AND of our value with 2^3 (8), we get the following:

= 123 & 8
= 8

Since the result (8) is the same as the flag (8), the integer (123) does contain the flag!


When adding flags into your integer, you instead use the bitwise OR. This is always used to switch flags on, so if the flag already exists in your number - it will have no effect, as shown in the following examples:

= 123 | 8
= 123


= 123 | 4
= 127


Finally, to remove a class you take the bitwise AND of the bitwise NOT of the value you're trying to remove. The bitwise NOT inverts the value, so the AND masks any other bits that are currently set, like:

= 127 & (~4)
= 123



The example I usually like to use is to build out the character classes in an RPG-like setting.

Simple C-style Example:


/* CC_ is for Character Class */

int CC_DWARF = 1;
int CC_FIGHTER = 2;
int CC_NINJA = 4;
int CC_SAMURAI = 8;
int CC_ELF = 16;
int CC_MAGICIAN = 32;
int CC_PALADIN = 64;
int CC_HOBBIT = 128;
int CC_PRIEST = 256;
int CC_DARKLORD = 1073741824;


int character_dwarf_fighter = CC_DWARF | CC_FIGHTER;
//value is 3


int character_samurai_elf = CC_SAMURAI | CC_ELF;
//value is 24


int super_crazy_bad_guy = CC_FIGHTER | CC_NINJA | CC_SAMURAI | CC_MAGICIAN | CC_DARKLORD;
//value is 1073741870



//let's remove the CC_DARKLORD class

int super_crazy_bad_guy2 = super_crazy_bad_guy;
super_crazy_bad_guy2 &= ~(CC_DARKLORD);
//value of super_crazy_bad_guy2 is now 46
//OR CC_FIGHTER | CC_NINJA | CC_SAMURAI | CC_MAGICIAN


//let's check super_crazy_bad_guy2 for CC_DARKLORD

if ((super_crazy_bad_guy2 & CC_DARKLORD) == CC_DARKLORD)
   Response.Write("This guy is nothing now!");
//this will print...



//let's check super_crazy_bad_guy2 for CC_DARKLORD

if ((super_crazy_bad_guy2 & CC_PRIEST) == CC_PRIEST)
   Response.Write("This guy is holier than I am!");
//this will NOT print...




Simple .NET/C#-style Example:


[Flags]
public enum CharacterClasses : int
{
   Dwarf = 1,
   Fighter = 2,
   Ninja = 4,
   Samurai = 8,
   Elf = 16,
   Magician = 32,
   Paladin = 64,
   Hobbit = 128,
   Priest = 256,
   DarkLord = 1073741824
};



CharacterClasses super_crazy_bad_guy = CharacterClasses.Fighter | CharacterClasses.Ninja | CharacterClasses.Samurai | CharacterClasses.Magician | CharacterClasses.DarkLord;
Response.Write(super_crazy_bad_guy.ToString());
//prints Fighter, Ninja, Samurai, Magician, DarkLord


super_crazy_bad_guy -= CharacterClasses.DarkLord;
Response.Write(super_crazy_bad_guy.ToString());
//prints Fighter, Ninja, Samurai, Magician


super_crazy_bad_guy |= CharacterClasses.Elf;
Response.Write(super_crazy_bad_guy.ToString());
//prints Fighter, Ninja, Samurai, Elf, Magician


if ((super_crazy_bad_guy &= CharacterClasses.Elf) != 0)
   Response.Write("An elf!");
   
//this will print



if ((super_crazy_bad_guy &= CharacterClasses.Paladin) != 0)
   Response.Write("A paladin!");
   
//this will NOT print





.NET Quickies

* What is the root class that all other .NET classes are derived from?
System.Object

* Name as many ways as you can think of to find a certain character in a string?
String.Contains, "Character Crawl" using any of (for/foreach, String.Chars, String.CharAt, String[], bit masking, plus many others), String.IndexOf, String.LastIndexOf, etc.

* What is a GUID?
Global Unique IDentifier - A 128-bit value that is statistically impossible to be duplicated in a closed environment. (Bonus points if you throw in a note about using it in a multi-server environment by setting the machinekey, generating on the SQL server, using a Key server, etc.)


More to come! Also, if anyone has any suggestions for questions that I should add into my interview process, please send me them!


Welcome to My Blog!

August 06, 2007 • 9:06AM • permalink
AdamWolkov.com has been live for almost two years, but there has never been much content on it. While I didn't have much time to spend on a redesign, I knew that I wanted to include a blog where I could write about my life, my family, my travels, my pets, my projects and anything else that comes to mind. I will also be using this blog as an aggregate by reprinting content that I post on other websites.

You can find more information about my various work and projects in the Me section. You can also find my personal photos on the photo site I keep with my wife, Adrianne (www.thewolkovs.com)

You can also contact me about anything at all. Clients (or companies requesting bids or more information) can use the same form.

So, welcome to my tiny spot on the web. I hope you enjoy!





page 4 of 4
<<  prev  1 2 3 4 


Highest Rated Blog Entries





Tags

optimization expert client-side concurrency network PC API math c sharp help lazy initialization tools T-SQL Generics performance dynamic block Immutable String SQL Server 2000 OS SQL languages hack book review Win32 API anime CosplayWar web development RegEx parsing programming languages bitwise script generation Remote Desktop software Drupal launch SQL Server operator Introduction Regular Expressions AlternativeNicheNetwork SQL Server 2005 books shortcut type Stopwatch Windows Google OOP c plus plus

Links