Thursday, February 25, 2010

Blocking user agents in IIS7

I had a problem with a very specific User-Agent - GBPlugin from Brazil.

Not sure why but this User-Agent was blocking IIS7 (not my ASP.Net app but IIS7 itself :/)

To solve this, I tried blocking GBPlugin a few ways - URLScan, RequestFiltering and my own custom http module. However, eventually I worked out how to do it using the generic URL rewrite module:

Although I of course configured this using the IIS UI not going direct to the .config files - just felt safer on the live server.

Monday, February 15, 2010

Enabling Screen Rotation on Samsung Omnia II phone - also enabling classic Microsoft Settings Control Panel

It took a little finding - but together these guys give the solution:


Two registry keys to change:

  1. HKLM\System\GDI\Rotation\HideOrientationUI and change the value to 0
  2. HKEY_LOCAL_MACHINE\Security\Shell\StartInfo\HideSettings change to 0

Monday, February 08, 2010

Getting SQLite to work in PHP (PHP5) on Windows Server

I just wanted to use the existing code....

But it seems PHP5 underwent a big change in "PDO" for SQLite.

I went around the houses looking at errors like "Class 'SQLite3' not found php" and " Fatal errorCall to undefined function sqlite_open()"

But... finally I found: http://djhweb.co.uk/sqlite1.htm

So I had to change the code:

$db = sqlite_open('filename',0666)

to 

$db = new PDO('filename');

Then:

$res = sqlite_query($db, $query, SQLITE_ASSOC);

to

$res = $db->query($query);

And:

$row=sqlite_fetch_array($res);

to

$row=$res->fetch(PDO::FETCH_ASSOC);

I might have got some of this wrong... but hopefully not!

If you hit "SQLSTATE[HY000] [14] unable to open database file" then that means you need to open up read/write permissions on the database directory.

Friday, February 05, 2010

Doing IE6 testing

You don't want to, but sometimes you have to

When you do, then IE6 testing can be quite easily done using IETester - fab - http://www.my-debugbar.com/wiki/IETester/HomePage

Sunday, January 31, 2010

Just in case I need to use PHPMailer again...

The important line was $mail->SMTPAuth = true.

Thanks to:
http://www.fasthostinghelp.com/send-mail-using-phpmailer-t98.html

$mail = new PHPMailer(); 

$mail->IsSMTP(); // send via SMTP 
$mail->Host "mail.domain name"// SMTP servers 
$mail->SMTPAuth true// turn on SMTP authentication 
$mail->Username "Domain Email account"// SMTP username 
$mail->Password "password of an email account"// SMTP password 

$mail->From "From email account – from above mentioned domain"
$mail->FromName "From Name here"
$mail->AddAddress("To Email account here ","Display name"); 
$mail->AddReplyTo("Reply to email account here ","Details"); 

$mail->WordWrap 50// set word wrap 

$mail->IsHTML(true); // send as HTML 

$mail->Subject "Subject Line of the email"
$mail->Body "Body part of the message – email details</b>"
$mail->AltBody "Alternate part of the body"

if(!
$mail->Send()) 

echo 
"Message did not sent <p>"
echo 
"Mailer Error: " $mail->ErrorInfo
exit; 


echo 
"Message has been sent"

?>

Thursday, January 28, 2010

Writing a DNN skin - need to get parent tab name

John Mitchell to the answer:

http://www.snapsis.com/DotNetNuke/Support/tabid/560/aff/12/aft/5003/afv/topic/Default.aspx

Have you ever wanted to get at more than just <%= SkinPath %>in your skin?

Maybe you want to display the name of the currently Active Page?

<%=PortalSettings.ActiveTab.TabName %>

Or maybe you want to display the name of the Active Page's Root level Parent?

<%=PortalSettings.ActiveTab.BreadCrumbs(0).TabName%>

If you want the currently Active Page's immediate Parent Tab Name try this:

<%=PortalSettings.ActiveTab.BreadCrumbs(PortalSettings.ActiveTab.Level - 1).TabName %>

Thursday, January 21, 2010

When Visual Studio 2008 keeps crashing

It's happened to me before and it's so annoying

Visual Studio just crashes and crashes and crashes - and it's not so easy to work out what to do...

First try the log file:
http://blogs.msdn.com/saraford/archive/2008/11/27/did-you-know-there-s-a-way-to-have-visual-studio-log-its-activity-for-troubleshooting-366.aspx

Then try the reset commands... basically type /? on the command line and you get options like /resetskippkgs and /resetaddin and /resetsettings

I'll try anything - I just want to get on with work!

Friday, January 15, 2010

MonoTouch - if you can't see any Provisioning Profiles

If MonoDevelop can't see any Provisioning Profiles, but XCode can, then maybe just maybe:

Distribution identity is not shown in MonoDevelop project signing options

MonoDevelop 2.2 has a bug that causes it not to detect distribution certificates that contain a comma. Apreview build of MonoDevelop 2.2.1 is currently available that fixes this issue.



This worked for me!

Wednesday, January 13, 2010

UITabBarController (kind of) inside a Modal child view

I've been playing quite a bit with MonoTouch - love it

It won't be a long term solution I feel (I *think* Silverlight is coming to the iPhone soon!) but it is a good solution for me right now.

One of the problems I've had is trying to get a UITabBarController to work in a child View - basically I just can't work out how to do this in Interface Builder.

To work around it I tried this code instead - using a UITabBar and custom linking code rather than using the "full" UITabBarController.

public override void ViewDidLoad ()
{
base.ViewDidLoad ();
childOne.Text = "one";
childTwo.Text = "two";
mainView.AddSubview(childOne.View);
mainView.AddSubview(childTwo.View);
mainView.BringSubviewToFront(childOne.View);
tabbar.SelectedItem = tabitemOne;
tabbar.Delegate = new MyUITabBarDelegate(this);
}


class MyUITabBarDelegate : UITabBarDelegate
{
TabViewController tvc;
public MyUITabBarDelegate (TabViewController _tvc)
{
tvc = _tvc;
}
public override void ItemSelected (UITabBar tabbar, UITabBarItem item)
{
if (item.Tag == 0)
{
tvc.mainView.BringSubviewToFront(tvc.childOne.View);
//while (tvc.mainView.Subviews.Count() > 0)
// tvc.mainView.Subviews[0].RemoveFromSuperview();
//tvc.mainView.AddSubview(tvc.childOne.View);
}
else
{
tvc.mainView.BringSubviewToFront(tvc.childTwo.View);
//while (tvc.mainView.Subviews.Count() > 0)
// tvc.mainView.Subviews[0].RemoveFromSuperview();
//tvc.mainView.AddSubview(tvc.childTwo.View);
}
}
}



Some initial MonTouch links

Doing MonoTouch stuff - and really quite enjoying myself!

I'd better make it pay though....


The monotouch forums are very useful - lots of code snippets around!

Monotouch.info is a good place to look for links

If you want to write games using Cocos, then check out:

This is a super tutorial

Craig Dunn's blog contains some very helpful posts:

Another blog/tutorial

Not monotouch, but useful for that real deployment stage,,,

StackOverflow is always a good place:
e.g. look at this level of info for writing a file - http://stackoverflow.com/questions/1829954/write-to-a-file-in-monotouch

Not monotouch, but for testing apps, this looks interesting:

Monday, January 11, 2010

A really good guide to url rewrite rules

Coupling an indecipherable language (regex) with a few flags to achieve lots of unexpected effects...

http://articles.sitepoint.com/article/guide-url-rewriting

Mainly posting this here as I keep hitting snags with my Wordpress MU installation on IIS

Tuesday, January 05, 2010

Setting up wordpress MU to work with authenticated SMTP Mail Server


I really don't like having sendmail running on a webserver, but some features of WordPressjust don't work if it can't send email (user registration, for example). Still, WordPress offers support to send email through external SMTP servers instead if a local mailer.

In /wp-includes/pluggable.php around line 377, change

 	$phpmailer->isMail();

to

 	$phpmailer->isSMTP();

Then, in /wp-includes/class-phpmailer.php around line 155, set your SMTP host:

     var $Host        = "my.smtphost.com";

You may also need to set a username and password, and tell WP to attempt authentication. You'll see those in the lines below the hostname variable.

     var $SMTPAuth     = true;     var $Username     = "username";     var $Password     = "password";

On the other hand, you could do this via a plugin, perhaps even Callum McDonald's WP MailSMTP.


For my redfoxhosting hosted SMTP server, the settings were:
true
password

Easy (but took 4 go's to get right!)

Thursday, December 17, 2009

YQL, Pipes and beyond

I've recently fallen in love with Yahoo again

Inspired by Haayman (a runsat user) I've been using Yahoo pipes to manipulate the site RSS output into more human friendly form.

The latest bit of this is here: http://pipes.yahoo.com/runsaturday/osmfeed -


Inspired by http://blog.pipes.yahoo.net/2009/06/01/using-yql-execute-to-power-the-pipes-webservice-module/ this pipe just shows how developed the web is now...

- it gets data from runsat
- processes that data
- makes a call to YQL which then processes the data through this serverside javascript - http://www.slodge.com/yql/pipe5.xml (this converts a google maps API
- processes the data some more
- spits out some new RSS which can then be consumed by web pages - e.g. by http://hollybar.blogspot.com

Of course, all of this could also be seen as fragile - it relies on external web services, but these are all on Yahoo! - so not too fragile (I hope!).

The programmable web - I love it!

Sunday, December 13, 2009

More player code live on runsaturday

A "simple" player:









A player with side map and elevation/speed chart:



Tuesday, November 17, 2009

"The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."

If you're working late at night and suddenly you start seeing lots of https issues concerning... "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."

Then it might just be because your app is routing its requests via the excellent fiddler2 - in which case SSL will not be trusted :)


Monday, November 16, 2009

Hard disk thrashing on Vista

I've been struggling recently with far too much hard disk thrashing.

So I searched around for help, and I've no idea if their advice helps yet, but this article seemed at least well written:
http://bucarotechelp.com/computers/windowsts/95021801.asp?x=62&y=6&page=1

Let's hope it helps - because recently the hard disk action has been way too slow!

Super easy to use (and free) POP3 email client source code

Really good project!
http://www.codeproject.com/KB/IP/Pop3MimeClient.aspx?fid=341657

Super easy to follow walkthrough for creating a custom DNN scheduled task

Super easy to follow walkthrough for creating a custom DNN scheduled task -

Really good stuff