I've found this interesting article by John Cronan about using the Abstract Factory pattern to access files, no matter if they are on FTP, HTTP or the local or networked file system. Basically he uses WebRequest.Create rather than any *Stream* class.
Interesting enough, he seems to be the only one providing a solution to the problem of accessing local file system resources when the default access rights do not allow you to, even if the logged on credentials would normally give you the access, thus solving an issue of the FileWebRequest class. Unfortunately he uses P/Invoke, which kind of contradicts the whole "more flexible than thou" approach of the article.
Overall an interesting read which gives you flexibility of file support, while taking away some of the specific advantages like seeking or appending. It's a definitely better approach than StreamReader and the ugly "URI formats are not supported." error.
A bonus for using this method is that it is compatible with the Office 2007/Vista Open Packaging addressing model, by way of the PackWebRequest class.
I've just finished watching "Free Energy - the Race to Zero Point", which is a documentary of sorts listing ideas of ways to produce free energy with open systems, or getting a lot more efficiency than present systems. The speakers are authors of controversial books and editors at magazines names as crackpotty as possible. The narrator himself looks like a Hitchcock wannabe, presenting the end of the world. Heck, the film is not even listed on Imdb, therefore this blog entry. But, even if I am mostly convinced that this is a piece of sensationalist propaganda and not true science, I am left wondering how much (if any) of this is truly real? Did Moray have a device that lit up light bulbs without fuel or batteries? Are the numerous inventors presented there just crackpots or do they have something? I find it difficult to believe that all video proof that was presented in the movies was faked. Why would they? Yet most of all I resonated with the idea that is, unfortunately for this movie, presented by all featured people: economic interests reign supreme and devices that don't need to be connected to power grids, use oil or that can be regulated by established industries are not only avoided, but actively attacked. It does make sense, doesn't it?
Well, I don't. I was first shocked to find out that the 1918 "Spanish" Flu pandemic killed 50 million people and I found out about it only in my twenties. Now I see that the pandemics are recurring events, there are lists with the virus strains and where they originated, while information from before 1900 is unreliable since medicine was not really.
Check out this link that shows a history of flu strains and the three flu pandemics from the last century.
While listening to my favourite songs on Pandora, I heard a song that I really enjoyed. The band was The Provenance, from Gothenburg, Sweden. and I immediately started looking for more on the Internet. Here is one of the best songs I've heard in a while, with a video that could have been way better. The music, though, is worth it.
They have a site, but not very updated and, since they just released their fourth album but only joined YouTube in October 2006, I guess they are not really Internet people. So let's us lend them a little hand, shall we? Official Web Site - Actually, their site is dead, their domain for sale. MySpace site - ugh, it seems that the band has been... well... disbanded. Their last blog entry says as much: "bye". YouTube user site
Of course, sooner or later YouTube blocked this video. Let's try something else:
It seems there is a fashion of combining English and Japanese in popular music in Japan, but this is really ridiculous. Just check out the lyrics: "Not a Chinaman 'cause I ain't from China, man... I am Japan, man.". Damn that's funny :))
Enough with this! Geeks are not supposed to move, even use their hands to push something so small as a mouse. Moving a mouse all day builds muscle and you know that is bad! So check out the OCZ Neural Impulse Actuator at work. A head band, a wire, no movement. Geeky! I want one of those!
In other words: those curly bracket things in SQL. What? curly brackets in SQL? Yes! Imagine that :)
The idea is that most database systems adhere to the ODBC standard, at least ODBC 1.0. That means that, when you communicated with a database, you can send so called ODBC escape sequences that are translated into the SQL engine native objects.
Quick example: SELECT {d '2007-03-15'} will work in all ODBC 1.0 compliant DBMSs, including Microsoft SQL Server, MySql, PostgreSQL, Oracle, etc. and select a date object from 15 of March 2007, no matter the server configured country or language.
Interested yet? You can read the ODBC Programmer's Reference for more details. Short story shorter, here are the working and interesting parts (to me) of the ODBC escape sequences: select {d '2007-02-13' } select {t '22:20:30' } select {ts '2007-02-13 22:20:30' } select {fn curdate()} select {fn curtime()} select {fn User()} select {fn Database()} select {fn week(getdate())} select {fn quarter(getdate())} select {fn monthname(getdate())} select {fn dayname(getdate())} select {fn curdate()} select {fn dayofweek(getdate())} select {fn dayofyear(getdate())} select {guid '12345678-1234-1234-1234-123456789012'}
This is because the namespace has changed since the writing of Elion's article from Microsoft.Web.UI to System.Web.UI and there are two methods named RegisterClientScriptResource and two named RegisterStartupScript so you have to get the right one. Else you get the "Ambiguous match found" error.
The .NET validation framework has two parts, the client Javascript validation and the server validation. That means that the Javascript code needs a value to validate and the server validation needs a property to validate.
So, first step, you create your web user control by putting some controls in it. Then, you want to add a validator to the page to reference the newly created user control. And you get the error "Control '{0}' referenced by the ControlToValidate property of '{1}' cannot be validated.". Why? because every control to be validated needs to be decorated with the ValidationProperty attribute:
[ValidationProperty("Text")] public partial class ucDate : System.Web.UI.UserControl
Adding the first line to the control tells the validation framework to use the Text property of the UserControl.
Next step, you run the page and you notice the javascript doesn't work. The client validation works on html controls, by looking (recursively) for a 'value' attribute. When one looks at the source code, though, there is no html control that has the id of the user control. It doesn't use a span or a div to encapsulate its controls. All the controls have the id to show they are children to the user control, but the actual user control does not appear in the html source. So what is there to do?
<div id='<%=ClientID %>'></div>
You put all the controls in the ascx file of the User Control into this div. There you go! The validation works!
There is one more quirk regarding web user controls that have more children that render an html object with a 'value' attribute. In that case, remember that the validation starts from the very top, in our case the div. One could build simple javascript functions on the onchange or onsubmit javascript events, for example, to add a value attribute to the div. Best way would be using the onsubmit event, but be careful that the validation sequence also runs on the onsubmit event.
I am just linking this small page about the evolution of Earth. You may see when the planet formed, how the moon appeared, the different geological eras, major meteor impacts and extinctions, the evolution of species and some information about the impact humans have on the environment lately.
I've told a lot of people about this, but forgot to blog about it. Shame on me, because this revolutionary concept can change the way we think of sound.
Audio Spotlight enters the category of directional sound systems, more precisely it creates sound from ultrasound. The result is that you can direct a single speaker towards a certain area, and only people in the area can hear the sound.
There are drawbacks, as obstacles getting in the way of the sound beam block the sound from reaching further on. There are limitations to the frequency response and the dispersion pattern. I also don't know if the system can create loud sounds as this would probably need high power ultrasound and I don't know how healthy that would be.
But, even so, the idea is marvelous. As you can see from the animation from the Audio Spotlight site, you can attach a sound to a picture in a gallery, and the sound will only be heard by the people in from of the picture. Imagine that in a museum. Or think about having a restaurant with audio spotlight above the tables, playing whatever music they want and not bothering the other people. Combine it with some form of sound barrier between tables and you get a classy private place with no walls and a lot of people. Or think of a disco where you can separate the sound of each instrument and play it in a slightly offset area so people can dance to the music equalized however they like it. Or even a club where people can hear the music loud on the dance floor and really weak at tables, so they can talk.
This invention comes (of course) from MIT, more precisely from Dr. Joseph Pompei while he was a student at the MIT Media Lab, himself son of another distinguished doctor, Dr. Francesco Pompei.
Update: However, with great power comes... ah, forget Spiderman! Anyway, there are voices expressing concern on the evil use of such technology. Like this link here, expressing the opinions of Barry Blesser, one of the most respected names in digital audio.
Now, I guess that the best invention ever would be directional earplugs! :)
I found this article on BBC News that told of a series of new algorithms for 3D image rendering using the tracing of light rays rather than polygonal rendering. They also use less resources than traditional algorithms. Interesting enough, so I searched the Internet. I think this will usher a new era of computer games, not to mention a boom of cheap 3D movies. See how the reflections generate secondary and tertiary reflections in the image?
For a while now, whenever I start my computer at work, I get to wait about 5 minutes with my CPU up to 100% due to svchost.exe. Of course, this being an important component of Windows, I cannot delete or disable it, neither can I see what subprocess is causing this utilisation with the normal Task Manager. However, one can download Process Explorer and see a lot more information. I highly recommend it.
Anyway, back to the original problem. I noticed that the problem was the ntdll.dll (ntdll.dll!RtlAllocateHeap+0x18c to be exact) which is, again, a Windows important file.
Only googling to the extreme did I find that the issue is caused by Windows Update, scanning your computer each time you start it. If you disable Windows Update, you don't get the updates, but you get rid of the wait.
Here is a discussion with Microsoft MVPs about possible solutions. Also, try this link.
And if you do have Process Explorer, you can set the priority of the offending task to Bellow Normal, which will allow you to run any program normally while the Windows Update process runs only on spare CPU. Normal Task Manager does not allow you to change the priority of the process.
Windows has a file called hosts, found in Windows\System32\drivers\etc\hosts, that can contain local domain name to ip conversions. It's like a local DNS service with a text database. That means that if you open the file and write 127.0.0.1 www.microsoft.com then every time you try to access microsoft, the browser will redirect to your local machine, effectively making it unreachable.
You can use this to block some of the sites you don't want your child to access or whatever, but most of all, you can disable the access to sites that are known sources of unwanted ads, spyware, malware, etc. Or, as I did, disable access to sites with online games that you are addicted to :)
You can find an updated hosts file at mvps.org. Backup your previous hosts file, for safety, then overwrite it with this.
Update: If you have a blog on Google's Blogger, you should comment (by adding a # in front of the line) or delete the line of the hosts file relating to service.urchin.com #[Urchin Tracking Module], else you will get some javascript errors when entering Blogger. Or you can just ignore all javascript errors.
Unfortunately, the lead singer is now in prison after accidentally killing Marie Trintignant, his girlfriend and the daughter of famous actor Jean-Louis Trintignant. This clip is manga-style, but that's not why I put it here, it's because I really like the song.