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

Saturday, 27 September 2014

Euler 3

Quite challenging as you cannot brute force a solution, I tried, the solution takes a long time to run. Had a go with TDD for a change, actually made it easy to think the problem through, even though I came up with the wrong answer. My solution would only work when the largest prime is less than the square root of the argument value. Solution

Easiest solution to implement for me was trial division algorithm is implemented on the page in python this is easy to convert to C#. Implemented in the tests this took 1-11ms to run which isn't bad considering the numbers magnitude, 600851475143.

Lists and enumerable range types do have a limit in their sizes which isn't too bad, I was playing around the idea of a linq solution which I think would work for smaller numbers.

Trying to keep a clear head and getting out I went to the zoo.

red panda in enclosure with trees, panda is sat on wooden box

Sunday, 21 September 2014

Interviews are hard

The topic of software development is vast, trying to get everything together to at least make sure I know what I know. 

I did get asked about SOLID, annoying as I should have known all this and been able to rattle it out even though the understanding was there, full on mind blank. A refresher from Agile principles, patterns, and practices in c# ( working through at the moment ). Wiki SOLID.

Also asked about, database service providers and Entity framework.

A good site for practice is project Euler, lots of small puzzles some are quite complicated and require a bit of maths to get going.

Solutions to the first two

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace basics
{
    class Program
    {
        static void Main(string[] args)
        {       
            //If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
            //Find the sum of all the multiples of 3 or 5 below 1000.

            var aList = new List<int>();
            for (int i = 1; i < 1000; i++)
            {
                if (i % 3 == 0 || i % 5 == 0)
                {
                    aList.Add(i);
                }
            }
            Console.WriteLine(aList.Sum());
            Console.Read();
        }
    }
}

---------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace basics
{
    class Program
    {
        static void Main(string[] args)
        {
            //Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:

            //1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

            //By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
            int first = 1, second = 1, third = 0;
            int sum = 0;

            while (third < 4000000)
            {
                // gen fibs
                third = first + second;
                first = second;
                second = third;

                // less than 4 mill and even add to sum
                if (third < 4000000 && third % 2 == 0)
                {
                    sum += third;
                }
            }

            Console.WriteLine(sum);
            Console.Read();
        }
    }
}
--------------------------------------------------------------- 


Good articles read this week

Monday, 15 September 2014

Solving and sorting

Been back to reading a lot again, How to solve it. The maths part of this book wasn't great as well the writing style being old text book. Colours, chapters and descriptions would have been nice rather than the maths equivalent of the old Haynes proverb, fitting is reverse of removal.

Book cover with white back ground and thinking man made of numbers

One of the things I did like was the idea that with all problems you need to get purchase on the problem at hand. This maybe by digging a screw driver into the problem, waggle it and look for signs, which seems quite foreign to me as a way of solving a maths problem.

There is also a lot of good common sense items,
  • Start at the end and work backwords
  • Did you use all the data.
  • What are the data (written that way all through the text)? Unknowns etc.
  • What is the condition?
  • Use auxiliary elements.
  • Use auxiliary problems to simplify until the ridiculous.
  • Have you solved something like the problem before?
After reading clean code, I should know quick sort, I did take a quick youtube refresher. I think I am making it harder than it should be.

Sunday, 7 September 2014

Cows are bigger in person

After being a bit down I read The clean coder and I am rejuvenated. Very handy tips on dealing with pressure and saying no. 

The interesting item recommended in work ethic is time outside of work dedicated to learning, the recommendation being 20 hours. The thing is this really isn't that much when pod casts are taken into account. I easily get through 3 hours a week with .net rocks and Hansel minutes, what does help is having a tech book and when not in the mood a not so tech book like clean coder.

Black book with white title and picture of purple nebula

Liked the parts about not rushing, as I have seen this a number of times and refactoring out crazy variable names.

I read about the woods being good all round for health and creativity so found Haldon forest park, early morning it is quite empty. Note the speed hump on the way out that has the claws to stop cars driving in the exit are brutal going the correct way over it.

trail spliting woods with mist

Cows are about and they would only move for excuse me, cows, manners matter.

two black cows on the trail




Other bits from this week, lots of the visual studio shortcuts work in SQL server management studio.

Words of the week

Niladac
Function with no arguments

Connascence

Change in part means a change in another part of the program, I think is the side effect of units which are tightly coupled.