This page contains useful free cryptographic software code that David Ireland has written or adapted in Visual Basic and ANSI C. It's updated frequently, so keep checking.
Ramblings of a Software Engineer, Amusements of a Geek, Cacophony of a Guitarist, An Entropy Admirer's and an Interesting Character's Musings..
Thursday, 27 November 2008
Wednesday, 26 November 2008
Tools for everyday development
1. Process Explorer
2. Debug View
- Win32 OutputDebugString
- Kernel-mode DbgPrint
- All kernel-mode variants of DbgPrint implemented in Windows XP and Server 2003
- Works with C#, VB.Net languages. Supports all project types that ships with Visual Studio 2005 including web sites and web application projects.
- A preview window to show changes.
- Finds other instances of the text being replaced in the project automatically.
- Lists existing resources by their similarity level to the text being replaced.
- Automatically replaces hard coded string with a reference to resource entry.
FxCop
The Visual Studio Code Analysis Team Blog
StyleCop
Introducing StyleCop on legacy projects
Ghost Doc
Resource Refactor
Thursday, 20 November 2008
Unit Testing Silverlight Apps
Inarguably SL2 applications are a whole new experience of developing cross platform applications from managed code environments.
Unit Testing becomes very vital while developing for cross browser enterprise class applications. Visual Studio's tight integration of the Unit Testing framework is such an invaluable tool in the code production pipeline. Now, with the release of a unit testing framework for SL2 applications, the same experience can be leveraged. SL2 applications can be developed in a test driven fashion now. It perfectly suits an agile team. A team which is constantly driven by change and is delivering on a constant basis, almost every day in some cases. Much like a team which does not have a release model. (Check out Jeff Wilcox's blog). I guess the Silverlight test framework was itself developed using an agile methodology.
The SL Unit testing framework has proved to be an invaluable tool personally for me. It allows me to test SL applications on 3 different browsers (cheap guess if you are thinking which browsers ) even though i target IE mainly. :P. I'll write about it with a test application soon in my next blog. Till then, check out these links..
Some Links:
Silverlight Toolkit - You can find components like dockpanel, treeview etc for SL 2, themes and of course the source code for controls with unit tests and the unit test framework itself.
Jeff Wilcox - The guy who develops actively on the SL unit test framework at MS.
Scott Gu's small demo program on SL unit testing - (If you don't know this man, you are not worth living, jump off a building NOW!)
MS Silverlight Unit Test Framework - MS unit test framework for SL 2.
Wednesday, 19 November 2008
A Simple Multi-threaded Logger
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;
using System.IO;
namespace SudhirMurthy.Logger {
public interface ILog {
void LogToDisk(string msg);
}
interface ILoggerService {
ILog ILog {
get;
}
}
public class LogFile : ILog {
static List<string> messages;
//WriteToDisk delegate
private delegate void WriteToDisk(object sender, string fileName);
//WriteToDisk event
private static event WriteToDisk writeToDisk;
public static void WriteLog(string fileName) {
//Raise the event
writeToDisk(new object(), (fileName));
}
public void SendToDisk(object sender, string fileName) {
StreamWriter sw = File.CreateText(fileName);
foreach (string s in messages) {
sw.WriteLine(s);
}
sw.Close();
}
public LogFile() {
messages = new List<string>();
WriteToDisk mydelegate = new WriteToDisk(SendToDisk);
writeToDisk = new WriteToDisk(SendToDisk);
}
public List<string> Messages {
get {
return messages;
}
}
#region ILog Members
public void LogToDisk(string msg) {
Monitor.Enter(this);
messages.Add(msg);
Monitor.Exit(this);
}
#endregion
}
public class LoggerService : ILoggerService {
//TODO: Need to make it threadsafe..
private static ILog logInstance = null;
public LoggerService() {
logInstance = new LogFile();
}
#region ILoggerService Members
public ILog ILog {
get {
return logInstance;
}
}
#endregion
}
public class LoggerClient1 {
LoggerService logService;
public LoggerClient1() {
logService = new LoggerService();
}
public void Log() {
logService.ILog.LogToDisk(string.Format(
"I am Logging: {0}", this.ToString()));
}
}
public class LoggerClient2 {
LoggerService logService;
public LoggerClient2() {
logService = new LoggerService();
}
public void Log() {
logService.ILog.LogToDisk(string.Format(
"I am Logging: {0}", this.ToString()));
}
}
public class TestApp {
LoggerClient1 a;
LoggerClient2 b;
public TestApp() {
a = new LoggerClient1();
b = new LoggerClient2();
}
public void logClient1() {
for (int i = 0; i < 1000000; i++) {
a.Log();
}
}
public void logClient2() {
for (int i = 0; i < 1000000; i++) {
b.Log();
}
}
}
class Program {
static void Main(string[] args) {
TestApp app = new TestApp();
Thread t1 = new Thread(new ThreadStart(app.logClient1));
Thread t2 = new Thread(new ThreadStart(app.logClient2));
try {
t1.Start();
t2.Start();
} catch (Exception) {
throw;
}
t1.Join();
t2.Join();
//The main thread should technically wait until
//t1 and t2 should have finished and then execute
//the following
LogFile.WriteLog("log.txt");
}
}
}
If you try removing the Monitor.Enter(this) and Monitor.Exit(this) lines from the above code, you end up getting weird line numbers in your log.txt file. (enable line no's in visual studio and see log.txt). i.e the count of the log will never be as expected (2 million in the above case). By putting the above lines back, you get the expected value which is 2million lines of log. :). It takes about 5-6 seconds on my dual core for threads t1 and t2 to finish logging and the main thread to write to disk. :). A bloated 93.4 MB file!!
My thread on MSDN Forums.
Saturday, 15 November 2008
Tricolor on the moon!!
The probe, painted with the Indian flag, touched down at 2034 (1504 GMT) Friday the 14th of November 2008, the Indian Space Research Organisation (ISRO) said.
India has become the fourth nation to join the stuff-on-the-Moon club, after the Chandrayaan-1 spacecraft in lunar orbit successfully launched an impact probe at the lunar surface. The 35-kg impactor was blazoned with the Indian flag.
Mission Objectives
Carry out high resolution mapping of topographic features in 3D, distribution of various minerals and elemental chemical species including radioactive nuclides covering the entire lunar surface using a set of remote sensing payloads. The new set of data would help in unravelling mysteries about the origin and evolution of solar system in general and that of the moon in particular.
Realize the mission goal of harnessing the science payloads, lunar craft and the launch vehicle with suitable ground support system including DSN station, integration and testing, launching and achieving lunar orbit of ~100 km, in-orbit operation of experiments, communication/telecommand, telemetry data reception, quick look data and archival for scientific utilization by identified group of scientists.
Chandrayaan-1 spacecraft undergoing pre-launch tests
Moon Impact Probe
PSLV 11 Assembled and ready to go at sriharikota.
PSLV-C11 at Vehicle Assembly Building
INDIA SHOOTS TO THE MOON!. Photo of PSLV-C11 liftoff launching the Chandrayaan-1. 22 Oct 2008
MERA BHARAT MAHAAAAN! JAI HIND!
Tuesday, 11 November 2008
XHTML - A very simple primer.
XHTML is a reformulation of HTML in XML. XML is mainly made up of generic tags which can be used to define data. XHTML is derived from XML or putting it the other way, XML is the base for XHTML. XHTML is also very similar to HTML 4.1.
According to W3Schools,
“XHTML is a combination of HTML and XML (EXtensible Markup Language). XHTML consists of all the elements in HTML 4.01, combined with the strict syntax of XML.”
Tips to be XHTML 1.0 compliant
1. Start writing your tags and attribute names in lower cases
for eg. <BODY> - is wrong
<body> - is correct.
<table WIDTH = “100%”> – is wrong
<table width = “100%” > – is correct
2. Always close your tags.
for eg. <p> this is a paragraph – is wrong
<p> this is a paragraph </p> – is correct
Be particularly aware when using tags like <img> <br> which do have a self closing tag in HTML 4.0,
These need to have a self-closing tag which is described as below.
<img src=”c:\\images\\alive.png”> – is wrong
<img src=”c:\\images\\alive.png” /> – is correct.
<br> – is wrong
<br/> – is correct
3. Nest your tags correctly
<ul>
<li>Coffee</li>
<li>Tea
<ul>
<li>Black tea</li>
<li>Green tea</li>
</ul>
<li>Milk</li>
</ul>
- is wrong
<ul>
<li>Coffee</li>
<li>Tea
<ul>
<li>Black tea</li>
<li>Green tea</li>
</ul>
</li>
<li>Milk</li>
</ul>
- is correct
4. XHTML documents MUST have a root element - <html>
The document structure should look like
<html>
<head> ... </head>
<body> ... </body>
</html>
5. Attribute values MUST be in quotes
<div id=header >
</div> – is wrong
<div id=”header”>
</div> – is correct
<table width=”100%”> - is correct.
<table width=100%> - is wrong.
6. Always add a <!DOCTYPE> declaration to you page.
A DOCTYPE gives the browser information about the kind of HTML it expects.
The DOCTYPE declaration is always the first line in an XHTML document.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title> xhtml document</title>
</head>
<body>
<p> welcome to xhtml standards</p>
</body>
</html>
The XHTML DTD (Document type definition) defines the syntax of the XHTML markup.
XHTML 1.0 Strict
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
XHTML 1.0 Transitional
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Use the transitional DOCTYPE for valid markup and pages which render the same in all major browsers.
XHTML 1.0 Frameset
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
Use the frameset DOCTYPE when you want to use HTML frames.
How w3schools was converted to xhtml
Useful Links
The XHTML 1.0 markup language (Second Edition) - http://www.w3.org/TR/xhtml1/
The XHTML Validator - http://validator.w3.org/
W3School’s XHTML Tutorial - http://www.w3schools.com/xhtml/
Tuesday, 4 November 2008
Mark Russinovich: Inside Windows 7
http://channel9.msdn.com/shows/Going+Deep/Mark-Russinovich-Inside-Windows-7/
Windows 7 Can scale upto 256 processors. whoohoo!!
Monday, 3 November 2008
The Numerati – Stephan Baker
They’ve Got Your Number
Maybe you’re the kind of person who doesn’t believe that the kind of person you are can be deduced by an algorithm and expressed through shorthand categorizations like “urban youth” or “hearth keeper.”
Maybe I’d agree with you, and maybe we’re right. But the kind of people — “crack mathematicians, computer scientists and engineers” — whom Stephen Baker writes about in “The Numerati” clearly see things differently. NYTimes Article