Monday, August 20, 2012

Windows Error: "System could not allocate the required space in a Registry log"

I recently had this issue on my dad's Acer laptop with Windows XP: "System could not allocate the required space in a Registry log". After googling, I found the fix: "Delete unneeded files from the system partition and then retry the operation." But, there's was an issue: I get the error even before getting on to the login screen. So, I couldn't delete any files and free up any space to get the computer started. 

The next fix I thought was to try the safe mode to get into the computer, so that I could delete some files. Unfortunately, it didn't work either as I got the same error before getting into the files system.

Finally, I removed the hard drive, put it on to an external hard drive enclosure, and plugged into another computer. Then deleted about 500 MB of files and plugged it back into the Acer. The computer started fine without any errors.

Hope this would help someone.

Wednesday, August 15, 2012

.Net Interview Puzzles

Links to good Puzzels:
http://www.yoda.arachsys.com/csharp/teasers.html
http://weblogs.asp.net/ssadasivuni/archive/2005/01/12/351335.aspx
http://www.acetheinterview.com/questions/cats/index.php/microsoft_google

-------------------------------------------------------------------------------------------

Swap two variables without using a temp variable

startAngle = startAngle+stopAngle;
stopAngle = startAngle-stopAngle;
startAngle = startAngle-stopAngle;

or completeness, here is the binary XOR swap:
int x = 42;
int y = 51236;
x ^= y;
y ^= x;
x ^= y;

--------------------------------------------------------------------------------------------
Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".
for(int i =1;i<=100;i++)
            {
                 if (((i % 5) == 0) && ((i % 3) == 0))
                {
                    Console.WriteLine("FizzBuzz");
                }
                else if (((i % 5) == 0) )
                {
                    Console.WriteLine("Buzz");
                }
                else if (((i % 3) == 0) )
                {
                    Console.WriteLine("Fizz");
                }
                else
                {
                    Console.WriteLine(i);
                }
            }
------------------------------------------------------------------------------------------------

"There are two ropes. Each is one metre long. You have some matches. Each rope burns in one hour. The ropes do not burn linearly. That is, half the rope does not necessarily burn in half an hour. How do you measure out forty-five minutes?"

"You set light to both ends of the rope 1 and just one end of rope 2. It will take half an hour for the two burning ends of rope 1 to meet. Then you set light to the remaining end of rope 2. The time it will take for rope 2 to finish burning will be a further 15 minutes. Hence all together, both ropes burned in this manner will take 45 minutes to burn."
From: http://www.brainj.net/puzzle.php?id=interview
-------------------------------------------------------------------------------------------------

static void Main(string[] args)
{
    for (byte b = byte.MinValue; b <= byte.MaxValue; b++)
        Console.Write(b);
}

// A little tip
// byte.MinValue = 0
// byte.MaxValue = 255

How many times the above statement will be executed ?
Answer: Endless loop
From: http://kossovsky.net/index.php/2009/07/csharp-byte-iteration-question/

Acronyms and Beyond


Collection of frequently used acronyms at workplace:

Software Development Concepts


DRY: Dont Repeat Yourself

YAGNI: You Ain't Gonna Need It
KISS: Keep It Simple Stupid
BDD: Behavior Driven Development
TDD: Test Driven Development
DDT: Design Driven Testing
DDD: Domain Driven Designing
SOA: Service Oriented Architechture
SOLID:
  • Single Responsibility Principle
  • Open Close Principle
  • Liskov Substitution Principle
  • Interface Segregation Principle
  • Dependency Injection
Technologies

ADO: ActiveX Data Objects
ASP.Net MVC: Active Server Pages - Model View Controller
WPF: Windows Presentation Foundation
WCF: Windows Communication Foundation
WF: Workflow Foundation
WC: Windows Cardspace
SSIS: Sql Server Integration Services
SSRS: Sql Server Reporting Services
SSAS: Sql Server Analysis Services
SOAP: Simple Object Access Protocol
AJAX: Asynchronous JavaScript and XML
CLR: Common Language Runtime
CLS: Common Language Specification
COM: Component Object Model
CTS: Common Type System
ILDASM: Intermediate Language Disassembler
IL: Intermediate Language
MSIL: Microsoft Intermediate Lanuage
JIT: Just In Time
DLL: Dynamic Link Library
PE: Portable Executable/exe file
DOM: Document Object Model
GC: Garbage Collector
GDI: Graphical Device Interface
GAC: Global Assembly Cache
HTTP: Hyper Text Transfer Protocol
TCP: Transmission Control Protocol
IDE: Integrated Development Environment
IIS: Internet Information Server
GUID: Global Unique Identifier
XML: Extensible Markup Language
CDN: Content Delivery Network












Tuesday, August 14, 2012

.Net Video Collection


Thought of creating a free video collection related to Dot Net that I find during day to day research.

ASP.Net
ASP.Net Conference 2012: http://channel9.msdn.com/Events/aspConf/aspConf

ASP.Net MVC:
HTML 5 TutorialIn HTML5 First Look, author James Williamson introduces the newest HTML specification, providing a high-level overview of HTML5 in its current state, how it differs from HTML 4, the current level of support in various browsers and mobile devices, and how the specification might evolve in the future. 

Behavior Driven Development (BDD)
Specflow: http://specflow.org/specflow/screencast.aspx

SSRS
Introduction: http://www.youtube.com/watch?v=aafHygddNqc

Shadowing vs Overriding:
        http://vimeo.com/25711711
        http://csharp-video-tutorials.blogspot.com/2012/06/part-22-c-tutorial-method-hiding-in-c.html

Inheritance: http://csharp-video-tutorials.blogspot.com/2012/06/part-21-c-tutorial-inheritance-in-c.html
The Diamond Problem: http://csharp-video-tutorials.blogspot.com/2012/06/part-34-c-tutorial-problems-of-multiple.html

Friday, August 10, 2012

Simple Webserver Using WCF

Note: This post is still in work-in-progress, but if anyone interested to know it faster, please let me know.

I wanted to create a simple web server that I wanted to use in another architectural design (will be coming soon in another post). After some research, I found a good solution using WCF.

WCF can be hosted on many places including Windows forms, IIS, WPF...etc. In this solution, I host my simple WCF web server on a WPF window. Follwoing is the code behind of my WPF mian window that hosts the web server.


using System;
using System.IO;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.ServiceModel.Web;
using System.Text;
using System.Windows;
 
namespace WpfApplication1
{
    /// <summary>
    ///   Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private static readonly string baseAddress = "http://" + Environment.MachineName 
":8111/Service";
        private static readonly ServiceHost host = new ServiceHost(typeof (Service),
                                                new Uri(baseAddress));
 
        public MainWindow()
        {
            host.AddServiceEndpoint(typeof (IImageServer), new WebHttpBinding(), "")
                                         .Behaviors.Add(new WebHttpBehavior());
            host.Open();
            Console.WriteLine("Service is running");
            Console.Write("Press ENTER to close the host");
            Console.ReadLine();
            InitializeComponent();
            brw.Navigate(new Uri("http://localhost:8111/Service/GetImage?width=50&height=40"));
        }
 
        private void Window_Closed(object sender, EventArgs e)
        {
            host.Close();
        }
    }
 
    [ServiceContract]
    public interface IImageServer
    {
        [WebGet]
        Stream GetImage(int width, int height);
 
        [WebInvoke]
        Stream GetPost(Stream contents);
    }
 
    // implement the service contract
    public class Service : IImageServer
    {
        public Stream GetImage(int width, int height)
        {
            // Although this method returns a jpeg, it can be
            // modified to return any data you want within the stream
 
            byte[] byteArray =
                Encoding.ASCII.GetBytes(
                    @"<html><body><form name='input' action='/Service/GetPost' method='post'>Username 
<input type='text' name='user' />
<input type='text' name='password' />
<input type='submit' value='Submit' />
</form></body></html>");
            var ms = new MemoryStream(byteArray);
 
            ms.Position = 0;
            WebOperationContext.Current.OutgoingResponse.ContentType = "text/html";
            return ms;
        }
 
        public Stream GetPost(Stream contents)
        {
            // Although this method returns a jpeg, it can be
            // modified to return any data you want within the stream
            string input = new StreamReader(contents).ReadToEnd();
            var x = WebOperationContext.Current.IncomingRequest;
            //var vl = x.[""];
 
            byte[] byteArray = Encoding.ASCII.GetBytes("<html><body><h1>Yeah</h1></body>
                                                          </html>");
            var ms = new MemoryStream(byteArray);
 
            ms.Position = 0;
            WebOperationContext.Current.OutgoingResponse.ContentType = "text/html";
            return ms;
        } 
    }
}