Tuesday, March 03, 2020

Unlinking Google Chrome and NYTimes

Need to go to 'subscriptions'
(yup, even though you didn't actually suscribe to anything).


https://myaccount.google.com/payments-and-subscriptions


Saturday, December 14, 2019

filename up to the extension and creating a new filename

Just dropping this here for now.

void getFilenameWithNoExtensionAndCreateANewFilename()
{
char *arg= (char *)"foobar_filename.ppm";
char output_filename[256];

char* ptrToPPMStart = NULL;
char* ptrCopyFrom = NULL;

char buf[80] = { 0 };
int i = 0;

ptrCopyFrom = arg;
ptrToPPMStart = strrchr(arg, '.');

while (ptrCopyFrom != ptrToPPMStart) 
{
// printf("copying %c\n", *ptrCopyFrom);
buf[i] = *ptrCopyFrom;
i++;
ptrCopyFrom++;

}

buf[i] = '\0';

printf("%s\n", buf);


strcpy_s(output_filename, "output_");

//from this create a new filename
strcat_s(output_filename, arg);

printf("output_filename: %s\n", output_filename);
}

Wednesday, December 11, 2019

Allocating of heap memory inside function with doubly nested pointers

just a cut/paste of template/pattern code here so i don't have to spend 10 minutes dancing with the compiler.

#include
#include
#include

#define SIZE 10

void fooAllocator(unsigned int** image)
{
*image = (unsigned int *) malloc(SIZE * sizeof(unsigned int));

if (*image != NULL) //resolves MSVC compiler error, just a little test before the real loop
{
(*image)[7] = 14;
}
for (int i = 0; i < SIZE; i++)
{
(*image)[i] = 66;
}
}

void fooWriter(unsigned int* image)
{
for (int i = 0; i < SIZE; i++)
{
image[i] = 42;
}
}

void printImage(unsigned int* image)
{
for (int i = 0; i < SIZE; i++)
{
printf("[%d]=%d\n", i, image[i]);
}
}

int main()
{
unsigned int* image = NULL;

//function that allocates memory for image
fooAllocator(&image);
printImage(image);
fooWriter(image);
printImage(image);

for (int i = 0; i < SIZE; i++)
{
image[i] = 36;
}

printImage(image);
return 1;
}

Thursday, October 17, 2019

multidimensional arrays in C on heap

For future reference I have 3D arrays below as sample snippet


//want to work on a 3D array on the heap
//first lest get a single then a 2D array working correctly on the heap

#define IMAGE_WIDTH 4
#define IMAGE_HEIGHT 3
#define CHANNELS 2

void experiment6()
{
int* array1D = NULL;
int* array2D = NULL;
int* array3D = NULL;

array1D = (int*)malloc(IMAGE_WIDTH * sizeof(int));
for (int i = 0; i < IMAGE_WIDTH; i++)
{
array1D[i] = i;
}
for (int i = 0; i < IMAGE_WIDTH; i++)
{
printf("[%d]=%d ",i, array1D[i]);
}

printf("\n");

array2D = (int*)malloc(IMAGE_WIDTH * IMAGE_HEIGHT * sizeof(int));
for (int i = 0; i < IMAGE_HEIGHT; i++)
{
for (int j = 0; j < IMAGE_WIDTH;j++)
{
array2D[i * IMAGE_WIDTH + j ] = i * IMAGE_WIDTH + j;
}
}
for (int i = 0; i < IMAGE_HEIGHT; i++)
{
for (int j = 0; j < IMAGE_WIDTH; j++)
{
printf("[%d]=%d ", i * IMAGE_WIDTH + j, array2D[i * IMAGE_WIDTH + j]);
}
printf("\n");
}

array3D = (int*)malloc(IMAGE_WIDTH * IMAGE_HEIGHT * CHANNELS * sizeof(int));
for (int i = 0; i < IMAGE_HEIGHT; i++)
{
for (int j = 0; j < IMAGE_WIDTH; j++)
{
for (int k = 0; k < CHANNELS; k++)
{
array3D[(i* IMAGE_WIDTH * CHANNELS) + (CHANNELS*j) + k] = (i * IMAGE_WIDTH  * CHANNELS) + (CHANNELS * j) + k;
//printf("%d ", i * IMAGE_WIDTH * CHANNELS + CHANNELS*j + k);

}
}
}

for (int i = 0; i < IMAGE_HEIGHT; i++)
{
for (int j = 0; j < IMAGE_WIDTH; j++)
{
for (int k = 0; k < CHANNELS; k++)
{
// array2D[(i * IMAGE_WIDTH  CHANNELS) + (CHANNELS * j) + k] = (i * IMAGE_WIDTH * CHANNELS) + (CHANNELS * j) + k;
printf("[%d] = %d ", i * IMAGE_WIDTH * CHANNELS + CHANNELS*j + k, array3D[(i * IMAGE_WIDTH * CHANNELS) + (CHANNELS * j) + k]);
}
}
printf("\n");
}


if (array1D != NULL) 
{
free(array1D);
}
if (array2D != NULL)
{
free(array2D);
}
if (array3D != NULL)
{
free(array3D);
}


}

Monday, October 14, 2019

git (gitlab) windows password reset not propagated correctly

After you change your password, this doesn't propagate to the windows credential manager passwords. I went and manually modified each one and that seems to work.


Even easier for me:
Had a bunch of tokens, removed them all related to git repos in windows credential manager. Exit and restarted sourcetree. Forces a request for a new token.


Monday, October 07, 2019

debugging with symbols (VTune)

good article here:
https://docs.microsoft.com/en-us/windows/win32/dxtecharts/debugging-with-symbols

I used this syntax:
srv*c:\temp\msft\symbols*https://msdl.microsoft.com/download/symbols

looks like it worked.

This article makes you think you can get nvidia symbols, but you can't if you read it carefully. They are just using that server to allow retroactive driver binaries to be pulled.
https://developer.nvidia.com/nvidia-driver-symbol-server

Tuesday, August 27, 2019

vsync enable/disable

type: nvidia control panel, find vsync