Breath of the Wild – Final Trails – Floor 6

Sweet relief. Don’t do what I did, and eat one of the truffles without first cooking it (alone). The next area is filled with fire… So prepare for that. Be sure to pick up wood here, as you’ll need it later. 

You will get 3 Ancient Arrows here. You need to save these until the last set of rooms much later on.

Breath of the Wild – Final Trials – Floor 4

Mounted Skellies… Start by running right towards the ruin. Chuck the metal containers off, and you should have a good perch from which to attack these guys. One of the mounted skeleton archers has shock arrows. Destroy that one from a distance. Remember to collect crates after killing all the enemies, as some have shock arrows in.

Breath of the Wild – Final Trails – Floor 3

This floor has 2 lighting blobs, and a number of Mobiln skellies that show up when you are about to open the first chest. Just like with the last room, take out the blobs from a distance, and kill the skellies with bone weapons if you can. You should be able to drop the bokoblin arms after this room, as the moblin arms will deal more damage if needed, and the lizard arms act as boomerangs.

Remember to get both chests and all the wood crates. You want to keep picking up as many arrows as possible.

Breath of the Wild – Final Trials – Floor 2

This room has 2 lighting bats. Kill them from a distance as they will fuck up your day. Then kill the lizard skeletons in the skull rock. One of these has a metal sword and boomerang. Try to take him down inside the skull. If you can avoid blowing up the barrels, you’ll get food you can cook later and some arrows.

Remember to get the chest around the side. 

Breath of the Wild – Final Trials – Floor 1

In many of these earlier rooms of the final trials, your best bet is to be quick on your feet and to pick up as many arrows as possible. You’ll need every arrow you get in the later trials. All of these rooms have the thunder weather pattern, so avoid using metal weapons and shields, but do pick them up as you’ll need them later.
For now, pick up as many bones as you can get away with, as they are a great way to take down other boney bastards.
Floor 1 – Run straight for the metal weapon in front of you so that you can take down a couple of the enemies at the start. Throw this away as soon as lighting will strike it, or when you have a bone or wooden weapon.

 

SQL Server Cursors

There are times when using cursors to process something in SQL is the right thing to do. These are the steps that I take when considering if cursors are the right thing to use and the process for using them:

  1. Are you really sure you can’t do the operation using a regular query?
  2. Are you processing something across a single or multiple databases?
  3. Are you processing something across single or multiple tables?
  4. Do the tables you want to process against have the same structure or do you have some metadata that describes how you want your process to work?
The example below is for a couple of stored procedures that, when combined together, allow you to find a string in any string column of any table in the database that you are working in.
The sections of a cursor:
  1. The Declaration and Name
    1. Pretty Simple. Make sure you don’t use the same name as another cursor on the server, as cursor declarations are global.
  2. The Open
  3. The Processing Loop
    1. Most other examples you will see with cursors will use a while loop. I use an if condition and a goto here for a couple of reasons.
      1. It reduces the risk that I will write an infinite loop by forgetting to add the second fetch statement (which is required in the while loop).
      2. It means I only have to change the fetch statement in one location if I change the definition of the cursor.
  4. The Close
  5. The Deallocation
use AdventureWorks2016CTP3
go

if object_id('dbo.FindString') is not null 
 drop procedure dbo.FindString
if object_id('dbo.ForEachTable') is not null
 drop procedure dbo.ForEachTable
go
create procedure dbo.ForEachTable 
 @sqlQuery nvarchar(max), 
 @paramDef nvarchar(255), 
 @Param nvarchar(255)
as begin
 set nocount on;
 set xact_abort on;
/*1. The Declaration and Name*/
 declare Find_StringCursor cursor for
  select
   c.TABLE_SCHEMA
     ,c.TABLE_NAME
     ,c.COLUMN_NAME
  from INFORMATION_SCHEMA.COLUMNS c
  join INFORMATION_SCHEMA.TABLES t
   on t.TABLE_SCHEMA = c.TABLE_SCHEMA
    and t.TABLE_NAME = c.TABLE_NAME
  where t.TABLE_TYPE = 'Base Table'
  and c.DATA_TYPE like '%char%' ;
/*2. The Open*/
 open Find_StringCursor;
 declare @TableSchema nvarchar(255);
 declare @TableName nvarchar(255);
 declare @ColumnName nvarchar(255);
 declare @sqlstring nvarchar(max);
 create table #Results(
  Table_Schema nvarchar(255),
  Table_Name nvarchar(255),
  Column_Name nvarchar(255),
  RecordCount int
 )
/*3. The Processing Loop*/
fetch_nexxt_Find_String_Cursor:
 fetch next from Find_StringCursor into @TableSchema, @TableName, @ColumnName
 if @@fetch_status != -1 begin
  set @sqlstring = @sqlQuery;
  set @sqlString = replace(@sqlString, '<Table_Schema>', quotename(@TableSchema));
  set @sqlString = replace(@sqlString, '<Table_Name>', quotename(@TableName));
  set @sqlString = replace(@sqlString, '<Column_Name>', quotename(@ColumnName));
  begin try 
   insert into #Results
   exec sp_executesql @sqlString, @paramDef, @Param;
  end try 
  begin catch 
   print error_message();
   print @sqlString
  end catch 
  goto fetch_nexxt_Find_String_Cursor
 end
/*4. The Close*/
 close Find_StringCursor
/*5. The deallocation*/
 deallocate Find_StringCursor

 select *
 from #Results
 where RecordCount != 0;
end 
go
create procedure dbo.FindString
 @SearchValue nvarchar(255)
as begin
 set nocount on;
 set xact_abort on;
 declare @sqltemplate nvarchar(max) = '
  select 
   ''<Table_Schema>'' as ts, 
   ''<Table_Name>'' as tn, 
   ''<Column_Name>'' as cn,
   count(*) as r
  from <Table_Schema>.<Table_Name> a
  where <Column_Name> like @Value
 ';
 
 declare @ParamDef nvarchar(255) = '@Value nvarchar(255)'

 exec dbo.ForEachTable @sqlTemplate, @ParamDef, @SearchValue;
end
go
exec FindString 'John%';

The cost of feeding UK primary school children vs feeding MPs

I’ve seen this image, and just like you, I was wondering how much it actually costs to feed all the primary school children in the country. Based on only 5 minutes of research, I’m able to work out the answer.

To be able to answer a question like this we need to know a few things:

  1. How much does it cost to feed one child per day?
  2. How many days are there in the academic school year?
  3. How many children receive free lunches? Based on the image above, we are restricting this to infant schools.
Once we know this, we can work out the total cost of feeding these children, per year. Then, we want to know how much that costs per taxpayer and compare that to the figure in the image (5.8 million), also per taxpayer. To be able to do that we also need to know.
  1. How many people in the UK are employed?

So, what are the answers?

  1. Between £1 and £2 per day. For simplicity, I’m splitting the difference and using £1.50. This figure comes from The Mirror and is now a few years old. 
  2. 195. That figure comes from Essex County Council school year planner for 2018 / 2019.
  3. 2 million. This was a little bit more difficult to find, and some assumptions have been made. Again, the figures come from 2012. I went to the government’s page on schools, pupils, and their characteristics and downloaded the national tables file. Table 2a lets us know that the total number of pupils in primary state-funded education is just north of 4 million. This covers years 1 through 6. I’ve just halved the value as an assumption that half the pupils are in years 1 through 3.
This gives a cost of  £780 million per year. 
And UK Employment rates?
  1. Between January and March 2017, 32 million. This was taken from the ONS website on the UK labour market page. These are the most up to date figures available at the time of writing.
Based on this, and assuming that we can split the tax bill evenly amongst all works, the cost per taxpayer, per year, is £24.38.
How much does it cost to feed the MPs? 19 pence per taxpayer, per year