Sunday, 2 September 2018

Splitting and cropping scanned images

Recently I've been trying to scan lots of photos at once.  The problem is each scan takes a long time and some of them are slightly skewed.

I was looking online for a free solution and thought this was free but it isn't:
http://autosplitter.com/

This looks like a good option since it's just a GIMP extension.
http://francoismalan.com/2013/01/how-to-batch-separate-crop-multiple-scanned-photos/

Wednesday, 24 September 2014

Diary of my extension

Architects drawings / planning permission

I'm planning on building an extension with the help of my dad who is an experienced builder.  I am most definitely not - my girlfriend calls me 'half-a-job' when ever I start a DIY project.
First of all we found an architect and got the plans passed for planning permission and building regulations.
Cost to date: £1493

Week 1: Sat 29/8/14 Digging footings

Aiming to dig down to 70cm below ground level.  Came across a couple of pipes so we left these and didn't dig under in case they broke.  Stopped when some level of knowledge was required (the accurate bit of the digging)



Week 2: Sat 5/9/14 Finishing the footing digging

Read the plans: The concrete needs to be at a depth of 90cm (and at least 20cm deep).  The concrete trench had to be 2' wide (we made it 2'2).  Dug under the upper pipe and the lower pipe (including its concrete).  The trench needed to be 6" outside the edge of the walls.
The building inspector confirmed that this was OK.


Week 3: Sat 13/9/14 Concrete in footings

Hammered in vertical planks to attach horizontal planks to.  This makes for a neater concrete trench.
Concreted over the 2 pipes ('haunching') - adding bricks round the pipes made this easier.
The far left corner wasn't as deep as the rest of the trench (due to the upper pipe) so we stepped the concrete upwards.  This was achieved by adding a concrete block as a dam (but the concrete is continuous because the block was rested ON the lower concrete)
Cost to date: £1723


Week 4: Sat 20/9/14 Starting to build to damp proof course

We started building from the top corner of the extension having carefully measured its location and checked we were building square rather than a parallelogram.  We added strings to show the 2 lines we wanted to build to. Plenty of spirit level work to ensure vertical / horizontals were correct. Also we needed to ensure that the top layer of bricks (where we start red bricks) is at the correct level to match the existing ones.  The basic maths of this is 9" for a concrete block and 3" for a concrete common - though this seems to disregard the different thicknesses of cement??
We built over the 2 pipes using strong concrete lintels which have steel inside.
Every 75cm on every other level of bricks we needed to add wall ties (which are now stainless steel and are no longer shaped like butterflies)
Meanwhile we moved all the concrete bricks and concrete commons round to the back on to pallets in preparation.  We also covered these in case of rain.
The cement we used started off with less water so we could build the initial flat bed from the base of the concrete.  After that we made it wetter so it was easier to 'throw' while building between bricks.
Cost to date: £2232

Week 5: Sat 27/9/14 Damp proof course completion

Today we added washing up liquid to the cement as a 'plasticisor' because the sand was so poor quality last week.  We built the inner and outer walls up to the damp proof course level.  There were a lot of bricks which needed to be cut to size - when you cut the angled part off a standard red brick this is called 'knocking off the pig'.  Random!  The cement needs to set for a couple of days and then I will fill the hole in:
A 9" gap then room for 4" of concrete / sand / Visqueen then 8" of hardcore and 10" of clay / rubble.
After that I will fill in the outer gap with any left over hardcore.
On Wednesday I filled in the clay / hardcore levels ready for dad coming on Thursday.
I mixed some weak concrete (10-1) to put down the cavity.  We 'blinded' the hardcore with sand and then put down some Visqueen and 4" of oversight concrete (6-1).  We 'tamped' the oversight concrete with a long bit of wood. Then we built up the outer skin to the level of the inner.
Friday the building inspector came and passed the work.

Week 6: Sat 4/10/14 Building the walls

This week I had to help Luke the brick layer by keeping him in cement (4-1).  Turns out it's also called 'gobby' and 'gear' and you put it on a 'ligger board'.  I also had to provide cut bricks/blocks.
Cost to date: £3598

Week 7: Sat 11/10/14 More walls

This week Luke came again and built up the walls.  The plan was to work Sat and Sun but we ran out of building sand!  Meanwhile we took down the facia and the end of the bay window.  I also went to a roofing place and bought 24 Rosemary tiles for above the french doors and a bag of broken blue slates for packing the RSJs / beams.
On the Friday we knocked out the door where the far side of the large RSJ will go and sawed through the floorboards.  After that we dug down to add footings ready to build a pillar for the RSJ.
Cost to date: £3798

Week 8: Sat 18/10/14

Luke put in a long day to try and get the walls finished but we ran out of light.  Still a lot of progress for one day.
Cost to date: £4483

Week 9: Sat 25/10/14

Dixie knocked out the kitchen window and boarded it up and also built the pillar which will support the RSJ.  Craig came to fit the 2 french doors.
Cost to date: £6304.3

Week 10: Sat 1/11/14

A cock-up (but not a fully blown cock-up-delux) with the french doors.  The gap at the top was too big so Luke came over again and we dropped the 2 lintels down a brick.  This involved acro propping the bricks from the inside then taking out the lintel and moving it down.  After this we filled in the gap on the inside using half bricks.

Week 11: Sat 8/11/14

This was the scary week!  We got lots of people round to help lift the 6.5m 270kg RSJ in to place.  It was quite a difficult operation especially because the plans were wrong - they said there should be an RSJ perpendicular to the new one but it was a concrete lintel instead.  We will have to do something to make the lintel stronger before we finish.  We gradually lifted the RSJ in to place using tressel tables and then Dixie secured it in to place with concrete lintels and blue slate.
Cost to date:£7194

Week 12: Sat 15/11/14

Just keeping things ticking along this week.  We built the pillar under the far side of the RSJ and put the wall plate on the extension.

Week 13: Sun 23/11/14

We hired an electromagnetic drill to make holes in the 2 large RSJs so that we can bolt on 2 more RSJs to hold up the bathroom wall.  Unfortunately we didn't manage to finish the job because the drill bit was too short for some of the holes and there was a concrete lintel in the way for some more holes.  We will tackle it again next week..  Dixie is back Monday so we should show more progress.
Cost to date: £7539

 Monday Dixie filled in the hole above the door and started fitting the door frame.  He also laid the pipes ready to put in a radiator on the back wall.
Wednesday and Thursday he fit 2 radiators and managed to get the 2 RSJs in below the concrete lintel.  A major success when morale was starting to get low!!  Look at these - they are a thing of beauty!  Oh and I bought the final 3 RSJs for dad to collect..
Cost to date: £8300


Mon 1/12/14

Dixie and Mark came and put in an RSJ beneath the bay window. They also put the beams on the roof using joist hangers on the bay window side.

Thu 4/12/14

Dad came over and we worked on the flat roof.  We nailed the beams in to place with 45cm gaps between them.  Then we cut the beams to the correct length (just past the end of the brickwork) and used the offcuts in the 45cm gaps.  We cut the chipboard to the correct size and then nailed those in to place on the roof.  Dad went home and I painted bitchumen paint on to the wood. Friday we extended the width of the roof using more 45cm beams and then some extra chipboard.  After painting the new chipboard we got the big gas bottle on the roof and put the first layer of felt on.  We did this by rolling up the felt and then heating it up as we unrolled it.  The first layer of felt runs parallel with the bay window.

Thu 18/12/14 

My brother-in-law Craig came up from Cornwall to help for a few days and dad came over to supervise.  We managed to get the 2 remaining RSJs in holding up the internal and external wall where the bay window is.  We decided to put them up against the floor boards of the ceiling above for added support.  Very happy days!  Though we did find a crack in the bathroom wall and the door won't lock any more...

Fri 19/12/14

Craig started fitting the door frame and laid the final few courses of brick around the side of the extension.


Sat 20/12/14

We worked on finishing the flat roof - the far side needed building out further than the brick work and the side of the bay window needed to be done.  We knew there was a pipe running down the side of the house and nearly cut it off (we thought it was a central heating overflow).  Until we figured out it was a gas pipe.  I text Colin the plumber and he just turned up out of the blue to sort it all out!  He moved the pipe inside the bay window so it will be easier to keep water tight.  What a legend!  Meanwhile me and Craig removed all the tiles from the bay window and filled the gaps with insulation.
Craig finished fitting the door frame.
Cost to date: ~£10500

Sun 21/12/14 - Mon 22/12/14

We continued working on the flat roof - filling the gap between the bay window and the pitched roof.  Then we finished off the wood required on the other side of the bay window.  Next we started felting the roof with the nice green felt until the dark got the better of us.
Craig carried on fitting the door - planing and drilling it.
Monday we finished the roof.

Fri 26/12/14

Rain.  In the house.  Sufficed to say today was a low ebb!  Tomorrow will be mainly ringing roofers to try and sort it out.  Laura somewhat lost the plot and was "infuriated with my inadequateness"! 

Sun 28/12/14 - Wed 31/12/14

Dad is bringing a roofer on Tuesday (after one quote for £650 and another for £200) and we have organised an electrician for Friday.  I started knocking down the bay window but ran out of daylight before I finished.
Monday I knocked the rest down as far as damp proof course ready to put the joists on. Tuesday dad came over and we insulated the ceiling and laid the joists.  Wednesday the roofer came and sorted out roof by: taking up the first 2 rows of tiles and putting green felt under, finishing off where the felt will meet the gutters and putting damp behind the top layer of tiles on the bay window.
Cost to date: £11163

Fri 2/12/14 - Mon 5/1/15

Friday the electrician came and did the first fixing.  Also Colin came and did the pipes for the 3rd radiator (in the extension bit).  Saturday dad came over and we laid the floor boards.  Craig came up and began boxing the various RSJs ready for plaster board.  Sunday/Monday Craig continued plaster boarding and removed the small nib.

Fri 9th-Mon 18th

Craig came back up north to finish the plaster boarding and do the plastering. He also put the gutters on and laid the back steps.
Cost to date: £13249

Up to 28/1/15

Painted everywhere, radiators all on, bought the flooring and electrics finished.
Cost to date: £14800

 17/3/15 Declaration of done!

Ok so there are a LOT more little things left to do but I'm declaring the blog posts done!  Would I do it again?  Yes though it has been hard and stressful.  Now we've had time to enjoy the space I don't just see it as a list of jobs waiting to be done.  Here is the finished product (click to open)..  Barring pictures and settees and more glossing and.....

Tuesday, 15 July 2014

SQL to dynamically create filtered statistics

Comment the @sql lines in/out appropriately to drop the statistics after use.
DECLARE @df nvarchar(32),@sql nvarchar(1000)
DECLARE tblcur CURSOR STATIC LOCAL FOR
    select top 2 * from ( SELECT distinct(Id) from MyTable )x
OPEN tblcur
WHILE 1 = 1

BEGIN
    FETCH tblcur INTO @df
    IF @@fetch_status <> 0
        BREAK
    --select @sql = 'DROP STATISTICS MyTable.DF_'+@df;
    select @sql = 'CREATE STATISTICS DF_'+@df+' ON MyTable (Id) WHERE Id = ''' +@df+ ''';';
    --EXEC sp_executesql @sql
    print @sql

END
DEALLOCATE tblcur

Tuesday, 5 November 2013

SQL to produce 1..100 as a comma separated string

WITH t AS (SELECT 1 id UNION ALL SELECT id + 1 FROM t WHERE id < 100)
SELECT STUFF((
         SELECT ', ' + CAST(id AS nvarchar(max))
         FROM (SELECT id FROM t) y
         FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 1, '')

Thursday, 12 September 2013

Problems with static_assert(sizeof(X)) upgrading to VS 2013

While upgrading to VS 2013 I encountered several changes to sizeof classes which stopped me from compiling:

static_assert(sizeof(QESQLSelect) == 188, "You probably have more cloning to do?");

Presumably stl has changed it's implementation so the sizes are different between versions.

The link below shows how to change compile options to show the sizeof to use.
http://blogs.msdn.com/b/vcblog/archive/2007/05/17/diagnosing-hidden-odr-violations-in-visual-c-and-fixing-lnk2022.aspx

Summary:
Add the following option and compile your cpp.  (Remember to remove the option afterwards)
I also used this option in the past to reduce the memory usage of my application.

This produces the following in the output window:

class QESQLSelect size(164):
+---
| +--- (base class QESQLSelectBase)
0 | | {vfptr}
| +---
4 | m_bCheckDistinctColumns
| <alignment member> (size=3)
8 | m_nDBType
12 | m_bDistinct
| <alignment member> (size=3)
16 | m_nTopN
20 | m_bHasImplicitOrdering
21 | m_bCount
| <alignment member> (size=2)
24 | QESQLColumnList m_selectedColumns
40 | ?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@ m_strTableOrAliasName
44 | m_pAlternativeSQLSuffix
48 | m_pOptionalSubQuery
52 | ?$auto_vector@PAVQESQLJoinCondition@@ m_joinConditions
68 | ?$auto_vector@PAVQESQLCrossApplyCondition@@ m_crossApplyConditions
84 | ?$auto_vector@PAVQESQLWhereCondition@@ m_whereConditions
100 | ?$auto_vector@PAVQESQLHavingCondition@@ m_havingConditions
116 | m_pGroupBy
120 | DimensionalRollupType m_RollupType
124 | m_pOrderBy
128 | m_pWithSelect
132 | m_pConnectPrior
136 | ?$vector@V?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@V?$allocator@V?$CStringT@_WV?StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@std@@ m_vecOracleHints
152 | m_pVecSQLServerHints
156 | ?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@ m_strComment
160 | ?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@ m_strSimpleTableAlias
+---

 
So I know to change the code to:
static_assert(sizeof(QESQLSelect) == 164, "You probably have more cloning to do?"); 

Note as of VS 2017 the flag seems to have been removed however d1ReportAllClassLayout still works.
Note again - it's a capitalisation problem.. use /d1reportSingleClassLayout

Wednesday, 31 July 2013

Navigating code which uses IoC

Recently I've been navigating around lots of code which uses interfaces to implement Inversion of Control.  The problem is that every time you use F12 to 'Go To Definition' you are taken to the interface, not any of the available implementations.  Most of the time there is only one real implementation, the other(s) are for unit tests.
 
Here are your quick navigation options:

 

Put interface and implementation in the same file

A low-tech option is just to put the main implementation of the interface in the same file as the interface itself.  In reality this is often not an option.

 

Call Hierarchy

You can use the built in 'Call Hierarchy' (Ctrl+k, Ctrl-t) to show implementations of the given function.
 

 

Productivity Power Tools

Productivity Power Tools (see here) allow you to click on the interface name and see 'Implemented By'.  You can then open the list of functions to get to the function you need.

 

Code Rush

There's a plugin for CodeRush here but I couldn't get it to work (even after I remembered to Unblock the downloaded DLL).  Also I found that CodeRush made my IDE grind to a halt (the solution is VERY large)

 

Visual Assist X

Visual Assist doesn't help (but also doesn't hinder any of the other options)

 

ReSharper

Apparently if you have ReSharper then ALT+END will find all implementors.
 
Note these hints are a summary of this post.
Visual Studio user voice suggestion that the functionality is added (here)