Wednesday, 16 May 2012
Visual Studio Intellisense Fix
Having Googled this issue I can up with a number of solutions some simple and some requiring a bit more effort. These ranged from hotfixes to uninstalling extensions - none of which worked!
The simple solution in fact for me was to not leave Visual Studio at all...
I just had to go into Tools > Options > Text Editor > C# Then check Auto list members and Paremeter information boxes.
For you it may be a different language but the procedure is still the same.
I hope this saves someone some time!
Tuesday, 15 May 2012
Default Namespaces in XDocument
Trying to create a google news site map using XDocument yesterday and I ran into a little problem working with a default namespace as well as additional explicitly named namespaces.
i.e <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
To save you guys the time and effort here is some advice - you need to declare the default namespace in the root element name declaration and add additional namespaces as Attributes to this element.
See below snippet of code:
XNamespace sitemap = XNamespace.Get("http://www.sitemaps.org/schemas/sitemap/0.9");
XNamespace news = XNamespace.Get("http://www.google.com/schemas/sitemap-news/0.9");
XDocument newsSitemapDoc = new XDocument(new XDeclaration("1.0", "UTF-8", null),
new XElement(sitemap + "urlset",
new XAttribute(XNamespace.Xmlns + "news", news.NamespaceName)));
Basic Publisher Subscriber in jQuery
Using jQuery bind and trigger to create a basic publisher subscriber pattern
In the html we have as follows:
<div class="sub sub1"></div>
<div class="sub sub2"></div>
Then the following javascript:
$('.sub1').bind('subscriberNotification', function(e, param1, param2) { alert(param1 + ': ' + param2); });
$('.sub2 ').bind('subscriberNotification', function(e, param1, param2) { alert(param2 + ': ' + param1); });
$('.sub').trigger('subscriberNotification', [ 'Hello', 'World' ]);
$('.sub').trigger('subscriberNotification', [ 'Hello', 'World' ]);
We should now receive one alert that says hellow world from subscriber one and one which says world hello from subscriber 2
Optional Parameters MySQL
Today I was dealing with a problem I had come across many times before but I've decided to ignore! The problem is where you've got multiple parameters which form the basis of an MySql WHERE, however all these filters are optional. So I am normally left with the ugly task of building a WHERE clause by dynamically appending only those columns I need to filter at the same time checking if an AND or a WHERE prefix is needed! yuk!!!
Today I decided to take the bull by the horns and search for a better solution and after a lot of to-ing and fro-ing between forums and blogs I discovered the following syntax:
SELECT * FROM table
WHERE ((@field1 is null) OR (field1 = @field1))
AND ((@field2 is null) OR (field2 = @field2))
AND ((@field3 is null) OR (field3 = @field3))
Thus, now I am able to pre-write the entire query with all parameters but only filter by parameters which contain values... if a parameter is null it simply gets ignored!
Another hack bites the dust!!!
Monday, 14 May 2012
I'm Going Solo
The 3 R's are no more just one r-migo from here on.
Nobody reads these first posts, but if you are then this will be a window into my mind a place to share my thoughts on web development, design and usability the only things I'm not afraid to speak up on!
To while(true) and beyond!
Nobody reads these first posts, but if you are then this will be a window into my mind a place to share my thoughts on web development, design and usability the only things I'm not afraid to speak up on!
To while(true) and beyond!
Subscribe to:
Posts (Atom)