Koni

Another “girl playing guitar” video I wanted to share, or maybe just save it here since it’s old, about 5 years old, but I still like it a lot. The girl’s name is Koni.

Beijing subway singer

Something I liked and would like to share with everyone else.

Firefox Live Bookmarks Feed Refresh Frequency

The default rate of Firefox Live Bookmark refresh is 30 minutes. Which is often too long for some people. This can be changed:

Enter about:config in the url location bar and hit enter.
Right-click anywhere within the list of preferences and select New -> Integer.

When you get asked to enter the preference name, enter:
browser.bookmarks.livemark_refresh_seconds

You will then be asked to enter a value.  Set the value to whatever refresh rate you’d like. The unit for the value is seconds, so if you wanted the refresh rate to be 5 minutes, the value would be 300 (as in 300 seconds). The minimum is 60 seconds, so if you enter anything less than 60, it will still default to 60 internally.

Be careful when you set the rate too low, sites such as slashdot will refuse your request if you set the rate to 60 seconds. To be safe, I think 300 is a good value.

Random Microsoft Rant

I don’t hate Microsoft, I have been using windows since the Windows 3.1 era, along with other microsoft products. But sometimes the small things that Microsoft choose to do simply piss me off so much that I have to write about them here:

1. Who is the genius that thought it was a good idea to have the system automatically reboot after an automatic system update? This problem exists in both XP and Vista. Have you ever thought about maybe, just maybe even if I’m not physically in front of the computer, my computer could still be running some important application or contain unsaved work??? There isn’t even an option to change this behavior. I had to manually edit some registry setting or group policy to disable this extremely annoying behavior. You know what kind of program reboot the user’s computer without the user’s permission? a virus!

2. This problem is vista only. In windows explorer, when I copy a bunch of files to another directory, they become automatically resorted! This becomes a problem if the folder I copy to already contain a bunch of files, then I would easily lose track of the new files I copied. Now, I can see some people might want this behavior, but when you make such a major change, I would appreciate it if you would at least give me an option to turn this off. So far there isn’t even a solution to allow me to change this behavior to XP style (new files always are at bottom until refreshed).  I almost switched back to XP just for this. It is very frustrating.

3. Vista home edition does have a RDP (Remote Desktop) client, but again some genius at Microsoft decided to hide the icon from the menus. To run the RDP client, simply run “mstsc.exe”. I can’t imagine what is the reason to hide this from us home edition users?

4. No “group policy editor” (gpedit) for home edition users. Gpedit is such a useful system configuration tool, it would be a crime to not include it for home edition users.  It’s like not including a “preferences” screen in a software product.

How to really disable event firing in sharepoint

One of the things I found out the hard way while programming event handlers in sharepoint is that you have to wrap your update() or delete() functions with the disableeventfiring function individually, for example:

this will work:
base.DisableEventFiring();
item.update();
base.EnableEventFiring();

this will NOT work:
base.DisableEventFiring();
item.update();
item.delete();
base.EnableEventFiring();

So the moral of the story is, only do one event triggering action at a time, do not try to do 2 or more within one wrapper.

How to add or remove permissions to a list item in sharepoint

Ok here is how I add or remove or copy permissions to a list item in sharepoint:

1 if (properties.ListTitle.Equals(“Document Library”))
2 {
3 using (SPWeb objWeb = properties.OpenWeb())
4 {
5 SPListItem d_item = properties.ListItem; //this is the one I want to copy permission from
6 SPRoleAssignmentCollection roles = d_item.RoleAssignments;
7 SPListItem item = myFile.Item; //this is the one I want to copy permission to
8 item.BreakRoleInheritance(true); //you must set this to true or it wouldn’t work
9 while (item.RoleAssignments.Count > 0)
10 {
11 item.RoleAssignments.Remove(0);
12 }
13 foreach (SPRoleAssignment role in roles)
14 {
15 item.RoleAssignments.Add(role);
16 }
17 base.DisableEventFiring();
18 item.Update();
19 base.EnableEventFiring();
20 }
21 }

How to customize the item edit form in sharepoint designer

I needed to customize the item edit / display / new form to remove some fields from the form. In SPD you can not convert the edit form to XSLT dataview. What you have to do is:

1. Hide the default form: Select the ListFormWebPart, right click and select web part properties. Go to layout and check hidden.
2. Insert your custom form: Click on an empty area so nothing is selected. Then go to Insert->Sharepoint controls->Custom List form, then select the list you are modifying and select the type of form. Now you can modify or delete any field!

How to Add, Remove, Manage List Columns in SharePoint Designer

To Add/Remove/Manage columns in sharepoint designer(SPD), first open up the site in SPD then open up the view’s aspx file. In design mode, right click on the DataFormWebPart and select “convert to XLST data view”.

Now you should have a “Common data view tasks” popup, if not, just click on the arrow to the right. You could then select “edit columns”. Now you will be able to add/remove/manage columns in SPD! Save the file when you done and your sharepoint site will be automatically updated with the new columns.

Int32.Parse Versus Convert.ToInt32 in SharePoint

Today I found out the hard way that SharePoint doesn’t like the function Int32.Parse. I spent several hours trying to debug my code, then finally come to the conclusion that by using Int32.Parse to convert a int to string, it mysteriously prevents execution of everything that follows this line (although this compiles perfectly in VS2008).

The SharePoint correct way to convert int to string is to use the function Convert.ToInt32(myString), btw Convert is also faster than Parse, so I recommend everyone to stop using Parse and use Convert instead even if it is not sharepoint.

Sharepoint Document Library Mass Upload Tool

This is a tool written by Stuart Preston to enable us to mass upload files, folders and sub-folders into our sharepoint document library. The tool will automatically create the folders in sharepoint. There is no limit on the number of documents you could upload.

Download SPBulkUpload

How to use:
1. Extract the zip file, this is actually a Visual Studios project with source code.
2. To start using the tool, copy the Conchango.Sharepoint.Utilities.BulkUpload.exe file from /bin/Debug folder to your C:\ root folder and rename it to something shorter like “spbulk.exe”.
3. Open up command prompt (Start->Run->cmd)
4. type: C: to go to your C:\ root
5. type: spbulk “c:\source folder” “http://webapp/site/target/document_library”
(replace the source folder and destination with your actual folder and site url)
6. Wait for the tool to finish.