Saved for later reference

online repository of stuff I had to google for hours to figure out – and random snippets of code

FizzBuzz with Reactive Extensions

TAGS: None

I played around with – and tried to do the “classic” FizzBuzz programming test in an obnoxious way.

Here’s what I’ve got so far, but I think it’s possible to make it more convoluted than this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reactive.Linq;

namespace FizzBuzz
{
    public delegate void NumberEventHandler(object sender, long e);

    class Program
    {
        public static event NumberEventHandler AnyNum;

        static void Main(string[] args)
        {
            var numbergenerator = Observable.Interval(TimeSpan.FromMilliseconds(1));
            var numbers = from n in numbergenerator where n > 0 && n <= 100 select n;

            var numberobs =
                    Observable.FromEvent<NumberEventHandler, long>(
                                ev => { NumberEventHandler neh = (sender, e) => { ev(e); }; return neh; },
                                ev => AnyNum += ev,
                                ev => AnyNum -= ev);

            var watchforfizz = from n in numberobs where n % 3 == 0 select "Fizz";
            var watchforbuzz = from n in numberobs where n % 5 == 0 select "Buzz";
            var watchforothers = from n in numberobs select ((n % 3 != 0 && n % 5 != 0)?n.ToString():"") + "\n";

            watchforfizz.Subscribe(x => { Console.Write(x); });
            watchforbuzz.Subscribe(x => { Console.Write(x); });
            watchforothers.Subscribe(x => { Console.Write(x); });
            numbers.Subscribe(x => AnyNum(null, x));
           
            Console.ReadKey();
        }
    }
}

Key features are the number generator, and the three filter event handlers. I feel like there should a better way of handling the “regular” numbers, but close enough.

Share

“Please provide path to Windows media (x86 processor)” when installing printer

Tags: , , , , , , , , ,

When installing a new printer earlier, I first installed it in Windows Server 2008 R2 (which of course only exists in a x64 version), and tried to add the x86 (XP) driver since all the clients run XP.

After providing the “additional drivers”-wizard with the printer driver, it asked me to “Please provide path to Windows media (x86 processor)”, which was a bit difficult since I had no 32-bit media (I would have tried 2008 32bit or similar, if so).

Turns out, the solution is blindingly simple: Share the printer, and with an admin user (typically the same who installed the printer on the server), log on to an XP computer, and install the shared printer from there. It will ask you to provide the driver since the server has none. After installing, go into printer properties in XP, find Sharing, Additional drivers…, and check off “Windows XP/2000, x86”. The driver will be uploaded to the server.

Share

“Microsoft Dynamics CRM for Outlook with Offline Access has already been configured for a user on this computer. Only one use can be configured per computer for Microsoft CRM for Outlook with Offline Access.”

Tags: , , ,

If you try to swap users on a laptop, with Dynamics CRM installed in Offline Access mode, it will give the error above; searching gave me this page from the Chinese Dynamics CRM team, so I’m just going to repeat it here:

1
2
3
4
  C:\>osql –E –S localhost\CRM
      1> drop database mscrm_msde
      2> go
      1> quit

Basically, you connect to the SQL Server on the local computer, and delete the Offline Access database, allowing you to reconfigure as normal. Note that this won’t let you reconfigure the user as “online only” – the new configuration will automatically be Offline Access.

Secondly, this works even if the user is not Local Administrator on the computer.

Share

© 2009 Saved for later reference. All Rights Reserved.

This blog is powered by Wordpress and Magatheme by Bryan Helmig.