Category Archives: Reference - Page 5

Firefox and NTLM authentiction

I love my Firefox and it is still my no 1 browser for general browsing but one thing that really annoys me at work is that it doesn’t play nice with Integrated Windows authentication (aka NTLM) when dealing woth Intranet web applications. Fortunately there is a ‘fix’ for it that requires a tweaking the internal settings (about:config) of Firefox.

Follow these steps to enable NTLM for specific web servers:

  1. In the URL bar type about:config and accept the warning you might be getting…
  2. Look for or filter for the property ‘network.automatic-ntlm-auth.trusted-uris’
  3. Edit (double-click) this property
  4. Add the server names or addresses separated by commas. .i.e localhost,serverA,serverB,…
  5. Save changes (click OK)
  6. Open Firefox’s ‘Options’ and go to the ‘Advanced’ tab -> Network
  7. In the Connection section click ‘Settings’ and add the same server names in the ‘No Proxy for’ text box. This is to make sure it doesn’t use the proxy to access these servers which will break the NTLM authentication as well.
  8. Save any changes (click OK)

Too bad Firefox can’t automatically figure out which local ‘Intranet’ servers require NTLM authentication like IE and Chrome does…

 

 

 

 

Useful Visual Studio 2010 Keyboard Shortcuts

This might be a bit old news for some but for those that forgot or never knew – here is a quick reference link on keyboard shortcuts inside Visual Studio.

http://microsoftfeed.com/2012/30-useful-visual-studio-2010-keyboard-shortcuts

Firefox tip

Quick tip: This might only work for version 10 (not tested otherwise) but you can type ‘about:memory’ in the URL bar of the browser to see details of what and how memory is used. Nice!

DirectorySearcher and filters to search AD

If you want to do a query against AD (active directory) there are several ways to do it – but (only) one proper way like usual.

The DirectorySearcher class has a ‘filter’ property that allows you to filter the returned results – oppose to you having to test each property in code. The syntax of this filter is a bit tricky (ok a lot…)

It took me a while to figure out how to properly set up a filter to do more complex queries – like when you have multiple things to filter by including ‘and’s and ‘or’s. Anyway, I found a good reference here: Search Filter Syntax.

It explains the syntax plus give some examples. It also list some special characters plus explain how to use ‘wildcards’.

Happy searching…

Advanced debugging in VS2010 tips

Just a quick link to an article on codeproject –  Advanced Debugging in Visual Studio

Because you are never to old to learn… or too young!

Creating daily log files

In the (wild) old days when the only thing we had to work with computers were the command line we use to store output of important processes to a (text)file so it can be viewed and worked on afterwards. Event today in a support and administration environment these skills are very handy.

The process of doing this was/is called ‘output direction’ or ‘pipe output to’ since the standard output ‘device’ was the console (command window). So taking the application output away from the console meant redirecting it to a ‘file’ – since in a sense the ‘console’ could also be seen as a file that gets stuff outputted to (a temporary one).

Anyway, say you want to save the output of a command line utility like ‘dir’ to a file – you would use the following:

dir *.txt > dir.txt

All this does is execute the normal ‘dir *.txt’ command but store the output to the file ‘dir.txt’. This only outputs the standard ‘console output’ to the text file. If the output file already exists it gets overwritten. Actually there are two types of ‘standard outputs’: 1 – the normal successful and 2 – the standard error output. Using only the ‘>’ operator is just a shortcut for ‘1>’ which only outputs the ‘standard successful’ output i.e. the previous example is the same as:

dir *.txt 1> dir.txt

The second type of output is the ‘standard error’ output. To get this output you use the ‘2>’ operator e.g.

Someexe.exe 2> errors.txt

If you want to combine the outputs – that is both normal and error outputs you can use this:

Someexe.exe > errors.txt 2>&1

Lets say you want to keep a history of all previous outputs – then you want to use the ‘append’ operator ‘>>’:

Someexe.exe >> output.txt

If the file ‘output.txt’ does not exist yet it will be created. Otherwise and new output will simply be appended. If you want to combine all of these – that is combine normal and error ouputs plus append to the output file you can use this:

Someexe.exe >> output.txt 2>&1

Now, say you want to use part of the date when creating, listing etc. files. Unfortunately this tip depends on the date-time format settings of the machine you are running it on. For my example I use the ‘yyyy/mm/dd‘ format. To get the year you can use the following:

set year=%date:~0,4%

To get the month you can use ‘%date:~5,2%’ or day ‘%date:~8,2%’ – again this only works for the ‘yyyy/mm/dd’ format. If your date-time format is different you have to change the ‘~x,y‘ parts where x is ‘from’ and y is ‘to’ character positions.

Now using the example above you can use:

dir %year%*.txt

to file all files with a name that start with the current year (e.g. 2012blablabla.txt)

You can use the same technique when creating output files, e.g.

dir *.txt > %year%List.txt

This way you can create daily log files e.g.

set year=%date:~0,4%
set month=%date:~5,2%
set day=%date:~8,2%
Someexe.exe >> %year%%month%%day%.log

Mission accomplished… for now.

Sci-fi encyclopedia

At a point (perhaps even now) I had an idea to do something like this for myself. Recently after years of work a new web/Wiki site went online that is a good reference to all things sci-fi.

http://sf-encyclopedia.com

Although probably not fully complete and possibly not 100% accurate the site at least gives us sci-fi lovers a place to look up and read about the genre that seems to be shrinking lately.

RegexOptions.Compiled and x64 are not friends

As part of my attempt to use the FastColoredTextBox control I stumble across one of those undocumented .Net bugs that has been laying around for some time without being fixed – The Regex class with RegexOptions.Compiled option compiled under x64 or (Any CPU) that executes extremely slowly. In fact, it performs so slowly that it appears the whole application is frozen for a few minutes while the memory usage slowly climbs to ridiculous levels.

There are only 2 solutions to this issue for now: (1) compile all assemblies with x86 option only (not great if you are running on 64-bit) or (2) do not use the RegexOptions.Compiled option. For me the latter is a better choice since there is hardly a different between compiled and not compiled regular expression processing times – that I can see and certainly better than waiting minutes for a frozen app to start reacting again.

Thanks Microsoft for this one. Great way to waste time trying to look for problems in you own app while it is their crap breaking stuff.

 

Formatting C# code for blogging

I came across a nice example of a tool that can help with formatting of C# source code that you want to publish (on say Word Press that does not support it). The tool’s source code can be extracted from CodeProject (Fast Colored TextBox for syntax highlighting). Incidentally it can also format VB, HTML, SQL and PHP (pitty about JavaScript 😉 )

Microsoft Access Database Engine for 64-bit

Wow I must have missed this one when it was released but it (has the potential to) solves some problems with accessing Access databases (*.mdb) from a 64-bit process. I haven’t tested it yet and the description mention that you can only use the 32-bit driver on Windows XP (sp3) but at least it should work for Windows 7 (and yes that other one…Vista as well).

Download link: Microsoft Access Database Engine 2010 Redistributable

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=13255