We are kept busy here at Quaytech Systems!  

One of our clients had ordered a sizeable piece of machinery to be used in the manufacturing industry. With the clock ticking towards delivery, we were tasked with integrating this machinery into an existing production process, all the while finding ways to make the existing process more efficient.  

This project provided great variety in its development. The existing system was written in an older language and this needed to be integrated with more modern systems in order to meet our client’s needs.

As part of this project, we have worked closely with our client in order to ensure a smooth delivery of the program. Regular communication has been vital in developing a program with changing requirements. We have kept the user experience in mind whilst creating various screens in the program. 

As well as working with data, we have generated a label system with unique barcodes that are printed for every component created in the process. Each component also required a unique file to be created in order to be read by the new machine.

It can be really rewarding to develop software for industry, especially, when you get to see a massive piece of machinery running on your own code!

Raspberry Pi is a “charity that works to put the power of computing and digital making into the hands of people all over the world.” With the latest Raspberry Pi 4 costing £34, and the Zero model costing only £13, everyone can afford to access a home computer.

The Raspberry Pi is a fantastic tool for learners or anyone looking for a DIY project. What follows are seven projects that you can try using your Raspberry Pi.

RetroPie

Who doesn’t love a bit of retro gaming? Retro Pie software allows you to use your Pi to run and play emulated retro games. Considered one of the most straight-forward of set-ups the retro pie website provides very clear instructions. 

Security/Pet Camera

Using the Pi camera (purchased separately), you can make your own affordable security camera system. It’s possible to use a hard drive to store hours of security footage. Another option is to set up a pet camera so you can spy on your hairy loved ones while at work!

Desktop computer

Your Raspberry Pi can also act as a desktop computer, providing you have a keyboard and monitor. The Raspian is an open-source Linux-based operating system for the Raspberry Pi. As well as using your Pi for word processing, you could also use this computer as a way to learn to code. 

VPN

You can use your Pi to run your own VPN server using PiVPN. This is a great way to bypass website filters and connect devices on your home network. You can also enable end-to-end encryption and run your mobile internet activity through a secure tunnel.

Wedding Photo Booth

Hiring a photo booth for a wedding can cost anywhere up to £300 for an evening. With a Raspberry Pi, a digital camera and a bit of determination, you can make your own. This project can be pushed even further by using the  official Raspberry Pi Touchscreen.

Play Minecraft 

The Official Raspberry Pi website is a treasure trove for potential projects. For Minecraft obsessives, it’s possible to run the game on your Pi. Even better, you can use a bit of coding in Python to automate the house building process. In a couple of clicks, you can build a house.

Magic Mirror

For the ambitious among us, try the award-winning Magic Mirror project. Imagine looking in the mirror and also receiving traffic and weather updates, seeing your news feed, even being complimented! While it does involve some woodwork, the official website provides excellent instructions and support.

I love a good metaphor when learning a new topic. I recently started using JSON Web Tokens (JWT) to protect an API making calls to a database. I imagined that database as a place where people want to get into, but only a selected few are allowed. How can you make sure only the right people are allowed in? It sounds like you need a bouncer!

Our Scenario

Let’s say our users are people on a night out. The database, holding private data, is an exclusive nightclub. Everyone wants in but, as you may have heard before, “If your name’s not on the list, you’re not coming in!”

How this Works

Luckily, you’re in with the right people and your name is on the list. You approach the bouncer, flash your photo ID and you’re in. You have free access to the nightclub. There are certain places you can’t go, like the kitchens or the VIP section, but otherwise, you’re in for a great night. What if you need to leave? Will you be allowed back in? Will you have to go through the whole vetting process all over again?

In this nightclub, they use tokens (like a stamp on your hand) to show that you are allowed back in. You can come and go as you please for an amount of time. With the token, security trusts that you are who you say you are. They won’t check again – straight in you go.

Guest Passes, what Types?

There are different types of tokens, just like there are different types of passes at a concert. Let’s say you are very important indeed, so you are given a VIP pass token when your credentials are initially checked. Not only can you access the dance floor and bar, you can also access the VIP area. What a privilege!

Unsavoury Guests

Unfortunately, there are unsavoury characters who want to get into the nightclub. Their names are definitely not on the list! Somehow, they’ve managed to intercept a VIP and either take their token or make a copy of it. As far as security is concerned, the person holding this token is a VIP so they are given access to the nightclub.

This isn’t secure and something had to be done. A token now comes with a timeout. Every night, the tokens are changed. If you try to use an old, out-of-date token you will not be allowed in. If someone manages to get a token before it times out, they could still get into the nightclub. There needs to be more stringent checks.

The nightclub decides to introduce JWT Tokens. To get a token, you must hold a secret key as well as your credentials. This secret key is used to create another encrypted password with a signature.

Anyone can see the encrypted password. When a token is used, a quick check is done on this visible encrypted password. The bouncer is now able work backwards to calculate the secret key by looking at the encrypted password. If the secret key matches the one the nightclub uses, the bouncer knows that this is a valid token.

So …

(If you haven’t twigged it by now, the bouncer is an Authorisation API, and the nightclub has the sensitive data. A token can contain “Claims” which hold more details about the user who wants the data (aka. the guest who wants to gain entry to the nightclub). One claim could be that this is an admin user and should have access to all endpoints (aka. a VIP guest who should have access to free drinks)).

To Summarise

While JWT doesn’t guarantee security, they can reassure you that the tokens are authentic and not counterfeit. Hopefully this metaphor can help you understand using JWT for website security and also give you flash backs to horrible memories of queuing outside clubs!

You’ve been tasked with getting data from a SQL server table into a CSV file. There are many options available, each with their own benefits and drawbacks. In each of the following cases, consider your own task:

  • Does it need to be done quickly?
  • When should it be done?
  • How often?
  • Should it be automated?
  • How large is the data set?

 

Good Ol ‘ Copy and Paste  

If you are running SQL Server Management Server (SSMS), you can run your query results to Grid. This will show the result set as a table on screen. Simply select all and copy (optionally, with headers) and paste directly into a CSV file.  

This is a great method if you need to get a small data set very quickly. 

 

Right click and Save As   

As previously, you can view your result set in SSMS. Select all and right click. Then click Save As. Again, this is quick, but also gives you more options in choosing file types.  

However, both copy and paste and Save As do not allow for customisation of delimiters.   

 

Save results to File  

This requires more of a set up in advance. In the Query Options Menu  you can make more changes such as choosing delimiters and  whether or not to include column headers  

You can use Ctrl+Shift+F  to change from seeing the results grid, to saving to file. This is handy if there is no need to see results.  

 

Data Export Wizard  

This is by far the most thorough method which allows for the most customisation. Select the database you wish to work on. Right click> Tasks > Export Data  

You can choose whether to overwrite an existing file or append data to the end. You can also preview the results and make changes e.g. deleting columns from results or changing data types.  

That said, the export wizard does take a lot more time and is quite hands-on. You may not need this level of customisation.  

Imagine that you need to run a query once all workers have gone home? Surely, there must be a way to schedule a query to run and for the results to be saved? Of course, there is! The following options offer a more automated way of solving our initial problem.  

To start, writing a SQL Job would allow you to decide what to do with your results set. You could email a result set as an attachment using the stored procedure sp_send_dbmail. You could schedule the job to run out of hours. This method requires a knowledge of  Transact-SQL and some setting up.   

Another way of automating this process would be to use the command line with SQLCMD or BCP.  

 

Bulk Copy Program (BCP)

BCP is designed specifically for copying very large amounts of data from a SQL Server and saving to a file. It is one of the fastest methods and can handle massive amounts of data. 

As you can see to the below, there is a  bit of learning curve when using it. That said, it is a very valuable skill for a database administrator to have.

   

 

SQLCMD  

Similar to BCP, SQLCMD can be run in the command line. It can also be run in PowerShell or in a batch file. This would also allow you to use Windows Task Scheduler to choose when the script is run. One advantage over BCP, is that it is easy to pass command line arguments to a SQL file using SQLCMD.  

 

 

Picture this. You’ve been tasked with developing a new feature for a client. Depending on the size of the project, you have a niggling feeling that you should write a functional specification, but you decide to start and figure it out along the way.

“I can just start and wing it. Preparation is for nerds. I am so cool” 

– You, probably.

 

Out with the Old?

With many companies adopting Agile Methodologies many people are moving away from writing Functional Specifications, so why bother? You may feel it’s time wasted that could be spent coding?


 

What is a Functional Specification?

To be clear, a Functional Specification explains what the product will do from the user’s point of view. It’s not concerned with how the features are implemented. The user simply cares about what it can do and what the user experience is like.  A Technical Specification describes the internal workings of the program. It will describe the data structure, system architecture, choice of algorithms, language used etc.


 

Communication, Efficient Use of Time, No Assumptions

An agreed-upon functional specification is a great way to save time communicating. As a developer, you won’t make any assumptions about what the customer wants. You can be certain that this is what they want. Otherwise, you could make design choices that don’t align with the customer’s vision. The customer doesn’t want any nasty surprises on release day. And you know what happens next; you’ll have to go back and make more changes. More time spent, more time wasted.

Sometimes, it can be difficult to get a client to make a decision. Design by committee can lead to a lot of indecision and delays. A functional specification forces all parties to nail down decisions before development starts. If a customer is unhappy about a decision, you can always point to where it was agreed.

 

Scheduling

Once you have a well-written functional specification, it becomes much easier to make a schedule and stick to it. Without the specification, how can you be sure when you will reach certain milestones? A business will want to know how long development will take. The longer development takes, the more it will cost the business. This is far from ideal.

 

Should I write one for every project?

When it comes to smaller projects, it might work out fine to just get stuck in and code. But if the project is of a larger size, a functional specification can save headaches down the line.

 

 

We wrote an Online Ordering system (ASP.NET, C#, MySQL) for our client, allowing their national customer base to place furniture orders via a portal they could offer their product portfolio through.

Recently our client required some additional functionality added to this web application.  We were asked to add a new feature to the ordering process which would supplement the order being placed.

For orders of a particular type, our client wanted the customer to upload their furniture plans which would go on to help the warehouse and assembly team, who prepare an order for dispatch.

Functions we had to consider:

  • As this was a compulsary upload, we had to prevent the order from progressing forward until these plans were uploaded.
  • Could a customer have multiple plans, therefore multiple file uploads?
  • Storage of these files, and how much space it would consume.  This was dealt with by writing a supplementary Windows Task to regularly clear out the directory into which they were temporarily uploaded.
  • The type of file to upload – limiting the expected extensions.
  • The total upload size.

This addition function was published with no downtime, and has resulted in additional functionality being planned to further improve their ordering platform.

ReadOnly properties and constant fields may seem to achieve the same results. However, there are many differences which must be taken into consideration when choosing which one to use. 

Constant Field 

A constant field can be created in a class for information that is to be hard coded into the application and will not be changed. This often used for mathematical values such as Pi. A constant is considered a “Compile-Time Constant”. This means the values is fully evaluated at compile time. It cannot be assigned to a value returned from a method or an object instance. The compiler compiles the constant value into every reference in the application. If you later change the value of the constant, it will also change value in every location it is used in the code.  

public class Maths 

public const double Pi= 3.14  

A constant must be assigned on declaration. It can only be a number, string or Boolean as these can be evaluated at compile time. 

Must be assigned on declaration 

Can only be a number, Boolean or string as these can be evaluated at compiled time 

They are always static  and can be accessed using the class name as seen below: 

var area = Math.Pi * radius * radius; 

ReadOnly Property 

A Read-Only Property is a variable in a class that is initialised and then not changed again. It is considered a “Runtime Constant”, which means that it can be assigned to any valid expression at runtime.  

The property can be assigned on declaration or in a constructor as seen below: 

In declaration: 

public class Maths { 

public readonly decimal myPrice = GetPrice(); 

In constructor: 

public readonly decimal myPrice; 

//constructor 

public Product(){ 
MyPrice = GetPrice();  } 

By default, a readonly field is not static so you must create an instance of the class in order to call it. 

var newProduct = new Product();

var newPrice = newProduct.myPrice;

Read-Only properties can have any data type and can optionally be static.  

When to use each? 

It is better to use Constants with simple data types and when you can be certain that the values will never change. 

You may use a Read-only property when value is initialised from a code, a file or a table but then cannot be changed anywhere else in the application. If it is to be shared by all instances, then it should be a static read-only field. If the field value could be different for each instance then leave the field as non-static.  

Nowadays, most of us take cryptography for granted. In every email we send, online purchase we make, every WhatsApp message we send, we are benefiting from centuries of cryptography. There has always been the need to send messages and to only have certain people read them.

An early (and well-known) example of cryptography is the Caesar Cipher, named after Roman General and Dictator, Julius Caesar. When sending private correspondence, Caesar would shift each letter of the alphabet down a certain number of letters. This number of letters (the key) would need to be known by the recipient in order to decipher the message. They would simply reverse the shift to decipher the message.

caesarcipher

The next logical step in creating a cipher was to randomly assign each letter to another. The key in this case, would be each letter and its random match. This is a much more powerful cipher due to the huge number of possible keys. In response to substitution ciphers, Frequency Analysis was used. In the English language, some letters are used more than others. Think of Scrabble – “E” is much more common than “Z”. If you study the frequency of each letter in English, something like a digital fingerprint will appear as seen below: 

frequencyanalysis

Frequency Analysis

Note that these are only averages. In the secret message the letter E may not be the most common. However, the larger the piece of text, the more it will resemble the above frequencies. It was now possible to crack the Substitution Cipher by deciphering one letter at a time. 

There has always been evolution with cryptography. A new cipher is constantly under attack from code breakers. As a result, cryptographers have looked for more complex ciphers throughout history. The Vigenère Cipher was a considered a breakthrough for code makers.

“It has the alphabet written out 26 times in different rows, each alphabet shifted cyclically to the left compared to the previous alphabet, corresponding to the 26 possible Caesar ciphers. At different points in the encryption process, the cipher uses a different alphabet from one of the rows. The alphabet used at each point depends on a repeating keyword.”

No longer would the most common letter be the letter E. The letter E would have different ciphers at different points in the message. It wasn’t until 1854, over two hundred years later, that the Vigenère Cipher was finally cracked by the British cryptographer Charles Babbage. Babbage employed a mix of cryptographic genius, intuition and sheer cunning to break the Vigenère Cipher.  Below, is a Vigenère Square which is used to encipher a message.

vigenere

With increased computational power in the 20th Century, cryptography has taken another leap forward. Famously, the Enigma machine (with a possible 150,738,274,937,250 keys  ) used by Germany in World War 2 required the use of the “Bomb” computer developed with the help of Alan Turing.

Modern Cryptography

In the age of online communication, there has been a need for greater security when transmitting messages. The issue that has always existed in the history of secret messages is protecting the key. The recipient of a message needs to have the key in order to decipher it. How then can you safely get the key to the recipient without it falling into the wrong hands?

One solution was to use a mathematical operation that is easy to do in one direction, but not in the other. For example, you can multiply 453,658 by 789,624 and in no time have 358,219,244,592. However, if I gave you the number 358,219,244,592 and asked you to find the two specific numbers I multiplied to get it, it would be a much tougher task. Image such a problem on an exponentially larger scale and you can start to see the difficulty. The issue now became finding a key, I.e. finding an operation that was easy to reverse only if you have a mathematical key.

In 1974, GCHQ’s Clifford Cocks was able to solve this problem by writing a one directional formula. It allowed messages to be sent over the internet where anyone could read the encrypted text. However, only the recipient would be able to decipher it using another of his formulae.

Nowadays, we can send messages that cannot be cracked by the best secret services in the world. For the first time in history, we all have access to unbreakable codes.

 

The fifth generation of mobile network (aka 5G) is on its way. How fast will it be? What will be possible? Will I need to get a new phone?!  When 5G arrives we can expect to see drones monitoring cows Netflix for gaming  and, eventually, a world without traffic lights.

Wait. Didn’t we just get 4G?

It seems strange to move onto a new generation when 4G has only 77.28% penetration in the UK. Put simply, 5G equals faster upload and download speeds than 4G. It is believed that speeds will be between 20 to 30 times faster than the previous generation.  All of this is possible because of the use of “high-spectrum band” frequencies. Better use of the radio spectrum will allow more mobiles to have access to the internet at the same time. The catch is that these higher frequencies cannot travel as far as 4G signals. This means that more antennas will need to be built.

One of the most notable changes will be felt with latency. Gamers rejoice! 5G may bring an end to dreaded lag. While 4G had latency of approximately 45 milliseconds, 5G’s latency could theoretically be as low as 1 millisecond. This would make delays undetectable to humans.  With vastly greater upload and download speeds, incredible changes will be possible using new technology. An internet connection will always be there. The Internet of Things (IoT) will become a reality.

You can expect driverless vehicles to take advantage of 5G technology. The low latency will be vital in keeping the vehicle on the road and making split-second decisions.  Imagine opening your door in the morning to find a parcel delivered by a delivery drone. This is not far from happening with Amazon applying for a patent for its own hack-proof drones in 2016.

 

amazon-drone

Amazon’s delivery drone which can be flagged down as shown.

Emergency services will also benefit. In the event of a disaster, drones would be able to access hazardous areas whilst remaining in constant communication. Wearable tech will also be able to communicate immediately. Ambulances could be contacted automatically if a person is injured or has no heartbeat.

The fun part

5G will truly change how we consume media. In gaming, it will be possible to stream games rather than own a physical copy. A Netflix-style business model would become a real possibility. Along with developments in cloud computing, 5G will signal the end of games console as we know it. Furthermore, Augmented Reality and Virtual Reality on the go will become a reality.  Increased download speeds will allow for the streaming of 4k Ultra HD video without buffering issues.

With 5G not due to roll out in the UK until 2020, we have a while yet to wait in anticipation… and yes, to access the new 5G network you will need a new phone.

There are two types of collections: generic and non-generic. A non-generic collection is one which can contain any data type, whereas the generic collection must state the type as a parameter. Generics can be considered safer to use as you have greater control of the data involved. Microsoft themselves recommend the following:

“Be sure to choose your collection class carefully. Using the wrong type can restrict your use of the collection. In general, avoid using the types in the System.Collections namespace unless you are specifically targeting .NET Framework version 1.1. The generic and concurrent versions of the collections are to be preferred because of their greater type safety and other improvements.”

Here is a brief explanation of some of the more commonly used Generic Collections. This is not an extensive list.

 

List<T> 

Generic lists are ideal for storing and retrieving large number of elements. You must specify the data type <T>. As you add entries the size of the list will expand – it is not fixed. 

The data can have nulls and duplicates and supports indexing. Lists are not guaranteed to be in order, so the Sort() method may be necessary.

Dictionary<TKey, TValue> 

A collection of key-value pairs where the data type of each is specified. The key is used to identify and order each pair. It acts as primary key so it must be unique and cannot be null.  The values can be null or duplicates.

 

SortedList<T> 

A SortedList is quite similar to  a Dictionary, although the SortedList uses less memory. 

It is a collection of key-value pairs that are sorted by the key in ascending order. When a new value is inserted, it is automatically placed in the correct order and the indexing adjusts accordingly. The key must be unique and cannot be null; the value can be null or duplicate. You can also have a non-generic SortedList which can take any data type.

 

Stack<T>  

Similarly, a Stack may be generic or non-generic. Stack<T> can be described as a last-in-first-out (LIFO) non-generic collection of objects that are of the same specified type. Use a Stack if you wish to access data in a reverse order.

stack

Queue<T>

A first-in-first-out (FIFO) non-generic collection of objects.  A Queue can be used to access data in the same order as it is entered in. Both Stacks and Queues are useful when you need temporary storage for information; that is, when you might want to discard an element after retrieving its value.

queue

Each collection type has its own strengths and weaknesses, but which to use? It really comes down to what the situation calls for:

  • If you need to access the elements in a certain order, you should choose to use a Queue<T> for FIFO or a Stack<T> for LIFO.
  • A Dictionary<TKey, TValue> or List<T> would be suitable if you needed to access each element by an index.
  • If you need to sort the elements differently from how they were entered, you could you a SortedList<T>. A List<T> also has a Sort() method which could also have the desired effect.

 

Be aware that there are many other types of Generic Collections which may better suit your needs:

  • LinkedList<T>
  • Collection<T>
  • KeyedCollection< TKey,TValue >
  • SortedDictionary<TKey,TValue>