Daily Post Image from Upsplash

July: 31

2024

Action Action system for the dialgoue system. I am going to start the base interface and then extend it around to see if we can utilize it with the event handler. The best approach would be to split the Action system into its own dexie database and then work from there?

Credit It is the that time of the month and we need to pay off our credit cards! I am making sure that everything has a payment but I am thinking of placing all the credit balances back into a negative. So instead of having just a $0 balance on the cards, the plan is to send them all a couple thousand and have them operate such that they owe me credit.

Optimization We can do a couple more unique tricks for the javascript optimization within Cryptothrone. The first approach will be to expand and improve the movement of javascript objects, including the ability to save them into the indexeddb and manually ensure they are sent to destruction. While working directly with the javascript Uint8Array and rust Vec<u8>, we can setup two unique instances of Spinoza style objects. For this we could use Deku for Binary and Serde for JSON, and all of this should be placed into our JEDI crate. As GPT stated, Storing objects as JSON is a straightforward and commonly used approach because it preserves the structure and data types of JavaScript objects. However, for certain types of data, such as images, files, or large arrays of numbers, it might be more efficient to store them in a binary format. This can reduce storage size and improve performance when handling large amounts of data. We already place the npc images into the indexeddb already, but to avoid having our code break, we could build a new part of the package to focus on it. This was the original optimization function:


function serializeObject(obj) {
    return new Blob([JSON.stringify(obj)], { type: 'application/json' });
}

However we could use this basic function:


function serializeToBinary(obj) {
    if (obj instanceof ArrayBuffer) {
        return new Blob([obj]);
    } else {
        return new Blob([JSON.stringify(obj)], { type: 'application/json' });
    }
}

A little bit of a cleaner function:


function serializeObject(obj) {
    try {
        if (obj instanceof ArrayBuffer) {
            return { type: 'ArrayBuffer', data: new Blob([obj]) };
        } else if (obj instanceof Blob) {
            const supportedTypes = ['image/png', 'image/jpeg', 'image/gif', 'audio/ogg', 'audio/mp3'];
            if (supportedTypes.includes(obj.type)) {
                return { type: obj.type, data: obj };
            } else {
                throw new Error('Unsupported Blob type: ' + obj.type);
            }
        } else {
            return { type: 'application/json', data: new Blob([JSON.stringify(obj)], { type: 'application/json' }) };
        }
    } catch (error) {
        console.error('Serialization error:', error);
        return null;
    }
}

Hmm, we should move the supportedTypes as an optional type, thus making this a more extendable function. The updated serialize function that we will be using.

function serializeObject(obj, options = {}) {
    try {
        if (obj instanceof ArrayBuffer) {
            return { type: 'ArrayBuffer', data: new Blob([obj]) };
        } else if (obj instanceof Blob) {
            if (options.supportedTypes && options.supportedTypes.includes(obj.type)) {
                return { type: obj.type, data: obj };
            } else if (!options.supportedTypes) {
                return { type: obj.type, data: obj };
            } else {
                throw new Error('Unsupported Blob type: ' + obj.type);
            }
        } else {
            return { type: 'application/json', data: new Blob([JSON.stringify(obj)], { type: 'application/json' }) };
        }
    } catch (error) {
        console.error('Serialization error:', error);
        return null;
    }
}

//
const options = {
    supportedTypes: ['image/png', 'image/jpeg', 'audio/ogg', 'audio/mp3'] // Customizable supported types
};

// Additional exampls of usage!

// 1. Regular JavaScript object
const myObject = { name: 'example', data: [1, 2, 3] };
const serializedObject = serializeObject(myObject, options);
console.log('Serialized Object:', serializedObject);

// 2. ArrayBuffer
const myArrayBuffer = new Uint8Array([1, 2, 3]).buffer;
const serializedArrayBuffer = serializeObject(myArrayBuffer, options);
console.log('Serialized ArrayBuffer:', serializedArrayBuffer);

// 3. PNG file (Blob)
const pngBlob = new Blob([/* binary data */], { type: 'image/png' });
const serializedPngBlob = serializeObject(pngBlob, options);
console.log('Serialized PNG Blob:', serializedPngBlob);

// 4. JPEG file (Blob)
const jpegBlob = new Blob([/* binary data */], { type: 'image/jpeg' });
const serializedJpegBlob = serializeObject(jpegBlob, options);
console.log('Serialized JPEG Blob:', serializedJpegBlob);

// 5. MP3 file (Blob)
const mp3Blob = new Blob([/* binary data */], { type: 'audio/mp3' });
const serializedMp3Blob = serializeObject(mp3Blob, options);
console.log('Serialized MP3 Blob:', serializedMp3Blob);

Next, here is the updated deserialize object function.


function deserializeObject(serialized, options = {}) {
    try {
        if (!serialized || !serialized.type || !serialized.data) {
            throw new Error('Invalid serialized object format');
        }

        const { type, data } = serialized;

        if (type === 'ArrayBuffer') {
            return data.arrayBuffer().then(buffer => buffer);
        } else if (type === 'application/json') {
            return data.text().then(text => JSON.parse(text));
        } else if (options.supportedTypes && options.supportedTypes.includes(type)) {
            return data;
        } else if (!options.supportedTypes) {
            return data;
        } else {
            throw new Error('Unsupported type for deserialization: ' + type);
        }
    } catch (error) {
        console.error('Deserialization error:', error);
        return null;
    }
}

const deserializationOptions = {
    supportedTypes: ['image/png', 'image/jpeg', 'audio/ogg', 'audio/mp3'] 
};

deserializeObject(serializedObject, deserializationOptions).then(deserialized => {
    console.log('Deserialized Object:', deserialized);
});

2023

  • 9:30am - Prepare legal documents for my uncle? Ugh this was a task that I hate doing because talking to lawyers has always been a pain.
  • 10:33am - I need to redo my gym schedule, I might have to do something a bit more hardcore and maybe do the duel trips? Aim for both a day and night trip, just to get out of the house and get some more data on FSD.
  • 2:30pm - The lag on league of legends is starting to get to me! It just seems to be way too much recently, the spikes are a bit draining.
  • 2:37pm - I will finish up this basic account page and get it functional enough to push to the main branch.
  • 3:06pm - I noticed that I was running out of space on my computer, so I think it might be time to do a bit of quick cleaning. I was at 72gb free and now I am at 134gb free, however I could remove some of the games on my computer but we all know that will not be happening. Cleaned up my downloads folder and now I am at around 170gb free. This should be enough for now, once I tackle my github folder, that will sum up a decent chunk.
  • 9:05pm - The most recent patch-july-30-2023 patch was a bit too much code, I am going to scale it back to smaller patches, so that there will not be massive changes inside of just one patch.

Quote

For it was not into my ear you whispered, but into my heart. It was not my lips you kissed, but my soul. — Judy Garland


Tasks

  • [ ]