Monday, October 10, 2011

Facebook–how to set the height of your tab

Today I had to set to more than 800 pixels the height of my tab. I found here a simple solution, thanks a lot to Amit Jain.

Steps in brief:

  1. in the app “canvas settings” set the height to “Settable”, like in the image shown below.
  2. add to the <body> line: style="overflow: hidden" (to remove the scrollbars)
  3. add to your main <div> (the one that contains your html) the style: style="height:2000px; width:520px;" – obviously you will set your desired height
  4. finally, just below the <body> tag, add this code:

<div id="fb-root"></div> 
<script> 
  window.fbAsyncInit = function() { 
FB.Canvas.setAutoResize(); 
  }; 
  (function() { 
var e = document.createElement('script'); e.async = true; 
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; 
document.getElementById('fb-root').appendChild(e); 
  }()); 
</script>
 

that’s it – worked for me!

2011-10-10_1630

Monday, September 05, 2011

Windows Phone traffic on Fiddler? Here’s how

Yes, it’s possible, and there is a fantastic page that explains how, here’s the link.

All the configuration needed took a couple minutes, and it worked perfectly.

Thanks Eric for this great article!

Thursday, September 01, 2011

Sql Server–find some texts in Stored Procedures

I often need to search for some texts in the body of stored procedures. This query can help:

SELECT routine_name, routine_definition
FROM information_schema.routines
WHERE UPPER(routine_definition) LIKE UPPER('%texttobesearched%')
AND routine_type='procedure'

EDIT: just discovered that this method has some problems with long stored procedures; found another one that works better:

declare @searchString varchar(100)

Set @searchString = '%' + 'text to be searched' + '%'

SELECT Distinct SO.Name
FROM sysobjects SO (NOLOCK)
INNER JOIN syscomments SC (NOLOCK) on SO.Id = SC.ID
AND SO.Type = 'P'
AND SC.Text LIKE @searchString
ORDER BY SO.Name

Wednesday, August 31, 2011

Windows Phone 7 - NavigateToString, WebBrowser, and anchors

I needed to show some html in a page, using a WebBrowser control and the NavigateToString method.

The html was ok; it has some anchor in it to move from a section to another.

When I tested it in a standard web browser, or loading it with the phone IE9, worked perfectly.

But when I loaded the same html in the app page, using as I said the Navigatetostring method, the anchors didn't work anymore.

Then I tried to use some javascript to move to the anchors, using location.replace(#anchorname) – but again when I tested the html outside the app it worked… but not in the app.

I posted the question to the MSDN Forums, end Eric Fleck suggested me to use another approach, while confirming that the wrong behavior is in the latest RC of the WP7 tools.

The new approach is described in detail in this MSDN page, and basically uses IsolatedStorage to save the html fragments in order to load them in the WebBrowser using the .Navigate method. This way all the anchor links work… and I’m happy Sorriso

G’day everybody!

Tuesday, August 23, 2011

Some “metro style” windows phone backgrounds

Found today: I like these backgrounds, see if you like them:

- Metro Lock for Windows Phone

- Metro Lock 2 for Windows Phone

A couple images, in Mango Occhiolino flavour:

Metro Lock (Mango)Metro Lock 2 (Mango)

Windows Phone 7 – Mango time

Today I uploaded my first Mango update. My “Fatto Quotidiano” app now id 7.1 compatible!

To celebrate this I also rewdesigned completely the layout, now the app is more readable, I think that it’s really better than before.

A couple of useful links / resources:

- To download the Windows Phone SDK 7.1 Release Candidate go here: SDK 7.1 RC

- With the RC you will also have at your disposal a great tool: the “Marketplace Test Kit”, integrated with Visual Studio. The tool “provides a suite of automated, monitored, and manual tests to help make sure that your applications are accepted in the Marketplace the first time you submit them”. Read about it here.

To see the list of my WP7 apps, click here

Wednesday, March 23, 2011

Sql Server Management Studio & “WTF”

Open Sql ServerManagement Studio, Open a New Query, Type WTF and press Enter.

Have fun.

Saturday, February 26, 2011

Some WP7 apps

ilomilo got a new refresh, a whole bunch of new puzzles to solve! great game - check this link: http://blog.ilomilo.com/2011/02/ilomilo-windows-phone-7-title-update/

Yelp! is available on the italian marketplace - http://officialblog.yelp.com/2010/11/yelp-gets-a-windows-phone-7-app.html

Resco Radio is a really good internet radio manager – check out this link http://wmpoweruser.com/resco-radio-for-windows-phone-7-preview/

Birdsong is my favorite Twitter client, in the next days the 1.2 release will be out, http://red-badger.com/Blog/

Friday, February 25, 2011

Mail in spam? Try (also) this…

Recently some messages from one of my site started being marked as spam by gmail and others.

The particular message is the “confirm registration” one, and it’s easy to understand that it’s imperative that it does not go to the spam folders… if you want regitered users, I mean.

I noticed that in the standard routine that we use to send mail messages there was no setting for the “Message-ID” header. I tried to add it (see below a code sample) and now the “marked as spam” rate is incredibly low!

See here (Wikipedia) a brief explanation of what the particular Message-ID header field is.

Here is the code sample, in bold the three new lines:

private bool PrepareAndSendMail(string emailKey, string senderName, string senderEmail, string destName, string destEmail, StringDictionary args)
{
    try
    {
        MailMessage m = new MailMessage();

        m.From = new MailAddress(senderEmail, senderName);
        m.To.Add(new MailAddress(destEmail, destName));
        m.Subject = MailSettings.Emails[emailKey].Subject;

        // this is to limit the "marked as spam" messages
        Guid messageGuid;
        messageGuid = Guid.NewGuid();
        m.Headers.Add("Message-ID", messageGuid.ToString());

        m.IsBodyHtml = true;
        m.BodyEncoding = Encoding.GetEncoding("iso-8859-1");
        m.Body = ReadTemplateFromFile(Globals.MapPath(MailSettings.Emails[emailKey].Template), args);

        return SendMail(m);
    }
    catch (Exception ex)
    {
        Log.Error("An error occurred sending mail", ex);
        return false;
    }

}