Tuesday 1 September 2015

Windows Explorer Preview Add text file type

Create a .reg file

paste this in to it:


Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.properties]
@="properties_auto_file"
"Content Type"="text/plain"
"PerceivedType"="text"


change 'properties' online 3 and 4 to your file extension
(noting the use of '.')

save then double click the .reg file to add it to your registry.

you can now preview the file type in windows explorer's file preview panel.

(no need to restart / relog in or restart windows explorer.)

Wednesday 26 August 2015

C++ none white-space character counter.

paramer 1 path of your text file.
if no paramter is passed it will default to a path.
#include <cstdio>
 
int main(int n, char *c[])
{ 
 char *a = 0 ? "C:\\tests\\nonwhitespacecount\\Debug\\1.txt" : c[1];
 FILE*f = fopen(a,"rb");
 if(f)
 {
  printf("unable to open %s\n", a);
  return 0;
 }
 fseek(f,0,SEEK_END);
 int size= ftell(f);
 char*r = new char[size+1];
 fseek(f,0,SEEK_SET);
 fread(r,1,size,f);
 fclose(f);
 f = fopen("out.txt","wb");
 
 int nonwhitespaces = 0;
 forint i =0; i < size; i++)
 {
  switch(r[i])
  {
   case 32:
   case 9:
   case 0:
   case 13:
   case 10:
    break;
   default:
    nonwhitespaces++;
    fwrite(r+i,1,1,f);
    break;
  }  
 }
 fclose(f);
 printf("nonwhitespaces %d.", nonwhitespaces);
 return 0;
}

Monday 6 April 2015

Diskpart

Diskpart

list disk
Select disk X
online disk (if the disk is not online)
attributes disk clear readonly
clean
convert mbr (or gpt)
create partition primary
select part 1
active (if this is the boot partition)
format fs=ntfs label=(name) quick
assign letter (letter)
list volume
select volume x

Friday 3 April 2015

Samsung S24B150BL squashed display 1920 x 1080


Samsung S24B150BL
This monitor displayed the screen squashed using  VGA 1920x1080, using auto on the monitor did not correct the problem, below are resolution settings that can be set manually.

(Warning: if your monitor is not the above model then look up the correct settings in your user manual otherwise you will damage your monitor)

148.5 clock

horizontal
front porch 48
back porch 152
sync width 80
active 1920
+
scan rate 67.5

vertical
front porch 1
back porch 41
sync width3
active 1080
+
scan rate 60 hz


Tuesday 3 March 2015

Windows 7 Missing Broadcom bluetooth drivers. hardware ID BTHENUM\{0000110e-0000-1000-8000-00805f9b34fb}


After installing all the latest laptop bluetooth drivers provided by my Laptop manufacturer there remained a  unknown devices missing drivers in the Device Manager and no indication what other drivers were needed, windows software update couldn't diagnose, and any findings on google for the hardware ID suggested old drivers already installed. Installing this update from Broadcom resolved them all.

Download updated Bluetooth® for Windows® software
Broadcom WIDCOMM Bluetooth Software for Windows

http://www.broadcom.com/support/bluetooth/update.php

Add extention to windows explorer preview panel.


These steps allow windows to identify and display a file type in the Windows Explorer preview panel.

1. Start->Run->type regedit and press enter.
2. Open HKEY_CLASSES_ROOT\
3. Find the folder extension name ie .xml
4. If it doesn't exist then make it.
5. Create two keys by right mouse clicking in the folder, select new string value.
6. Name: Content Type
7. Value: text/plain
8. Name: PercievedType (one word no spaces).
9. Value: text

Saturday 17 January 2015

Bug in AAA code base.

A typical daily bug to ponder from AAA code base "Redefining the next-generation of technology in games".


The cut down example implements Vector3 - inheriting 4 elements from base, sets 3 elements and asserts calling base::Validation() because the 4th element is never set.

Note.
1. Clearly no use of debug build during development.
2. Unnecessary code in core code.

const unsigned int NAN = 0x7FC00000;

bool ValidateElement( unsigned int value )
{
    return value == NAN ? false : true;
}

class VectorBase
{
private:
    float m_x;
    float m_y;
    float m_z;
    float m_w;
public:  
    VectorBase()
    {
        *((unsigned int *) &m_x) = NAN ;
        *((unsigned int *) &m_y) = NAN ;
        *((unsigned int *) &m_z) = NAN ;
        *((unsigned int *) &m_w) = NAN ;
    }   
    float GetX() { return m_x; }
    float GetY() { return m_y; }
    float GetZ() { return m_z; }
    float GetW() { return m_w; }

    bool Validate()
    {
        return  ValidateElement( GetX() ) &&
                ValidateElement( GetY() ) &&
                ValidateElement( GetZ() ) &&
                ValidateElement( GetW() );
    }
}

class Vector3 : public VectorBase
{
public:
    Vector3() {}
  
    void Set( float x, float y, float z)
    {
        m_x = x;
        m_y = x;
        m_z = x;
    }

    float GetX() { return m_x; }
    float GetY() { return m_y; }
    float GetZ() { return m_z; }
    float GetW() { return 0.f; }
}

int main(int argCount, char*argStr[])
{
    Vector3 v3;

    v3.Set (0.f, 0.f, 0.f);
  
    ASSERT( v3.Validate () );
  
    return 0;
}