Category Archive: Programming

Oct 05

How can I quickly sort characters in a string?

string word = "cab"; string sorted = string.Concat(word.OrderBy(c => c));

Oct 12

How can I delete records from MS SQL Server database using Python?

The following code will delete all records from table in database on server. import win32com.client connectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=database;Data Source=server;" query = "delete from table;" con = win32com.client.Dispatch(‘ADODB.Connection’) con.Open(connectionString) con.Execute(query) con.Close( ) Note: This code works on Windows only. You will also need to install excellent Python for Windows extensions (pywin32) by …

Continue reading »

Sep 28

How can I restart Windows service with Python?

First you need to install excellent Python for Windows extensions (pywin32) by Mark Hammond from Then you can use the following code (that will restart the Print Spooler service). import win32serviceutil serviceName = "spooler" win32serviceutil.RestartService(serviceName) Note: this code was tested with Python 2.7 and version 216 of the pywin32 extensions.

Feb 03

How can I get application’s directory in a WPF application?

string appPath = AppDomain.CurrentDomain.BaseDirectory;

Jan 26

Cannot convert lambda expression to type ‘string’ because it is not a delegate type

When you get the “Cannot convert lambda expression to type ‘string’ because it is not a delegate type” error in Visual Studio 2010, all you have to do is add using System.Linq; to the top of the source file.

Jan 20

Unhandled Error in Silverlight Application 2104

When you get the error  Message: Unhandled Error in Silverlight Application Code: 2104 Category: InitializeError Message: Could not download the Silverlight application. Check web server settings when you try to deploy your Silverlight application you have to register MIME type in your IIS 7: Extension: .xap MIME Type: application/octet-stream At least that is what it …

Continue reading »

Dec 28

Look What I Found #5

PDFsharp: .NET library for creating and processing PDF documents on the fly. SSH.NET: .NET 4.0 library for SSH client protocol. MailSystem.NET: suite of .NET components with support for SMTP, POP3, IMAP4, NNTP, MIME, S/MIME, OpenPGP, DNS, vCard, vCalendar, Anti-Spam (Bayesian , RBL, DomainKeys), Queueing, Mail Merge and WhoIs. Json.NET: makes working with JSON formatted data …

Continue reading »

Dec 06

How can I tell if Silverlight application is running out of browser?

Application.Current.IsRunningOutOfBrowser indicates whether application was launched as an out-of-browser application. Application.Current.HasElevatedPermissions indicates if application is running as an out-of-browser application with elevated permissions. Elevated permissions give you direct access to clipboard, user folder and COM enabled applications.

Oct 22

Code Kata

A code kata is an exercise in programming which helps hone your skills through practice and repetition. Here is a list of some of code katas I found: How to Become a Better Programmer Project Euler: Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to …

Continue reading »

Oct 22

Look What I Found #4

Aspect Ratio Calculator: Useful, for example, when resizing images. ExtensionMethod.NET: Database of C#, F# and Visual Basic extension methods. Use attribute to omit code from coverage analysis in Visual Studio AvalonEdit: Extensible open-source text editor with support for syntax highlighting and folding. Fillerati: Generator for filler text that uses excerpts from the works of famous …

Continue reading »

Older posts «