Thursday, 13 January 2011

Access Facebook from VietNam



Option 2: Edit windows hosts file
- Use notepade, open hosts file at C:\Windows\System32\drivers\etc
- Add following IPs:


125.252.224.88 www.facebook.com
69.63.181.12 apps.facebook.com 
153.16.15.71 www.facebook.com
153.16.15.71 register.facebook.com
153.16.15.71 www.logins.facebook.com
153.16.15.71 facebook.com
153.16.15.71 blog.facebook.com
153.16.15.71 logins.facebook.com
153.16.15.71 login.facebook.com
153.16.15.71 apps.facebook.com
153.16.15.71 upload.facebook.com
153.16.15.71 graph.facebook.com
153.16.15.71 photos-a.ak.fbcdn.net
153.16.15.71 photos-b.ak.fbcdn.net
153.16.15.71 photos-c.ak.fbcdn.net
153.16.15.71 photos-d.ak.fbcdn.net
153.16.15.71 photos-e.ak.fbcdn.net
153.16.15.71 photos-f.ak.fbcdn.net
153.16.15.71 photos-g.ak.fbcdn.net
153.16.15.71 photos-h.ak.fbcdn.net
153.16.15.71 static.ak.connect.facebook.com
153.16.15.71 static.ak.fbcdn.net
153.16.15.71 b.static.ak.fbcdn.net
153.16.15.71 error.facebook.com 
153.16.15.71 developers.facebook.com 
153.16.15.71 pixel.facebook.com
153.16.15.71 api.facebook.com
153.16.15.71 chanel.facebook.com
153.16.15.71 0.50.chanel.facebook.com
153.16.15.71 external.ak.fbcdn.net
153.16.15.71 profile.ak.fbcdn.net
153.16.15.71 creative.ak.fbcdn.net

Wednesday, 12 January 2011

Remove Bad Web parts from SP Pages

SP Developers often run into issue where their deployed web part has problems, the page refuses to load. How can developer can remove those "bad" web parts from the page when the actual page does not load? The solution is simple enough, just add ?Contents=1 to the URL, it will take you to Web Part Maintenance page, where you can easily remove those bad guys

http://server/SitePages/Home.aspx?Contents=1  will take you to followng screen:

Log4net and you

SharePoint Developers often need to add logging capability to their code. Here are the easiest steps that will add log4net to your web part on local SP Development machine

1) Download log4net, extract to some folder on your computer
2) Deploy log4net to your GAC
3) In your SP project, Add reference to log4net
4) Add this line at the end of your Assemblyinfo.cs
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
5) Use log4net in your code
private ILog _log = LogManager.GetLogger(typeof(VisualWebPart1UserControl));
protected void Button1_Click(object sender, EventArgs e)
{
string s = DateTime.Now.ToString();
Button1.Text = s;
_log.InfoFormat("*** Server time: {0}", s);
}
6) Modify web.config of the target Web Application

<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
    <appender name="OutputDebugStringAppender" type="log4net.Appender.OutputDebugStringAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
      </layout>
    </appender>
    <appender name="FileAppender" type="log4net.Appender.FileAppender">
      <file value="log-file.txt" />
      <appendToFile value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
      </layout>
    </appender>
    <root>
      <level value="INFO" />
      <appender-ref ref="OutputDebugStringAppender" />
      <appender-ref ref="FileAppender" />
    </root>
  </log4net>

</configuration>

7) Use DebugView to view log messages live

Saturday, 1 January 2011

Start Stop SharePoint 2010 services

You may have known that developing SharePoint 2010 on local developer workstation (Win 7) is possible. Then it comes to a need to save RAM for other applications when you are not actively working with SharePoint coding. The best set up for my case is as follow:

  1. Set SharePoint related services start up type to Manual
  2. Start / Stop those services when needed

For this kind of set up, I've run across Emmanuel's blog. The steps are well explained and the PowerShell scripts work nicely. Check it out, sure you will need it sometime.

The scripts