The Alchemist by Paulo Coelho
The Alchemist by Paulo Coelho has two layers: the icing, but a thin veneer, albeit a quite interesting one, is the story of a boy who wanted to see the world. Underneath, it describes “The Secret”: that the whole universe conspires to help you achieve your dreams. There is also a passing reference to “The Power of Now”: that the present is all there is.
This book provokes the reader to think, and I’ve come to think, after reading this book, that dreams are overrated. First, not everyone is born knowing exactly what they want, which is the crucial first step. For most people, discovering one’s direction (upon which both heart and mind agree) is the hard part. Second, what’s the big deal? If you’re hungry, eat; if you want something badly enough, go for it with all you’ve got.
If you’ve read Ayn’s Rand The Fountainhead, you won’t be very impressed by The Alchemist. The storyline is thin, the protagonist unconvincing, the philosophical message unsubstantial. I suppose, however, for those who are already contemplating their life meaning, it could be that cataclysmic “call to action”, and give a “life-enhancing impact” (according to The Times), which is laudable.
WER folder eating up disk space on Windows Server 2008
My ASP.NET app, running on Windows Server 2008, suddenly died:
Could not load file or assembly ‘Coolite.Ext.Web’ or one of its dependencies. There is not enough space on the disk. (Exception from HRESULT: 0×80070070)
So I dug around and found that C:\ProgramData\Microsoft\Windows\WER\ReportQueue was taking up GBs upon GBs of space. A rudimentary google showed that this is a common problem and running Disk Cleanup is the answer. Unfortunately Disk Cleanup is not installed by default on Windows Server 2008; an install requires a reboot, something I didn’t want to do. So I fired up a Command Prompt window:
cd \ProgramData\Microsoft\Windows\WER\ReportQueue del /s *.tmp.hdmp del /s *.tmp.mdmp
So far, so good …
SVN Hosting Comparison
Updated 19 February 2009:
Between Beanstalk and Unfuddle, I initially chose the former, because I liked its UI better. But then I discovered that the free version of Beanstalk doesn’t have any defect tracking integration. So now I’m using Unfuddle (free version) and it’s been great so far. Performance is ok, the UI is nice (not as clean as Beanstalk’s, but still pretty good), but the winner is Unfuddle’s SVN integration with Trac: just key in the ticket number (e.g., “Ticket #123″) as the log message during SVN commit and Unfuddle will automatically create links between the SVN revision and the Trac ticket. Amazing.
Original posting:
(Yes, I know, Git is better, but SVN is just fine for my particular purpose.)
Tried the following free SVN hosting:
- CVSDude Codesion. AJAX-ey UI and all that, but I found it distracting and confusing. More confusing was the fact that I couldn’t log in. Verdict: No.
- ProjectLocker. Old-school UI – fine with me. Ads all over the place – fine with me. But it’s slow. Verdict: No.
- Beanstalk. Very clean, very intuitive UI. Best feature: automatically creates the trunk, branches and tags directories upon creation of a new repository. I’m liking it. Verdict: Yes!
Getting started with jQuery
Maybe you’re like me a month ago: you’ve heard great things about jQuery; you would love to get to know the basics; but you have better things to do than to aimlessly walk through tutorials. I was lucky enough to be working alongside a jQuery-savvy UI developer on a recent project these past few weeks, and I’ve managed to pick up a few tricks. So let’s see if you can know what I know by the end of this blog entry, and start littering your client-side scripts with dollar signs for your next project
At the most fundamental level, jQuery is a great way to save on typing stuff like document.getElementById("uxFirstName").value. Pre-jQuery, we would write:
<p><input type="text" id="uxFirstName" name="uxFirstName" /></p>
<p><input type="button" id="uxClickMe" name="uxClickMe" value="Click me" onclick="uxClickMe_click()" /></p>
<script type="text/javascript">
//<![CDATA[
function uxClickMe_click() {
alert(document.getElementById("uxFirstName").value);
}
//]]>
</script>
With jQuery:
<p><input type="text" id="uxFirstName" name="uxFirstName" /></p>
<p><input type="button" id="uxClickMe" name="uxClickMe" value="Click me" /></p>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
$("#uxClickMe").bind("click", function() {
alert($("#uxFirstName").val());
});
});
//]]>
</script>
Important takeaways: You can place multiple $(document).ready(function() { ... }); anywhere within the document body. Using CSS notation, "#elementId" denotes the element id, and ".className" denotes the element class. (The latter is very useful for stuff we want to do on multiple elements.) What I like best is the .bind() method, this frees us from messing up elements with attributes such as onclick and onblur.
Okay, let’s move on to more interesting stuff. We want to be able to toggle a div to show and hide its contents with a “slide in/slide out” effect. The best example would be a shopping cart, but its HTML would be a bit too involved, so we’ll just use the example of a textarea for the user to key in optional remarks in a web form.
<a href="#" class="add-remarks">Additional remarks</a>
<div class="optional remarks">
<textarea id="uxRemarks" name="uxRemarks" cols="80" rows="5"></textarea>
</div>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
$("div.remarks").hide();
$(".add-remarks").bind("click", function(e) {
e.preventDefault();
$("div.remarks").toggle("slow");
});
});
//]]>
</script>
So, by default, the big textarea is hidden (line 8), and if the user wants to type in it, he clicks on the link, and the textarea slides into view (lines 9-12). Nice. Now we have an additional consideration: what if there is a postback due to some user action? Then whatever the user had typed in would be hidden upon page load. The solution would be to replace $("div.remarks").hide(); with the following:
$("div.optional").each(function() {
if ($(this).children().is("textarea")) {
var textarea = $(this).children("textarea");
// assume that there'll only be one textarea in div.optional
var text = textarea.val();
if (text == null || text.length == 0) {
$(this).hide();
}
}
});
So, for each div with class=”optional”, if it has a child element that is a textarea, and the textarea doesn’t contain any text, hide the div. Note: $(this) refers to $("div.optional"). So you can have many optional textareas, and each would be hidden only if it’s empty.
Well, that’s essentially all I know (for now) about jQuery, and I hope you found $(this) (heh) useful.
Integrating jQuery Autocomplete plugin with ASP.NET
I wanted to use the jQuery Autocomplete plugin:
$(document).ready(function() {
var url = "SomeData.aspx";
$("#myTextBox").autocomplete(url, {
minChars: 2
});
});
Where the url needs to return with one value on each line. I suppose an HTTP handler (.ashx) would be more suitable for this, rather than a web form, but I wanted to utilize the MVP framework already in place which had all the code needed to get the data from the DB. When I tried to get the .aspx to output just plain text without any HTML tags by removing the MasterPageFile attribute from the @Page directive, I got the following error:
Using themed css files requires a header control on the page. (e.g. <head runat=”server” />).
After mucking around a bit, I found that the following worked for me:
<%@ Page Language="C#" AutoEventWireup="true" Codebehind="SomeData.aspx.cs" Inherits="MyProject.SomeData" Theme="" %>
