David Cumps
#region .Net Blog
-
Different Actions - Same Result
This post has moved to http://blog.cumps.be/different-actions-same-result/ trying to spark some feedback with additional question.
-
BENUG Test Driven Development Session - TestDriven.NET
Today I went to a BENUG session about test driven development, and I finally got NUnitAddin to work ;)
A small recap of today:- Get TestDriven.NET-0.9.615d.msi, this includes MbUnit along with NUnitAddin already setup to work with MbUnit. No more need to edit that config file yourself. The future testing tool is TestDriven.NET ;)
- Reference Core, Framework and TestFu in your project.
- Add [TestFixture] as attribute to your class.
- Add [Test] as attribute to a method.
- Right click somewhere in the class and Run Tests, to run them all, or right click in one method to only run that one.
- Watch the Output window display success or failed, and display the report url at the end.
- CTRL+Click the url to see a detailed report (view example).
Note:
If you have installed csUnit, leave it installed! Do NOT uninstall it unless you are good enough informed about the uninstall possibly fucking up your VS.NET installation. I uninstalled it today, and poof, adding classes and everything else trough VS.NET was broken, solution, Repair VS.NET :( -
Add IE Features - New keywords (yeah, the ones Firefox users are so proud of)
Right, someone trying to convince me why Firefox is so much better than IE brought up the issue of being able to type "google searchterm" into his Adress bar and immediately being taken to the site.
Well, here's some news: IE can do that to, along with imdb, whois, vandale, php and everything else that uses parameters as query terms.
How? Look at this registry key and see the light:
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\SearchUrl\google]
@="http://www.google.com/search?q=%s"
" "="+"
"%"="%25"
"&"="%26"
"+"="%2B"
%s is where your search term comes, and the name of the key is the prefix.
Another example to get the hang of it:
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\SearchUrl\imdb]
@="http://us.imdb.com/Find?%s"
" "="+"
"%"="%25"
"&"="%26"
"+"="%2B"
Got it? Sweet, enjoy your new IE power! ;)
I have uploaded a .reg file which contains altavista, astalavista, cd, download, google, googlenl, imdb, php, sub, vandale, vcd, whois and lucky as search terms. Feel free to invent more :)
Update: Google feeling lucky keyword.
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\SearchUrl\lucky]
@="http://www.google.com/search?q=%s&btnI=I%27m+Feeling+Lucky"
" "="+"
"%"="%25"
"&"="%26"
"+"="%2B" -
The Invisible Administrator
Today something very weird happened and I doubt something this weird will ever happen again.
I was working on a site at school when I browsed to a file-server to check some paths, and to my surprise I could suddenly access ALL shares, not only the ones for students, but all of them...
When I tried creating files they got made under BUILTIN\Administrators! But I was logged on with my own student account. So, being nice and all, I reported it...
Then we spent almost entire afternoon trying to determine why I was suddenly an admin.
And this is when the weird stuff started to happen:
On PC1 I was an admin on the server, but when I logged in to PC2 I couldn't access it.
We tried different student accounts on PC1 but they also couldn't access the shares.
Then we removed all groups from my account except Domain Users, and I still could get in.
We cleared the profiles from PC1 and 2 and also deleted my roaming profile.
Nothing changed...
First conclusion: It's tied to username X and PC1, examine PC1 later.
Then we go to another room and try it on different computers. And there it starts all over again.
PC3: I'm an admin, PC4: I'm not.
In the end we checked all groups I belonged to, and their membership, deleted my profile, checked all NTFS permissions (which I could change as well..), and nowhere there was a trace of me or any groups I belonged to. Nothing had admin rights.
We forced replication to make sure I was group-less but it still worked!
Conclusion: User X has the rights of an Admin, but does NOT show up in any group, NTFS permissions or anything else...
Solution: We disabled the account and created a new account.. (Which means I have to recreate my entire profile again...)
Has anyone else every encountered this, and found out why this was happening? -
Six Invites to the Most-Hyped-Mail-Service-Of-The-Year, aka GMail
Ah, well, 11 blog posts on a day is fine as well :p
With all those people giving away GMail accounts, I got 6 as well.
I got one someday, never used GMail, but hey, I can give them away.
There's too much hype around it, and I'm really not into webbased mail when I just can read it from Outlook.
But anyway, if you want one, it seems I have to supply a First and Last name and an email adress, so, the first 6 people who supply them in the comments get an invite.
Update: I just got 5 more invites, will update post when they're all given out...
Update2: All gone, closing comments -
Fix Outlook Contacts Phone Number "+32" with C#
I own a Sony Ericsson T630 and manage my contacts with Outlook trough Bluetooth.
This has the side side-effect that I finally started adding everyone I might need to contact to my Contacts, before that I just picked an email and used the Reply-To ;)
But there is one thing that bothers me, I store my numbers in international format (eg: +32 50 .....), but Outlook always removes the + in front of it, and I can't find how to change that. And my phone needs the +!
So I wrote a C# tool that would let me fix my contacts.
You can download it here and read the full article here. -
Fix Outlook Contacts Phone Number "+32" with C#
I own a Sony Ericsson T630 and manage my contacts with Outlook trough Bluetooth.
This has the side side-effect that I finally started adding everyone I might need to contact to my Contacts, before that I just picked an email and used the Reply-To ;)
But there is one thing that bothers me, I store my numbers in international format (eg: +32 50 .....), but Outlook always removes the + in front of it, and I can't find how to change that. And my phone needs the +!
So, let's write a tool to fix this.
First we need a reference to Outlook. So add a reference to 'Microsoft Outlook 11.0 Object Library' (or 10.0, if you use 10.0 leave a comment if this source worked for you!)
When you did this you'll have two new reference, just remove the Office Core... so that you have something like this:
Our application has a very simple logic, where the Main controls it all.1using System;
First we get the folder where our Contacts are stored.
2using System.Text.RegularExpressions;
3using System.Collections;
4using System.IO;
5using System.Diagnostics;
6using Outlook = Microsoft.Office.Interop.Outlook;
7
8namespace FixContacts {
9 class FixContacts {
10 static void Main(string[] args) {
11 // TODO
12 }
13 } /* FixContacts */
14} /* FixContacts */1 //string contactFolder = @"Cumps David\Contacts";
Then we open Outlook and get the folder.
2 Console.Write("Contact Folder: ");
3 string contactFolder = Console.ReadLine();1 Outlook._Application appOutlook = new Outlook.Application();
When we have the contact items, we loop over everyone of them, checking if there is a number to be fixed.
2
3 Outlook.NameSpace olNS = appOutlook.GetNamespace("MAPI");
4 olNS.Logon("", null, null, null);
5
6 Console.WriteLine("Searching Folder...");
7 Outlook.MAPIFolder olContactFolder = GetFolder(contactFolder);
8 Outlook.Items olContactItems = olContactFolder.Items;1 Console.WriteLine("Fixing Phone Numbers...");
Finally, we clean everything up.
2 foreach(Outlook.ContactItem olContact in olContactItems) {
3 CheckNumbersToReplace(olContact);
4 }1 olNS.Logoff();
First the GetFolder method. This will get us our folder we specified with a path.
2
3 olContactItems = null;
4 olContactFolder = null;
5 olNS = null;
6 appOutlook = null;
7 Console.WriteLine("Done");
8 Console.ReadLine();
Again we open Outlook. Then we split the path into the corresponding folders and we look for the root folder.1Outlook._Application appOutlook = new Outlook.Application();
When we have found our root folder, we will look for our first folder and when we find it, we replace our parent object by that folder and go looking for the next folder.
2Outlook.NameSpace olNS = appOutlook.GetNamespace("MAPI");
3olNS.Logon("", null, null, null);
4
5Outlook.MAPIFolder olFolder = null;
6folderPath.Replace("/", @"\");
7string[] arrFolders = folderPath.Split('\\');
8
9foreach (Outlook.MAPIFolder olTmpFolder in olNS.Folders) {
10 if (olTmpFolder.Name == arrFolders[0]) {
11 olFolder = olTmpFolder;
12 break;
13 }
14}1if (olFolder != null) {
And in the end we return our found folder after cleaning up.
2 for (int i = 1; i < arrFolders.Length; i++) {
3 Outlook.Folders olFolders = olFolder.Folders;
4 olFolder = null;
5
6 foreach (Outlook.MAPIFolder olTmpFolder in olFolders) {
7 if (olTmpFolder.Name == arrFolders[i]) {
8 olFolder = olTmpFolder;
9 break;
10 }
11 }
12 olFolders = null;
13 }
14}1arrFolders = null;
Now the CheckNumbersToReplace method, this is a simple one.
2olNS = null;
3appOutlook = null;
4return olFolder;
We create an ArrayList where we will add every phone number in the contact that starts with our contry prefix.1 private static void CheckNumbersToReplace(Outlook.ContactItem vContact) {
Next we check every phone entry if it contains the prefix. (I only show one of them now)
2 ArrayList phoneNumbers = new ArrayList();
3 string countryPrefix = "32";1 if (vContact.HomeTelephoneNumber != null) {
When we looked over all phonenumbers, we will build a new vCard with the correct information in it, that is, our numbers prefixed with a +.
2 string phoneNumber = vContact.HomeTelephoneNumber;
3 if (phoneNumber.Substring(0, 2) == countryPrefix) { phoneNumbers.Add(phoneNumber); }
4 }1 if (phoneNumbers.Count > 0) {
As you can see, we create a temporary vcard for this, and then launch it, you only have to press Save on it, and it's saved. As this is just a personal tool I didn't have the time or requirement to look into automatically saving it. In the end we delete the temporary file.
2 string vCardLocation = "";
3 Outlook.MailItem vCardMail = vContact.ForwardAsVcard();
4 Outlook.Attachments vCardArray = vCardMail.Attachments;
5 foreach (Outlook.Attachment vCard in vCardArray) {
6 vCardLocation = Environment.CurrentDirectory + @"\" + vCard.FileName;
7 vCard.SaveAsFile(vCardLocation);
8 foreach (string phoneNumber in phoneNumbers) {
9 FixNumber(vCardLocation, phoneNumber);
10 }
11 }
12 vContact.Delete();
13 Process launchvCard = new Process();
14 launchvCard.StartInfo = new ProcessStartInfo(vCardLocation);
15 launchvCard.Start();
16 launchvCard.WaitForExit();
17 File.Delete(vCardLocation);
18 }
The FixNumber method is a simple search and replace in the vCard file.1 private static void FixNumber(string vCardPath, string phoneNumber) {
And that is our FixContacts utility. It opens the contact dir, scans the contacts, check for phone numbers and fixes them if necessary and pops them up with the correct information, after which you only have to press Save.
2 if (File.Exists(vCardPath)) {
3 StreamReader readvCard = File.OpenText(vCardPath);
4
5 string vCard = readvCard.ReadToEnd();
6 readvCard.Close();
7 vCard = vCard.Replace(phoneNumber, "+" + phoneNumber);
8
9 StreamWriter writevCard = File.CreateText(vCardPath);
10 writevCard.WriteLine(vCard);
11 writevCard.Close();
12 }
13 } /* FixNumber */
Good enough for me, me phone and Outlook playing nicely together with this.
Full sources and executable are uploaded again. Enjoy. -
Blog-post record - Using ndiswrapper
Wow, apparently I made 8 blog-posts today (9 now), that's a record ;) Well I've been away for a while as well, so..
Busy holiday, little time for computer, and plenty of new projects, a new laptop, airport express, all the toys ;)
I guess it'll be a bit more quiet the coming days, as I said everything today ;)
But to give this post some information, here's how to set up a Dell truemobile 1450 under linux. (I got it working under Fedora Core 2)
Get ndiswrapper and the .exe file that came with your card.
Extract the exe to a location on your disk
Install ndiswrapper (make install)
Install the driver (ndiswrapper -i bcmw15a.inf)
Check if it worked (ndiswrapper -l)
If it worked, check iwconfig to see wlan0
Now set up your wlan
iwconfig wlan0 mode managed
iwconfig wlan0 key open 12345..6 (your hex WEP key)
iwconfig wlan0 channel 11 (your channel)
iwconfig wlan0 essid HEAVEN (your essid, without quotes)
You can test with iwlink wlan0 scan (I believe) if it finds your AP.
I found that when you are unable to set your essid, it is because your WEP key is invalid. I don't know WiFi tech enough, but it seems that you only need a valid WEP key and it'll find your wlan.
If it's associated, bring it up with ifup wlan0 and it'll get an ip trough dhcp.
It took me a while, especially the essid part. Also sometimes it can bark at you when trying to set your key, then you have to do:
iwconfig wlan0 key open
iwconfig wlan0 key open 12345..6 (your hex WEP key)
Don't know why, but that solved it. -
Open Java and .NET Programmer functions
Ulysses Consulting recently contacted me asking if I didn't knew anyone for the following positions:
- Java Programmer
- .NET Programmer
If you want to apply contact me and put Ulysses in the subject. Include your contact details and which function you're going for and I'll forward the info. -
New site for Dutch teachers - Lerarenforum.be
In case there are some Dutch teachers reading this, I just finished a forum site exclusively for teachers...
It's a project of Kurt Meuleman, a teacher himself, who wanted to have a forum for the entire Dutch-speaking teacher-community, and today it's officially open.
Basically it's phpBB with a self-created theme and some mods. I'm convinced that with his motivation it could become something, should be on Radio 1 soon normally ;)
The address? http://www.lerarenforum.be