Monday, December 23, 2024

Observable pattern- jQuery

 The key concept here is that there is an object, often referred to as the observable/subject whose internal state changes during its lifetime.


There are several other objects, referred to as observers, that want to be notified in the event that the state of the observable changes in order to execute some operations.


In most common implementation, the observable maintains a list with its observables and notifies them when an appropriate state change occurs.


So in case a state change occurs to the observable, it iterates through the list of observers that are interested for that type of state change and execute a specific method that they have defined.


The observers are described as objects that implement a well-known programming interface, in most cases, specific to each observable they are interested in.
In the case of state change, the observable will execute the well known method of each observer as it defined in the programming interface.


// Observable

const WeatherStation = (function () {

    const $observable = $({}); // jQuery object for custom events


    return {

        // Register an observer (subscribe to an event)

        on: function (event, handler) {

            $observable.on(event, handler);

        },


        // Unregister an observer

        off: function (event, handler) {

            $observable.off(event, handler);

        },


        // Notify observers (trigger the event)

        setMeasurements: function (data) {

            console.log("Weather station state changed:", data);

            $observable.trigger("stateChange", [data]);

        },

    };

})();


// Observer

function displayWeather(event, data) {

    console.log(`Current conditions: ${data.temperature}°C, ${data.humidity}% humidity, ${data.pressure} hPa.`);

}


// Usage

$(document).ready(function () {

    // Register the observer

    WeatherStation.on("stateChange", displayWeather);


    // Simulate state change

    WeatherStation.setMeasurements({ temperature: 25, humidity: 65, pressure: 1013.1 });

    WeatherStation.setMeasurements({ temperature: 28.5, humidity: 70, pressure: 1009.2 });


    // Optional: Unregister the observer

    // WeatherStation.off("stateChange", displayWeather);

});

Wednesday, December 18, 2024

chatgpt

 Prompt 1 - Complex Topic Decoder

Break down [Difficult Subject] into 5 core principles. Use real-world metaphors for each. Create mini-challenges to test understanding. Build a 7-day mastery path with quick-win milestones. Include a “clarity score” after each mini-test.

My learning goal: [Learning Goal].

Prompt 2 - Learning Acceleration Blueprint

Design a 21-day rapid learning system for [Topic]. Structure into morning theory, afternoon practice, and evening review. Create dopamine-triggering rewards for each milestone. Include focus-state triggers and retention measurements.

My available time: [Study Time].

Prompt 3 - Knowledge Web Builder

Transform [Topic] into an interconnected concept map. Create memory hooks linking new information to existing knowledge. Design a 5-minute daily review system. Include understanding depth score. Generate quick recall patterns.

My current knowledge: [Current Level].

Prompt 4 - Book Mastery System

Extract core principles from [Book]. Create an action-focused summary with implementation steps. Design a 30-day practice plan for key concepts. Include knowledge application score. Generate real-world testing scenarios.

My learning focus: [Book Topic].

Prompt 5 - Problem-Solving Framework

Build a rapid solution system for [Subject] challenges. Create decision trees for common problems. Include quick-check validation methods—design difficulty progression path. Generate solution speed metrics.

My skill level: [Current Level].

Prompt 6 - Case Study Analyzer

Create a framework to extract insights from [Topic] cases. Build a pattern recognition system. Design implementation roadmap for lessons learned. Include practical application scores. Generate quick-action templates.

My analysis goal: [Analysis Goal].

Prompt 7 - Writing Enhancement System

Develop a daily writing improvement plan for [Style/Purpose]. Create templates for common scenarios. Include style consistency checks. Design reader impact measurements. Generate progress tracking metrics.

My writing goal: [Writing Goal].

Prompt 8 - Interview Success Accelerator

Build a rapid preparation system for [Interview Type]. Create answer frameworks with impact stories. Design confidence-building exercises. Include presence measurement score. Generate quick recovery tactics.

My interview goal: [Interview Goal].

Prompt 9 - Language Learning Optimizer

Design an immersive learning environment for [Language]. Create daily conversation scenarios. Build pronunciation improvement systems. Include fluency progress metrics. Generate quick practice routines.

My language goal: [Language Goal].

Prompt 10 - Hobby Mastery Roadmap

Create structured learning paths for [Hobby]. Break into daily skill-building exercises. Design progress validation system. Include enjoyment-to-effort ratio. Generate skill demonstration opportunities.

My target level: [Desired Level].

Tuesday, December 3, 2024

Graph API

 https://learn.microsoft.com/en-us/graph/delta-query-events?tabs=http