Sunday, December 27, 2009

A First Experiment with the RX Framework

A first experiment with the RX framework. This generates 5 stock prices for 4 different stocks.



using System;
using System.Collections.Generic;
using System.Linq;
 
namespace RXStockGenerator
{
    class TestRX
    {
        public TestRX()
        {
            using (new StockPriceGenerator().Subscribe(q => Console.WriteLine("Quote: " + q)))
            {
                Console.WriteLine("Press any key to unsubscribe");
                Console.ReadKey();
            }
        }
    }
 
    class StockPriceGenerator : IObservable<StockQuote>
    {
        private readonly Random m_random;
 
        public StockPriceGenerator()
        {
            this.m_random = new Random();
        }
 
        public IDisposable Subscribe(IObserver<StockQuote> observer)
        {
            List<IObservable<StockQuote>> generators = new List<IObservable<StockQuote>>
            {
                this.Generate("AAPL", 200.00, 100),
                this.Generate("IBM", 120.00, 150),
                this.Generate("MSFT", 30.00, 125),
                this.Generate("GE", 15.00, 175),
            };
 
            return generators.Merge().Subscribe(observer);
        }
 
        public IObservable<StockQuote> Generate(string symbol, double startPrice, int delay)
        {
            return Observable.Generate(
                0,
                i => i < 5,
                _ => new StockQuote(symbol, startPrice + this.m_random.NextDouble()),
                _ => TimeSpan.FromMilliseconds(delay),
                i => i + 1);
        }
    }
 
    class StockQuote
    {
        public string Symbol { get; set; }
        public double Price { get; set; }
 
        public StockQuote(string symbol, double price)
        {
            this.Symbol = symbol;
            this.Price = price;
        }
 
        public override string ToString()
        {
            return string.Format("{0}/{1:##.#0}", this.Symbol, this.Price);
        }
    }
}

Wednesday, December 09, 2009

LinkedIn Groups Created By Headhunters

I have noticed that Headhunters who operate in a particular space in Capital Markets or have a job opening in a certain area will create LinkedIn groups for the sole purpose of identifying candidates. I never join groups that have been created by a headhunter unless they are personally recommended to me.

For me, LinkedIn is becoming a bit like the Wild West, and its usefulness will be diluted by recruiters who misuse the service.

Thoughts?


©2009 Marc Adler - All Rights Reserved.
All opinions here are personal, and have no relation to my employer.