Codebender
not the last of his kind
not the last of his kind
May 21st
This is a common question when one wants to publish a new open source project, especially if he/she is new to open source licensing scheme. The many available choices of the license can be very confusing and many people simply pick a license without really understanding the meaning or the clauses in the license. Some choose a license by the popularity. Some because a particular license is used in their favorite projects. Even worse, some even choose a license because it looks or sounds cool.
There are many resources on the Web that provide comparison of the available licenses. I want to make it simpler by creating a flowchart to guide you to pick the right license for your project. To reduce confusion, I’ll only list the most common open source licenses. You can click on the flowchart to enlarge it.
Apr 26th
When using either WebClient or HttpWebRequest to download file from a remote location, sometimes I got the following exception:
System.Net.WebException: An exception occurred during a WebClient request
For some reasons, IIS (the Web server) may deny to serve a request that doesn’t specify the user-agent property in the request header. So, although it’s not really obvious, this can be solved pretty easily by specifying the particular user-agent property. You can set it to anything, it doesn’t matter as long as it exists.
For example, here how you provide the property using WebClient:
using (var wc = new WebClient()) { wc.Credentials = CredentialCache.DefaultCredentials; wc.Headers.Add(HttpRequestHeader.UserAgent, "anything"); wc.DownloadFile(fileUrlToDownload, fileNameToSafe); }
And, here how to do it with HttpWebRequest:
var req = (HttpWebRequest)HttpWebRequest.Create(fileUrlToDownload); req.Credentials = CredentialCache.DefaultCredentials; req.UserAgent = "anything"; var resp = (HttpWebResponse)req.GetResponse(); using (var stream = resp.GetResponseStream()) { using (var fstream = new FileStream(fileNameToSafe) { var buffer = new byte[8192]; var maxCount = buffer.Length; int count; while ((count = stream.Read(buffer, 0, maxCount)) > 0) fstream.Write(buffer, 0, count); } } resp.Close();
You may also notice that downloading a file using WebClient is much simpler than using HttpWebRequest. The later, however, gives you much more control.
Mar 23rd
My thin-client desktop is running Debian Linux with the Gnome window manager. When I use it to connect to my Windows Server VM using rdesktop, I usually get a problem when trying to type ASCII or accented (French) characters. For example, when typing Alt 130, I am expecting to get the é character. Instead, it’s only printing 30 (the 1 character was omitted).
It drives me crazy since I have to type a lot of these accented, especially French, characters. Fortunately, later I found that turning off the Num Lock fixed this problem. Yes, for some reason, I can’t type the ASCII characters with the keyboard’s Num Lock on.
Actually, working with Linux rdesktop to connect to a Windows machine is very annoying. Aside from the problem I just described, I still have more issues that yet to be solved:
I love how this just works in Windows.
Recent Comments