Friday, 17 November 2017

Excellent series for the STEMM enthusiast

This excellently produced series of books, branded under the Sterling Milestones banner follows a consistent format. Each book contains 250 individual ideas encapsulated in a picture and a page of text. Organised in roughly time order each book expands the core ideas and discoveries in a STEMM related field.  

My personal favourite is The Space Book which starts with the big bang, rolling through early discoveries of the planets and calendars towards current activities in space and onwards to how the universe will end. Full of facts and contextual pictures this book really brings alive that unique combination of engineering and exploration which is the discovery and exploration of outer space.

Each book starts with an introduction to the field and finishes with a comprehensive index, Notes and further reading followed by photos credits. Most are offered by Chris Pickover but other authors have some of the titles.

For more details Sterling milestones books 

Is available via Amazon or ABEbooks as usual.

Friday, 10 November 2017

Some of our favourite software died today

Today 10th Nov 2017 the house iMac was upgraded to OSx 10.11 El Captain having happily run on OSx 10.6 Snow Leopard since in in 2009.   Snow Leopard was the last version of Mac OSx that would run PowerPC code ( in emulation mode) so this lays to rest QuarkXPress version 6.5 that was the last vestiges of DTP software used for the other halfs' typesetting business.  Purchased as box software many, many years ago Quark has provided good service but is no longer required. Running OS that is over five years old, that no longer get security updates, is also a bit of risk. Also expiring was the last free version of Mac the Ripper DVD content extraction tool. I have to admire Apple by making it so easy and smooth to do an OS upgrade effectively jumps forward five operating system releases in one go.

The smaller handheld Apple devices upgraded to the latest version of IOS 11.0 recently and this has obsoleted early Apps. My favourite APP was ConvertBot, a little gadget that converted numbers between different units. The software was so well designed and looked so slick that for me it became an early demonstrator for Apple's approach to building a software ecosystem. Many other Apps that have not been updated in the last year or few will also have expired and become unusable. More information here.

Monday, 6 November 2017

Coffee jar plastic top madness

I like a cup of strong flavour instant coffee, I also like to recycle and encourage reduction in packaging. 

In a fit of packaging madness Jacobs Douwe Egberts  lo'r has this most ridiculous plastic top on it's instant coffee. 

551g Total Jar  made up of 
347g of glass          -> 62.3 %
37g   of plastic top ->   6.7 % 
167g of product     ->  30.3 % 

Looking by height 
19cm Total Jar  
16cm Glass     -> 84 %
6.5 cm plastic top -> 15%   which overlaps jar by 3cm and has a further 3cm on top of that.

This type of plastic top is typically non-recyclable ( unlike the glass ) and has no recycling marks identifying the plastic. There is also a plastic film wrapping the glass, which may look nice but does nothing for the recycling process.

Is there a more effective packaging solution ? Yes but the economics don't look great on the latest Morrisons shopping trip.

L'or = £2.34 per 100g
Nescafe gold refill pack = £3.00 per 100g   ( no glass, minimal plastic bag )
66p more expensive for packaging free refill option. Sigh.

Even worse for the environmentally minded Morrisons on-line shopping currently has the refill pack 50p / 100g more expensive than the glass jar version.  6 Nov 2017.



Further advice on Recycling Etiquette. 

Reply from L'or
Thank you for contacting L’Or.
The lid is made of plastic and is recycled through standard plastic recycling bins.
Kind Regards

C**** M******

Consumer Relations Team

Friday, 3 November 2017

Technical Problem to solve - "Five in a bed" Key matching across lists.

I have a technical problem that needs to be solved as part of a larger project that has been in the works for a while. Code development needed.

Starting conditions
Five text files {A..E} that each contain one number on each line.
Each line is a Hex value that has 8 bits set within a 40bit value.
EG: Each file will look like these lines ( order is not important )

The files have between a 5000 and 500,000 lines. On average about 30,000 lines.

Find one or more solution groups of lines, one from each file, that when OR’d together have all 40 bits set (0xFFFFF) but when AND’d together have 0 bit set (0x00000). The answer would deliver results as
repeated for each solution set found. Have the ability to stop after first solution or provide multiple answers is desirable.

Outline size of task - ( updated )
A simplistic approach would take all the lines from the first file and compare with all lines from second file and keep the matching pairs that are then compared against 3rd file and so on. This scales badly as up to 30,000 ^ 5 = 24,300,000,000,000,000,000,000 worst case comparisons may be needed. Further thought reduced this number as any failed comparison between the first two keys would remove the need for further comparisons for that key pair.  Also when 4 keys have been matched locating the last key becomes a trivial look-up for existence in the last key file. To get 4 keys we can generate keys pairs from files A&B and separately from files C&D then just merge the key results. This process would need 3 comparisons making worst case about 30,000 ^ 3 = 27,000,000,000,000 comparisons to find all the matching sets. As we only need 1 matching result 5 key set set, then if we can use a progressive algorithm that does not need all the results from one stage before starting the next stage, the actual number of comparisons would be much less.

Test runs show that from files with 8,172 and 438,761 entries  517,183,384 matching pairs are generated (approx 14% hit rate). The normal size of the files is 30,000 entries.  If this 14% success ratio persists then we would have in the normal case

(( 30000 * 30000 )* 2 * 0.14 ) 

comparisons and final stage lookups.  Which seems do-able.

Structure of answer
Read and prepare file data into data structures.

One possible solution would be to run matches between files A&B and separately files C&D to find second stage candidates. Join the results lists and look-up against file E for final matches. This is one approach but I am open to other possibilities.

It is expected that some sort of pre-organisation of the file keys would be used to reduce the need to compare each key with each other.  Possible some sort of Bloom filter or key grouping ( This is the needed magic bit. )

Technology to be used.
Perl and/or c++
Multi-tasking via threads or standard libraries encouraged 8 or 12 way processors available.
8GB memory, 5TB HDD and/or 250GB SSD.
Typical time to solution 5 minutes or better.
Any c++ should be "standards compliant" and self contained at src level and (highly desirable) to be adjustable to work on W10 or Mac or Ubuntu.
Code should be structured so that it can be trivially built into a larger program or as stand alone utility.

Done a perl prototype.
Usage {-v n -p n} -x n fileA fileB fileC fileD fileE
Each file has a list of numbers 1 each on a line.
Find the lines in the files that have no overlapping bits, IE when & togther make 0. 
-v n  Set verbose level n default 0; 
-p n  Dump partial results after n keys and save mem 10000 is recomended for 2.5GB usage  
      memMode is set from -p and mode =4
-x {1,2,3,4} Run mode 1= A B Pair (default) , 2= C D Pair ,3= Murge previous done runs with fileE
    Run Mode 4= Do all stages in this single process, sets memMode=0;

Normal run would be -x 1 fileA fileB fileC fileD fileE & -x 2 fileA fileB fileC fileD fileE &
wait # till both have finished -x 3 fileA fileB fileC fileD fileE # which will pick up the results and do final murge.

or -x 4 fileA fileB fileC fileD fileE # may run out of memory on big sets

Thursday, 2 November 2017

Bike stand fail - fixed

I have a Ridgeback Flight 3.0 bike kitted out for touring mode but it has a falling over problem.

Quite simply fixed by moving stand attachment forward and cutting off corner of stand to fit.

Before picture

After ...

The stand was only £5 on Amazon and other more adjustable expensive ones are available.

Sunday, 8 October 2017

/usr/bin/cal with added hex output option. Generate Hex calendar ( unix src code )

apply this diff - compile and go. Use -x option to get hex output.

$ diff cal.c  cal_hex.c | sed 's/>/\>/;s/</\</'
>  * Hex version
> int xflag;
< yflag = year = 0;
< while ((ch = getopt(argc, argv, "jy")) != -1)
> yflag = year = xflag = 0;
> while ((ch = getopt(argc, argv, "jyx")) != -1)
> case 'x':
> xflag = 1;
> break;
< len = snprintf(lineout, sizeof(lineout), "%s %d",
<     month_names[month - 1], year);
> if (xflag) { 
> len = snprintf(lineout, sizeof(lineout), "%s 0x%x", month_names[month - 1], year);
> } else {
> len = snprintf(lineout, sizeof(lineout), "%s %d", month_names[month - 1], year);
> }
< (void)snprintf(lineout, sizeof(lineout), "%d", year);
> if (xflag) { 
> (void)snprintf(lineout, sizeof(lineout), "0x%x", year); 
> } else {
> (void)snprintf(lineout, sizeof(lineout), "%d", year);
> }
< (void)snprintf(lineout, sizeof(lineout), "%d", year);
> if (xflag) { 
> (void)snprintf(lineout, sizeof(lineout), "0x%x", year); 
> } else {
> (void)snprintf(lineout, sizeof(lineout), "%d", year);
> }
> static char *hday[] = {
>                 "",
>                 " 1", " 2", " 3", " 4", " 5", " 6", " 7",
>                 " 8", " 9", " A", " B", " C", " D", " E",
>                 " F" ,"10", "11", "12", "13", "14", "15", 
> "16", "17", "18", "19", "1A", "1B", "1C", 
> "1D", "1E", "1F",
>         };
> if ( xflag ) {
> *p++ = hday[day][0];
> *p++ = hday[day][1];
> } else {
> }
< (void)fprintf(stderr, "usage: cal [-jy] [[month] year]\n");

> (void)fprintf(stderr, "usage: cal [-jyx] [[month] year]\n");

I hate polystyrene and Bissell carpet cleaners lies right on the box.

I hate polystyrene and other single-use packaging materials. This single image explains the issue with non-recyclyeable non-biodegradable fragmenting plastic. This bird will be dead soon.

Often used in product shipping boxes as a bulking and holding material.  Alternatives exist and have been widely used by Mobile phone and other product shippers including Apple.

Bissell carpet cleaners are a great machine but the product packaging sucks. Particularly because they have "Sustainable packaging design" boldly printed on the box. The lie of that is just inside with three blocks of polystyrene. Shameful.  The tide is turning in the global awareness of ocean pollution by plastic debris calling out such hypocrisy can only serve to drive the message home.  

At time of writing the URL on the box is redirected to a UK Bissell shop website. Message implementation fail.

Bissell was asked for a comment and this is included below. No mention of the broken URL or acknowledgement of the sustainable packaging message and polystyrene block mismatch.

PS: This article does not refer to Poly Styrene the late singer with X-Ray Specs. :-)

========== Reply  From Bissell ===============
Dear Mr Gannett,
Thank you for contacting Bissell UK.
I am sorry to read of your disappointment with our packaging.
Please be advised I have forwarded your comments and concerns to our head office and this will be taken into consideration for future purposes. At the moment there are no immediate plans to change our packaging or labeling so we are unable to provide you with any timescales of, if and when this will be changed.
I am sorry for the inconvenience caused.
Kind Regards
J******** C******

Customer Service Team