David Huby’s Blog Technical and business stuff

10Aug/100

Android Development – ADT Eclipse error

I got Hello World working without any problems, but when getting the LunarLander example I ran into a bit of an issue ... "The project cannot be built until build path errors are resolved"

I found the solution at http://code.google.com/p/android/issues/detail?id=5509 (by Philip Lowman)

1. Right click in Package Explorer and choose Import
2. Choose "Existing project into workspace" under General
3. Click Browse next to "Select root directory"
4. Select the following folder in your android SDK directory:
samples/android-8/ApiDemos
5. Check the "Copy projects into workspace" box
6. Click Finish
7. The project should now build successfully.

Filed under: Programming No Comments
6Aug/100

Get started learning PHP

Someone I met the other day asked me how they could get started with PHP - should they do a course?

I don't think a course is the best way to start PHP - with so many good resources online you can get started and start writing practical PHP, and come back and use a book or do a course once you've already grasped the basics.

Tips

Make sure you understand

  • the control structures like if, while, the difference between for and foreach
  • most of the string manipulation functions
  • print and echo and the difference between them
  • some of the array manipulation functions

You will also want a really good grasp of how arrays work, it's a pretty long article but I'd read through the whole thing php.net/array . I think the biggest strength of PHP is its very flexible array implementation and understanding it well will give you a great deal of the benfits of PHP.

Once you have that covered move on to understanding the object oriented functionality that was introduced in PHP5.

Resources

Stackoverflow.com

This is a great resource for a number of languages. One of the cool things about having people who know all these different languages is they can look at something like PHP from a bunch of different perspectives. A lot of people say PHP is terrible, and they have their reasons ... But I also think that there are many cases where PHP is the best or most economically viable solution

http://stackoverflow.com/questions/309300/defend-php-convince-me-it-isnt-horrible

Some really good responses on this thread. This will give you more of a feel for the language at a bit of a higher level than the nuts and bolts of this or that function.

You can look at all the PHP threads here

http://stackoverflow.com/questions/tagged/php

php.net

Thisis the official resource. One handy thing about php.net is if you want to search for how to use strlen (string length) for example, just navigate to php.net/strlen and you will be redirected to that manual page. In the left hand column there will be a bunch of other similar functions to the one you just looked up - in this case string manipulation

phpclasses.org

This is sometimes good sometimes bad. they have a lot of resources on there but I've found some of the submitted code is unpolished. On the other hand I've used some email and graphing libraries from there and they have been fantastic.

So if you want to find a library to do something that you think might have been done before, sign up and check out this site, try things and be aware the first thing you download might not be the right tool for the job.

From time to time they also have great newsletter articles.

Filed under: Programming No Comments
27Apr/100

ASP.NET Control Lifecycle

Complete Lifecycle of an ASP.Net page and controls

http://blogs.thesitedoctor.co.uk/tim/2006/06/30/Complete+Lifecycle+Of+An+ASPNet+Page+And+Controls.aspx

Filed under: Uncategorized No Comments
18Mar/100

Baretail – a great tool for montoring changing logs

Brian Canzanella blogged about Baretail in this article http://www.csharptocsharp.com/log4net-configuration-for-rockin-loggin

It doesn't look too special in the screenshot, but if you are looking for a tool which can monitor your logs live in Windows, this tool is fantastic.

Filed under: Uncategorized No Comments
8Mar/102

Single sign on in Sitecore

Even after going through the Active Directory and Custom Providers documentation with a fine toothed comb, there was still an issue with Single Sign On. Every time I hit sitecore/admin/LDAPLogin.aspx - the 'configuration test' for SSO, which had anonymous authentication disabled and Windows Integrated authentication turned on, I was presented with a pop up login box. After several failures using login details I knew to be correct, I was presented with a 401.1 Error Page.

It turns out this is due to custom host headers being used on a local site. You can read about this in more detail here at Microsoft support.

2Mar/100

Add Windows Authentication Provider IIS 7 Windows 7

http://weblogs.asp.net/zroiy/archive/2008/08/17/missing-windows-authentication-provider-for-iis-7-on-windows-server-2008.aspx describes how to set up Windows Authentication providers in IIS 7 on Windows 2008; the image below shows how it's done in Windows 7

Filed under: Sysadmin No Comments
2Mar/100

Event validation error in ASP.NET

I ran into this .NET error yesterday:

Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

This article may help if you have a page where the contents of drop down list boxes are being updated after the page has loaded - i.e. with JavaScript.

As K Scott Allen says, "Event validation checks the incoming values in a POST to ensure the values are known, good values. If the runtime sees a value it doesn’t know about, it throws an exception." http://odetocode.com/blogs/scott/archive/2006/03/20/asp-net-event-validation-and-invalid-callback-or-postback-argument.aspx

I had two Drop Down Lists which were being populated via AJAX after page load. The approaches to solving eventValidation errors I saw around on the .NET and StackOverflow:

  • Disable event validation: bad unless you have a workaround for all elements on the page, and some users have said that this has stopped other events firing.
  • Update the Render method: in some cases this will definitely work, in my case - it may be possible that I could have updated the validation with all possible values, something I haven't tried
  • Replace DropDownList controls with select tags: probably not a good idea but could be used for a quick fix
  • Some users have recommended adding an ASP.NET AJAX UpdatePanel around the affected control(s)

In my case I added all possible values of the drop down on page load and removed the AJAX functionality, as a quick fix, because the issue was occurring on a production site.

Filed under: Uncategorized No Comments
1Mar/101

Sitecore CryptographicException: Padding is invalid and cannot be removed.

Something to try if you get the error below: Recycle the application pool for the given website. It worked for me.

Update: If that doesn’t fix your problem, try clearing your cookies.

Server Error in '/' Application.
Padding is invalid and cannot be removed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[CryptographicException: Padding is invalid and cannot be removed.]

Tagged as: 1 Comment
1Mar/100

Sitecore issue – not all users being displayed in the User Manager

I know there more than 15 users should be returned by my providers, but only the first 15 are being displayed in the User Manager.

If I search using a search string such as "a" the results are correctly filtered to those including only "a". Some of the users returned in this result were not displayed in the previous listing. They are valid users and should have appeared when all users were being displayed.

Sometimes the users available shows "Page 1 of 2 (15 of 20 users)". Clicking on the right arrow to view the next page will display a different 15 users and in the bottom right hand corner users available is updated to "Page 2 of 1 (15 items)"

In the release notes for Sitecore,

October 21, 2009
Released Sitecore CMS 6.2.0 rev.091012 (Initial release). Change log. Important Changes:
User Manager
The performance of the User Manager has been improved again after 6.1 Update-1 had removed a previous optimization. This fix will, however, re-introduce the problem that the User Manager in certain situations, for example after creating a new user, will display an incorrect total number of users in the footer.

The Sitecore installation in question is using version 6.1.0 (rev. 090630)

Working theory: we need to update our Sitecore instance.

Filed under: Uncategorized No Comments
26Feb/100

Sitecore tip of the day – Rebuild Lucene Search Index

How do I rebuild a Lucene Search Index in Sitecore?

  • Log in to the Sitecore desktop at http://yoursite/sitecore/
  • Click the Sitecore button and open the Control Panel
  • Click on the Database group
  • Click Rebuild the Search Index
  • Select the indexes you wish to rebuild and click the Rebuild button