Sunday, 26 October 2014

Don't make me think

A shorter a book I think a lot of clients would find worth reading regarding their own websites, a lot of common sense in this book to the oh yeah that makes a lot of sense.

Red matt finish book with book title in bold white text with cartoon picture of a mans head

Had this book on my reading list of a while, but since it is required reading for OU, I thought I would give it a go. 

The take aways from don't make me think for me are
  • Convention is not all bad
  • Accessibility is really a lot of common sense and fringe benefits including potential for increased traffic
  • We tend to scan websites for information and do not read it all
  • Usability testing is worth while doing and does not have to cost much at all.
  • Goodwill can be bought and lost at a rapid rate.
Browsing more interview questions, can I sort a dictionary by value and by key which didn't come out too badly, however I have installed resharper ( yay student discount ), resharper does heavily push linq. 

The linq solutions are terse relative to my own explicit solutions.

namespace boredbasics
{
    class Program
    {
        static void Main(string[] args)
        {
            var aDictionary = new Dictionary<string, string>
            {
                {"d", "a first value"},
                {"z", "a Second value"},
                {"a", "a ThirdValue"},
                {"n", "a forthValue"}
            };

            DictionarySorter.PrintDictionary(aDictionary);
            Console.WriteLine();

            //sorted by key
            DictionarySorter.PrintDictionary(DictionarySorter.SortByKey(aDictionary));
            Console.WriteLine();

            //sorted by value
            DictionarySorter.PrintDictionary( DictionarySorter.SortByKey(DictionarySorter.KeyValueSwap(aDictionary)));
            Console.WriteLine();


            Console.ReadLine();
        }
    }
}


namespace boredbasics
{
    public class DictionarySorter
    {
        public static Dictionary<string, string> 

            SortByKey(Dictionary<string, string> aDictionary)
        {
            return aDictionary.Keys.OrderBy(k => k.ToString()).ToDictionary(key => key, key => aDictionary[key]);
        }

        public static Dictionary<string, string> KeyValueSwap(Dictionary<string, string> aDictionary)
        {
            return 

            aDictionary.Keys.ToDictionary(key => aDictionary[key]);
        }

        public static void PrintDictionary(Dictionary<string, 

                                        string> aDictionary )
        {
            foreach (var key in aDictionary.Keys)
            {
                Console.WriteLine("key: {0}, value: {1}", key,  

                aDictionary[key]);
            }
        }
    }


Apart from all of that found a good link on Hanselman's blog for good applications

GitHub for windows and Windows memory tester being news to me, so I will give those an install and see how they go. As using github via the command line does make it a pain to use. Must give linqpad a go.

Wednesday, 22 October 2014

Interview cake fibs question

Had a browse around interview cake I like the site, anyway I got this weeks free practice problem. I did a recursive and iterative solution. I would change a few bits looking back at it now, as it is lacking any guard conditions for inappropriate input.

fib program below running through the console using visual studio ide


namespace boredbasics
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 0; i <= 10; i++)
            {
                Console.WriteLine(fib(i));
            }

            for (int i = 0; i <= 10; i++)
            {
                Console.WriteLine(fibRecursive(i));
            }

            Console.ReadLine();
        }

        public static int fibRecursive(int nthFib)
        {
            if ( nthFib == 0)
            {
                return 0;
            }
            else if ( nthFib == 1)
            {
                return 1;
            }
            else
            {
                return fibRecursive(nthFib - 1) + fibRecursive(nthFib - 2);
            }
        }

        public static int fib(int nthFib)
        {
            if (nthFib == 0)
            {
                return 0;
            }
            else if (nthFib == 1 || nthFib == 2)
            {
                return 1;
            }
            else
            {
                int first = 1, second = 1, temp = 0;
                for (int i = 2; i < nthFib; i++)
                {
                    temp = first + second;
                    first = second;
                    second = temp;
                }

                return temp;
            }
        }
    }
}

Sunday, 19 October 2014

First go at async

Playing about with async so a really simple example partly ripped from illustrated C#.

picture of visual studio 2013 pro with console window open running async console app

namespace boredbasics
{
    class Program
    {
        static void Main(string[] args)
        {
            Task<int> t1 = 

            countCharsAsync(1, "http://stackoverflow.com/");
            Task<int> t2 = 

            countCharsAsync(2, "https://news.ycombinator.com/news");
            Task<int> t3 = 

            countCharsAsync(3, "http://www.bbc.co.uk/");

            Console.WriteLine("call one:\t{0: 20}", t1.Result);
            Console.WriteLine("call two:\t{0: 20}", t2.Result);
            Console.WriteLine("call three:\t{0: 20}", t3.Result);
            Console.Read();
        }

        public static async Task<int> countCharsAsync(int id, string uri)
        {
            Console.WriteLine("Starting count chars {0}", id);
            var wc = new WebClient();
            string result = await wc.DownloadStringTaskAsync(new Uri(uri));

            Console.WriteLine("char count complete {0}", id);
            return result.Length;
        }
    }
}


A few things to add to my list, don't make me think has been ordered for uni reading, ASP.Net MVC book arrived yay!

If any other job seekers are reading, I was hanging around imgur lots are seeing the same things with junior tech jobs.

commant stating Must have 5 years experience milking purple Himalayan goats...and know html




Reading about the gingery furnace and found a few places to order a good metal bucket for the furnace and a smaller bucket to create the void.

http://www.oipps.co.uk/
http://artisanfoundry.co.uk/

Can't wait to get setup and build a lathe.

Sunday, 12 October 2014

Uni ebooks

OU courses are finally starting, a lot of the reading material no longer comes on paper, which is not great for me as I like a break from the screen and humming machines. There is a good tool to convert into kindle compatible format which is currently free, http://calibre-ebook.com/ .

Part of the units being studied cover web development, I am usually pretty keen on firebug and the in built chrome tools, for quick validation and good features the plugin for firefox https://addons.mozilla.org/en-US/firefox/addon/web-developer/ works well.

Car and 3d printer video of interest, a model transmission, when I first looked at it I thought it would be quite basic however it supports six forward speeds and reverse, youtube.

Sunday, 5 October 2014

Interviews

Interviews are tough going, I think it is worth being aware that the developers doing the hiring may not have all the input into job specification.

Practical tests, I did mess up more than once, keeping things simple and being able to justify what is written is more important than a poorly implemented feature.

Being asked to do a black jack implementation, although not perfect, left as is because I know it gets used for homework, link to sln.

Still reading Agile principles, patterns, and design practices in c#. The explanation of design patterns although not going over all the gof, being able to understand template and command in a practical sense is useful. In the other pattern books at the end being left with so what, how does this help me.

Book, Agile priciples, patterns, and practices in c#, blue black cover with white and blue text with an image of a nebula