Blog
Articles, code snippets and news worth sharing.
Posts
A PowerShell script that finds every user in Active Directory, adds them to a SharePoint 2010 group and syncs their profile details.
$spgroupname = "Group Name"
$sitename = "http://sitename"
$domain = $env:USERDOMAIN
$spsite = New-Object Microsoft.SharePoint.SPSite($sitename)
$rootweb = $spsite.RootWeb
1 min read#PowerShell#SharePoint 2010
Run code when a popup window opened with window.open is closed, using the onbeforeunload event.
var popupWindow = window.open(url);
popupWindow.onbeforeunload = function() {
//Do processing
return null;
1 min read#JavaScript#jQuery
Remove duplicate strings from a List in C#, the old way with Sort and RemoveAt and the shorter way with Distinct.
List<string> strlist = new List<string>();
//Fill the list with random values
strlist.Sort();
Int32 index = 0;
while (index < strlist.Count - 1)
{
1 min read#.NET#C#
A simple XOR based encrypt and decrypt routine in JavaScript, for demonstration only.
function Encrypt()
{
var actual = "stringtoencrypt";
var key = 100; //Any integer value
var result = "";
for (var i = 0; i < actual.length; i++)
1 min read#JavaScript#jQuery
Convert a textarea into a rich text editor with TinyMCE, a JavaScript HTML WYSIWYG editor.
2 min read#JavaScript#Tools
Build a cascading dropdown in ASP.NET with jQuery and a page method: pick an author and the books drop down fills in.
2 min read#ASP.NET#C##jQuery
Use LINQ GroupBy to count how many times each value appears in an integer array.
private Dictionary<int, int> GetArrayDuplicates(int[] arrayToSearch)
{
Dictionary<int, int> counts = arrayToSearch.GroupBy(arrayItem => arrayItem)
.ToDictionary(groupedItem => groupedItem.Key,
groupedItem => groupedItem.Count());
return counts;
1 min read#.NET#C#
Two ways to start a C# application automatically at Windows startup: the Startup folder or a Run registry key.
private void RegisterStartupApplication()
{
RegistryKey regKey = Registry.CurrentUser.OpenSubKey
("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
regKey.SetValue("MyApplicationsName", Application.ExecutablePath);
}
1 min read#C##Windows
Minimise all windows from C#, the same as clicking Show Desktop on the taskbar, using the Shell32 COM library.
Shell32.ShellClass shell = new Shell32.ShellClass();
shell.MinimizeAll();
1 min read#C##Windows
Fix Visual Studio 2010 not reopening your documents from the last session by resetting all settings.
1 min read#Tools#Visual Studio
Read the default Outlook contacts folder from C# using the Outlook interop assembly and return them as a DataSet.
using Microsoft.Office.Interop.Outlook;
1 min read#C##Office
I received the 2012 Microsoft MVP Award for contributions in Visual C# technical communities.
1 min read#C##Tools