LEGO Self-balancing Robot – Segway Type

Thanks Laurens Valk’s article I made my first self-balancing robot with using LEGO Mindstorms EV3. I made some small change on the original robot structure and program to match my design, which has only single motor and two wheels. It can be IR controlled to move forward and backward, but it cannot steer (of cause it cannot!). Other motors are in another project so that is why this robot is like this.


Capture screen under Mac OS with Mono Development

I am doing a project that need to capture screen of Mac OS through Mono Development. I found a post in stackoverflow described same thing as I want to do. The OP in the post said he is failed to do that. Someone replied that the posted code only worked under Linux but not Mac OS. However I tried to use same code in my project and it is succeeded. Below is a screenshot I took. Not sure why. My Mac OS: 10.9, Mavericks.


Below is the code

Gdk.Window window = Gdk.Global.DefaultRootWindow;
if (window!=null)
    Gdk.Pixbuf pixBuf = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, window.Screen.Width, window.Screen.Height);
    pixBuf.GetFromDrawable(window, Gdk.Colormap.System, 0, 0, 0, 0, window.Screen.Width, window.Screen.Height);
    pixBuf.ScaleSimple(400, 300, Gdk.InterpType.Bilinear);
    pixBuf.Save("screenshot0.jpeg", "jpeg");

I tried to reply same as above to the stackoverflow post, but it has been deleted because “it is no helpful to resolve this issue”. 😦

Fix “Unable to find the default edit form for list” programmatically without SharePoint Designer

Sometime you may meet an error when you add new item or edit item properties. A yellow screen is showing like below, or, a standard SharePoint error window popped up and said “Unable to find the default edit form for list (listname)”.


Mostly that is the edit form (or add item form) has been deleted. However, sometimes the form still there but it becomes blank page. The form can be access by the url /{your list}/Forms/EditForm.aspx


And you will find the DefaultEditFormUrl property of this list is empty. An error will occurred if you try to set this property to the existing form page via PowerShell. The error saying “Unable to find an SPForm matching URL”


All above is saying same thing: the data form web part in this form has been deleted.

The easiest way to fix this issue is use SharePoint Designer to fix the form or recreate a form. However, sometimes we cannot do that because the environment doesn’t allow SPD connection for some reason, mostly because security. We have to find another way.

Thanks two good posts SharePoint 2010 Create and Update List Forms Programmatically and SharePoint 2010 – Add custom list form to existing list, I created a PowerShell script to fix this issue without SharePoint designer.

$web = get-spweb yoursiteurl
$list = $web.Lists[yourlistname]
$rootFolder = $list.RootFolder;
$formFolder = $rootFolder.SubFolders["Forms"]
$editForm = $formFolder.Files["EditForm.aspx"]
$manager = $editForm.GetLimitedWebPartManager(1)

$newWebPart = new-Object Microsoft.SharePoint.WebPartPages.ListFormWebPart
$newWebPart.ListId = $list.ID
$newWebPart.ListName = $list.ID.ToString("B").ToUpper()

#set the page type. 6: Editform, 8: Newform, 4: Displayform
$newWebPart.PageType = 6
$newWebPart.Title = $list.Title
$newWebPart.Description = $list.Description
$newWebPart.CatalogIconImageUrl = $list.ImageUrl
$newWebPart.TitleUrl = $list.DefaultViewUrl

#this is very important that implement the web part with IListWebPart interface. If not do that the web part and form will not be identified by SP as an available form
[Microsoft.SharePoint.WebPartPages.IListWebPart]$part = $newWebPart

$manager.AddWebPart($part, "Main", 0)
$part.ShowToolbarWithRibbon = $true

$list.DefaultEditFormUrl = $web.ServerRelativeUrl + "/" + $rootFolder.Url + "/Forms/EditForm.aspx"

After run this script, your edit form is come back.


Enjoy it!