Sunday, 25 October 2015

I'm not dead

I got a bit busy and a bit depressed

BCS foundation level test: DONE!
Changed the way I test, I need to get a better balance as it seems geared towards lots of documentation to the extent that I spend a lot of time documenting what I am doing rather than actually doing it. There has been the benefit that less is getting missed and managers can decide on risk relative to test cases run. A big benefit has been the confidence to say no and be able to back it up.

ITIL foundation: DONE!
Again a lot of documentation and process, a good trainer from  Quanta. It was good as he was willing to engage and discuss that ITIL does not really deal with modern ways of doing project work (agile). From my point of view it is a way for the IT department to have the confidence to talk about business demands and maintaining a good relationship. It was an eye opener in what managers have to deal with in terms of scope creep. 

BONUS, work paid for it all.

Getting back to programming now the above are out the way, started on the Java OCA 8, forgotten how much I enjoyed programming, big highs when it works, lows when it doesn't and a good challenge in between. So the habit I need to build is program everyday and build things, I want to mix in code challenges as a way of testing myself and doing something different. 

And here is one I made earlier, I wanted an easy to paste example, it should have been a proper class.


package com.company;

import java.io.*;
import java.util.HashSet;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    private static HashSet<String> words = new HashSet<>();

    public static void main(String[] args) {
       //read file into a set         
        FileReader fileReader;
        BufferedReader bufferedReader;


        try {
            fileReader = new FileReader("C:\\enable1.txt");
            bufferedReader = new BufferedReader(fileReader);
            String currentWord = "";
            while ((currentWord = bufferedReader.readLine()) != null) {
                words.add(currentWord);
            }
            bufferedReader.close();
        } catch (FileNotFoundException ex) {
            System.out.println("File not found bro!");
            ex.printStackTrace();
        } catch (IOException ex) {
            System.out.println("HDD broke bro!");
            ex.printStackTrace();
        }

        // int how many lines to read         
        System.out.print("Lines to read: ");
        Scanner scanner = new Scanner(System.in);
        int linesToRead = scanner.nextInt();

        // amount of lines specified above with string of what keys can be entered 
        String[] inputWords = new String[linesToRead];

        for (int i = 0; i < linesToRead; i++) {
            inputWords[i] = scanner.next();
        }

        System.out.println();

        //output each user input line = longestWordFound 
        for (String word : inputWords) {
            System.out.println(word + " = " + longestWordFromChars(word) );
        }
    }

    // find the longest word that can be found using those keys
        private static String longestWordFromChars(String chars) {
        Pattern regex = Pattern.compile("\\b[" + chars + "]+\\b");
        Matcher regexMatcher;
        String longestWord = "";
        for (String word : words) {
            regexMatcher = regex.matcher(word);
            if(regexMatcher.find()) {
                if(word.length() > longestWord.length()) {
                    longestWord = word;
                }
            }
        }
        return longestWord;
    }
}

Saturday, 18 July 2015

Another interview

It went OK i just panicked and forgot all the words, also if anyone interviews please do not ask them to work from a TV on the wall, what is so hard about getting them to use a proper workstation. 

Any way from what I remember of the interview questions there were three, solve quadratic equations, formula given, connect to a db in c# and out order the values not to worry about displaying them, and a t-sql question from the pubs database. 

Pubs was actually a not that easy to get hold of, a bit of searching and the database can be build by using a script from SQL from the trenches, use the script as the old db files are not compatible with modern iterations of mssql server.

Note code is not perfect as tried to keep to similar timescales

Question 1 & 2

using System;
using System.Data;
using System.Data.SqlClient;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            var dt = new DataTable();
            var connectionString = @"Server=D\SQLEXPRESS; 

            Database=pubs;Integrated Security=true;";
            var query = "SELECT * FROM authors";

            var conn = new SqlConnection(connectionString);
            var cmd = new SqlCommand(query, conn);
            conn.Open();

            var sda = new SqlDataAdapter(cmd);
            sda.Fill(dt);
            conn.Close();
            sda.Dispose();

            DataView dv = dt.DefaultView;
            dv.Sort = "au_lname ASC";

            foreach (DataRow row in dv.ToTable().Rows)
            {
                Console.WriteLine("{0,-15}{1,-15}{2,-15}", 

                row["au_lname"], row["au_fname"], row["city"]);
            }

            var anAnswer = quadSolver(1, 9, 18);
            Console.WriteLine("The answer is: {0} and {1}",

            anAnswer.Item1, anAnswer.Item2);

            Console.Read();
        }

        public static Tuple<double, double> quadSolver(double a, double b, double c)
        {
            double answer1 = 0.0;
            double answer2 = 0.0;
            answer1 = ((b * -1) + Math.Sqrt(Math.Pow(b, 2) - 

                      (4 * a * c))) / (2 * a);
            answer2 = ((b * -1) - Math.Sqrt(Math.Pow(b, 2) - 

                      (4 * a * c))) / (2 * a);
           
            return new Tuple<double, double>(answer1, answer2);
        }
    }
}


Question 3 

SELECT  (au_fname + ' ' + au_lname) AS NAME,
        [PUBLISHED TITLES],
        [AVERAGE COST],
        [LAST PUBLISHED]
FROM authors AS A
JOIN
(
    SELECT  AU_ID,
            COUNT(*) AS [PUBLISHED TITLES],
            AVG(price) AS [AVERAGE COST],
            FORMAT(MAX(pubdate), 'dd/MM/yyyy') AS [LAST PUBLISHED]
    FROM [dbo].[titles] AS T JOIN [dbo].[titleauthor] AS TA
    ON T.title_id = TA.title_id
    GROUP BY au_id
) AS FT ON A.au_id = FT.au_id
ORDER BY NAME;


Table showing author name, amount of titles and last  published date in dd-mm-yyyy format
 

Wednesday, 8 July 2015

Github

Finally got github account set up and time to get updating my blog again!

https://github.com/Decimater/xfireDownloader

Sunday, 26 April 2015

Bits and bobs

Little bits I suppose, 

Getting rid of more hardware, and been drooling over the m.2 ssd available. 





Apart from getting rid of old hardware, started to use SQL a lot more and Java.

Sunday, 22 March 2015

Laws, JUnit, and Hamcrest

Came across a couple of different laws this week, 

The robustness principal / Postel's law, interesting idea on how it can be used within software construction although originally for use in networking. 

Be conservative in what you do, be liberal in what you accept from others (often reworded as "Be conservative in what you send, be liberal in what you accept").

Command query separation (CQS), the idea for what I write would be a function or method should return a value for query and for command which would change the system's state in some way should return void.

Installing JUnit for IntelliJ 14, although IntelliJ does come with JUnit installed and a test runner, JUnit has a dependency on Hamcrest. It was not entirely clear where what and how was going wrong, so...

  1. Hamcrest at Google code.
  2. IntelliJ -> File -> project structure
  3. Modules -> Dependencies -> + icon top right
  4. Point to hamcrest, YAY!
Book cover with white text and hands using a tool on wood


Book read this month, The software craftsman, has some good ideas, I did like the whole job searching and what to look for, generally that a dev would have written the job description and more concerned about what the dev can deliver. I often see degree only, 10 or more years experience.

Sunday, 15 March 2015

Back to learning Java

Little things from podcasts and bits online, 

Strangler pattern, interesting idea, by taking the shape of current system you strangle the older system in the same way ivy does. 

Conway's law, the idea that systems being developed mirror the social structure of the company creating it.

UK Business insider with an article about rates of pay and different technologies and skill sets. 

Trying to get up to speed with Java doing basic coding challenges, very different to how intuitive I found visual studio.

Intellij using the darcula theme with a second window showing a black triangle
Challenge 203, display a black triangle
 
Challenge 202 convert binary to English

public class Main {

    public static void main(String[] args) {
        String input "010010000110010101101100011011000

11011110010000001010111011011
11011100100110110001100100";
        char[] inputs = input.toCharArray();
        List<String> inputsAsWords = new ArrayList<String>();

        int wordLength = 8;
        int wordLettersinInput = input.length() / wordLength;
        int counter = 0;
        for (int i = 0; i < wordLettersinInput; i++)
        {
            String Word = "";
            counter += wordLength;
            for (int k = i*wordLength; k < counter; k++  )
            {
                Word = Word + inputs[k];
            }

            inputsAsWords.add(Word);
        }

        for (String word: inputsAsWords)
        {
            System.out.print((char) Integer.parseInt(word, 2));
        }
    }
}


Long graphics card with a large looking gpu on a desk

More kit going to the recycling, this time it was a broken card, folding at home is hard on cards, removed the cooler for other projects. I did find whilst throwing rubbish out my old TIM-clean. TIM-clean, citrus based solvent that is actually friendly compared to isopropyl alcohol and effective.

Sunday, 8 March 2015

Recycling

Recycling old kit, you will be missed, go now to silicon heaven with all the old calculators. 



Also frustrating and rewarding the app inventor, had to do some bits for uni. I am old so programming in this way is quite strange.