Home Blog Page 3797

PWA push notifications not engaged on iOS Safari (however engaged on android, internet, mac os safari)


I’ve NextJS PWA app and I configured it with VAPID and web-push (nodejs). The notification pops up on all different gadgets (android, internet, mac safari) however not on iphone with safari.

Additional particulars:

  • I’ve tried two completely different telephones: not working
  • iOS model: 17.4
  • sure, i’ve added the PWA to my house display

The bizarre factor is that I do get the push occasion. So the employee.js is working tremendous. However the issue is when displaying the popup e.g. self.registration.showNotification. I’ve tried loads of issues and have been caught with this.

Did anybody else expertise this?

======== Code particulars beneath

That is how my subsequent.config.js is configured:

const isDev = course of.env.NODE_ENV === 'improvement'

const withPWA = require('next-pwa')( {
    dest: "public",
    sw: "sw.js",
    register: true,
    skipWaiting: true,
    disable: isDev
  });

const nextConfig = {
  reactStrictMode: true,
};

module.exports = withPWA(nextConfig);

How I am setting the VAPID particulars:

webpush.setVapidDetails(
        "mailto:[email protected]",
        vapidKeys.publicKey,
        vapidKeys.privateKey
    );

That is what my employee.js appears like:

self.addEventListener("push", async (e) => {
    attempt {
        const { message, physique, icon } = JSON.parse(e.information.textual content());

         // Notify the primary thread to play sound
        const purchasers = await self.purchasers.matchAll();
        purchasers.forEach(shopper => {
            shopper.postMessage({
                kind: 'PLAY_SOUND'
            });
        });

        e.waitUntil(
            self.registration.showNotification(message)
        );

       
    } catch (error) {
        // Ship error log to the primary thread
        self.purchasers.matchAll().then(purchasers => {
            purchasers.forEach(shopper => {
                shopper.postMessage({
                    kind: 'ERROR',
                    message: `Error in push occasion: ${error.message}`
                });
            });
        });
    }
});

self.addEventListener("notificationclick", (occasion) => {
    occasion.preventDefault()
    occasion.notification.shut();

    occasion.waitUntil(
        self.purchasers.matchAll({
            kind: "window",
        }).then((clientList) => {
            for (const shopper of clientList) {
                if (shopper.url === "/" && "focus" in shopper)
                    return shopper.focus();
            }
            if (purchasers.openWindow) return purchasers.openWindow("/");
        })
    );
});

I’ve tried on two completely different iphone gadgets. I’ve tried on android (works), tried on mac os (works).

I’ve tried to debug the Safari context on iOS. I can see that sw.js is loaded correctly and the console logs work (it even triggers a customized occasion I used to debug)

However I feel the issue lies with showNotification which I am unable to determine why.

Google provides Android a pace increase after reminiscence administration improve

0


Android is quickly about to get a pleasant little efficiency increase that ought to make it sooner and extra environment friendly than earlier than. Particularly, Google is engaged on making its OS help {hardware} with 16KB web page sizes.

Right this moment, the corporate revealed a brand new submit on its Android Developer Weblog saying that Android will quickly be page-size agnostic. By page-size agnostic, the agency means Android will help each 4KB and 16KB web page gadgets. The corporate is opening up the choice for builders to change between 4KB and 16KB on the Pixel 8 and Pixel 8 Professional with Android 15 QPR1 Beta 1.

What precisely does this imply for the common consumer? Not a lot in the mean time, however when extra {hardware} begins supporting this, it can increase efficiency and effectivity. As Google explains, it ought to end in movies trying higher, video games performing higher, and apps working extra easily:

In most CPUs, devoted {hardware} known as reminiscence administration models (MMUs) translate addresses from what a program is utilizing to a bodily location in reminiscence. This translation is completed on a page-size foundation. Each time a program wants extra reminiscence, the working system must become involved and fill out a “web page desk” entry, assigning that piece of reminiscence to a course of. When the web page measurement is 4 instances bigger, there may be 4 instances much less bookkeeping. So, the system can spend extra time ensuring your movies look nice, video games play effectively, and functions run easily, and fewer time filling out low-level working system paperwork.

The motive of this announcement is mainly to say that they’re enabling help now so OEMs can begin getting on board. Google states that it noticed a 5-10% increase in total efficiency through the use of bigger web page sizes. Nevertheless, there’s a trade-off the place 9% extra bodily reminiscence is used. We’ll want to attend some time earlier than finish customers such as you and I get to see the advantages of this.

startup – Easy methods to make and use an USB keep on with GParted that may boot on a Mac?

0


I’ll reply my very own query. Since I had lots of bother creating Dwell USBs on Ubuntu and Mac and needed to dig a bit deeper into the topic and also will listing the output of the profitable partition schemes.

  • Obtain .iso from right here underneath “secure releases”. If uncertain, selected the 32bit-Model.

  • Put a USB stick within the slot and look into Disk Utility for its gadget quantity (disk1, disk2, diskX, and so on). This may be discovered by clicking the icon “Data”.

  • Open up a shell

  • Unmount the stick in terminal (nowhere else) with sudo diskutil unmountDisk /dev/diskX

Be sure you do not dd to a incorrect disk, e.g. your working HDD!

  • Copy the downloaded file with sudo dd bs=1m if=file.iso of=/dev/rdiskX

We use the r for uncooked in of=/dev/rdiskX to make the copy quicker. It is best to not be utilizing the s1 extensions: these are partitions on the disk, not the disk itself.

The USB stick then appears like this with diskutil listing:

/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *7.8 GB     disk1
   1:                       0xEF                         3.0 MB     disk1s2

sudo gdisk -l /dev/diskX will present this (aborting the query is feasible with ctrlC):

GPT fdisk (gdisk) model 1.0.1

Partition desk scan:
  MBR: MBR solely
  BSD: not current
  APM: not current
  GPT: current

Discovered legitimate MBR and GPT. Which do you need to use?
 1 - MBR
 2 - GPT
 3 - Create clean GPT
Your reply:

Lastly, sudo fdisk /dev/diskX will present

Disk: /dev/disk1    geometry: 942/255/63 [15138816 sectors]
Signature: 0xAA55
         Beginning       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: 00    0   0   0 -    0   0   0 [         0 -          0] unused      
 2: EF 1023 254  63 - 1023 254  63 [    535612 -       5948] 
 3: 00    0   0   0 -    0   0   0 [         0 -          0] unused      
 4: 00    0   0   0 -    0   0   0 [         0 -          0] unused 

OS X will present a dialog to Initialise…, Ignore or Unmount the USB stick when it’s put into the slot. Clicking Ignore is protected. I put the German screenshot in, I believe it is fairly clear.

dialog upon inserting USB stick

When booting the Mac now press alt or possibility and there needs to be an choice to boot to that is named EFI boot. It will carry up GParted Dwell.

However beware, there are some Macs (e.g. Macbook Professional 17″ Early 2011 that aren’t ready in any respect as well something different from USB than OS X).

Microsoft shares temp repair for Linux boot points on dual-boot programs


Microsoft shares temp repair for Linux boot points on dual-boot programs

​Microsoft has offered a workaround to briefly repair a identified challenge that’s blocking Linux from booting on dual-boot programs with Safe Boot enabled.

The corporate says this non permanent repair will help Linux customers revive unbootable programs displaying “One thing has gone critically incorrect: SBAT self-check failed: Safety Coverage Violation” errors after putting in the August 2024 Home windows safety updates.

Many Linux customers confirmed they had been affected by this identified challenge following this month’s Patch Tuesday, as BleepingComputer reported on Tuesday

These affected stated that their programs (working a variety of distros, together with however not restricted to Ubuntu, Linux Mint, Zorin OS, and Pet Linux) stopped booting into Linux after putting in this month’s Home windows cumulative updates.

The difficulty is triggered by a Safe Boot Superior Focusing on (SBAT) replace designed to dam UEFI shim bootloaders weak to exploits concentrating on the CVE-2022-2601 GRUB2 Safe Boot bypass. When it launched the replace, Microsoft stated the replace wouldn’t be delivered to gadgets the place twin booting is detected.

Nevertheless, after acknowledging the problem this week, it additionally confirmed that “the dual-boot detection didn’t detect some custom-made strategies of dual-booting and utilized the SBAT worth when it shouldn’t have been utilized.”

Linux boot broken by Windows security update
Linux boot damaged after Home windows safety replace (Ok_Work_5257)

​For many who have already put in the August 2024 Home windows updates and may not boot Linux on their dual-boot gadgets, Microsoft recommends deleting the SBAT replace and guaranteeing that future SBAT updates will not be put in.

To try this, you’ll have to undergo the next process:

  1. Disable Safe Boot after booting into your gadget’s firmware settings (this requires totally different steps for each producer).
  2. Delete the SBAT replace by booting Linux and working the sudo mokutil --set-sbat-policy delete command and rebooting.
  3. Confirm SBAT revocations by working the mokutil --list-sbat-revocations command and guaranteeing it is empty.
  4. Re-enable Safe Boot out of your gadget’s firmware settings.
  5. Verify the Safe Boot standing by booting into Linux, working the mokutil --sb-state command, and guaranteeing the output is “SecureBoot enabled.” If not, retry the 4th step.
  6. Stop Future SBAT Updates in Home windows by working the next command from a Command Immediate window as Administrator:
    reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSecureBootSBAT /v OptOut /d 1 /t REG_DWORD

“At this level, you need to now be capable of boot into Linux or Home windows as earlier than. It is a good time to put in any pending Linux updates to make sure your system is safe,” Microsoft stated.

The corporate continues to be investigating the problem with the assistance of Linux companions and can present extra updates when new info is obtainable.

What are Frameworks in Python?

0


Introduction

Think about you’re constructing a brand new skyscraper. You wouldn’t begin with out a blueprint, proper? Equally, when creating software program, having the correct framework is essential. Within the huge world of Python, frameworks act as these blueprints, guiding builders by the development course of. They supply a structured basis, so you’ll be able to give attention to creating spectacular, purposeful functions. On this article, we’ll discover what Python frameworks are, why they matter, and dive into the highest 5 that may elevate your coding tasks from good to nice.

Frameworks in Python

Overview

  • Perceive the idea of frameworks and their function in Python improvement.
  • Establish the highest 5 Python frameworks and their main use instances.
  • Evaluate and distinction the options of those frameworks.
  • Be taught in regards to the strengths and weaknesses of every framework.
  • Acquire insights into how to decide on the correct framework for various tasks.

What are Frameworks?

Frameworks are reusable units of libraries or modules which kinds a construction by which sure sorts of software program will be developed. They reduce down the quantity of labor of the programmer, as a result of there are lots of pre-constructed blocks and a linear framework of labor supplies programmers with fewer difficulties to surmount and lots of duties that may be solved in a relatively comparable method will be addressed in comparable methods.

In Python, frameworks will be categorized based mostly on their main objective:

  • Net Improvement: Frameworks that assist construct net functions.
  • Information Evaluation: Frameworks tailor-made for knowledge manipulation and evaluation.
  • Machine Studying: Frameworks designed to streamline machine studying duties.

Key Traits of Python Frameworks

Understanding the traits of Python frameworks can assist you make knowledgeable selections about which one to make use of. Key traits embody:

  • Modularity: Purposes are usually segmented in to modules based mostly on the structure ensuing to straightforward administration and upkeep.
  • Scalability: They provide options for utility scale; coping with small workloads to large-scale enterprise functions.
  • Safety: A few of the implementing frameworks which are out there have inherent safety options that guard functions in opposition to recognized threats.
  • Neighborhood Assist: A powerful neighborhood can present massive documentation, tips, and third-party plugins for the software program.

Sorts of Python Frameworks

Python frameworks are available in varied sorts, every designed to handle particular improvement wants. Understanding these sorts can assist you select one of the best framework in your mission’s necessities.

Full-Stack Frameworks

Full-stack frameworks will be described as utility frameworks that include many instruments and libraries to assist the front-end in addition to the back-end improvement of internet sites. These frameworks comes with set of parts which supplies nearly all of the wants of database administration to authentication administration, which makes these frameworks a package deal resolution for the event of advanced and complex functions. They often include each device you’ll be able to think about to develop a whole net utility equivalent to a templating engine, an Object relational mapping system, and person administration and routing instruments amongst others.

Use Instances

Full-stack frameworks are most acceptable for use by builders who need to construct enterprise-level net functions quickly. They’re most becoming for the tasks the place a large amount of performance is predicted, the place velocity of improvement and quantity and flexibility of options are paramount. A few of the examples of utility are Content material Administration Techniques, E-commerce options and Company net utility.

Micro Frameworks

Microframeworks are as small and composed of separate elements as doable with the intention to accommodate solely the important options for creating net functions. They don’t have as many functionalities as full-stack frameworks, however they permit for using a number of extensions and libraries based mostly on the mission. Microframeworks go away a lot room for interpretation, to allow builders to implement solely the barest necessities of the structure.

Use Instances

Microframeworks are well-suited for smaller tasks or functions the place simplicity and suppleness are desired. They’re additionally splendid for builders preferring to construct their utility elements from scratch or want a light-weight framework for speedy prototyping. Widespread use instances embody easy net apps, APIs, and tasks the place builders need extra management over the elements they use.

Asynchronous Frameworks

Asynchronous frameworks are designed to deal with concurrent operations effectively, making them appropriate for functions that require real-time processing and excessive efficiency. These frameworks use asynchronous programming strategies to handle a number of duties concurrently with out blocking the execution of different duties. This functionality is essential for functions that contain real-time knowledge, equivalent to chat functions, stay updates, and streaming companies.

Use Instances

Asynchronous frameworks are finest for tasks that must deal with numerous simultaneous connections or duties. They’re notably helpful in eventualities requiring real-time communication, equivalent to chat servers, gaming functions, or any utility with excessive concurrency necessities. Their skill to handle quite a few connections effectively makes them a robust device for particular high-load eventualities.

Specialised Frameworks

Specialised frameworks give attention to particular areas of improvement, providing instruments and options tailor-made to explicit duties or domains. These frameworks are constructed to handle area of interest necessities or improve particular functionalities, equivalent to knowledge evaluation, machine studying, or API improvement. By concentrating on explicit points of improvement, specialised frameworks present focused options that may simplify advanced duties.

Use Instances

Specialised frameworks are perfect for tasks with particular wants that align with the framework’s focus. For example, frameworks designed for machine studying or knowledge evaluation present specialised instruments for dealing with massive datasets and performing advanced computations. They’re beneficial in fields the place domain-specific performance is essential, equivalent to scientific computing, knowledge science, or synthetic intelligence.

Advantages of Utilizing Frameworks

Utilizing frameworks in Python affords quite a few benefits, together with:

  • Elevated Productiveness: Libraries are pre-existing code buildings that assist in rising the velocity of improvement and cut back the time for which a programmer spends on typical coding.
  • Consistency: Growing throughout the framework additionally ensures that the complete code that’s written is inside this framework’s benchmark guaranteeing that the work created is constant and in the usual that’s anticipated.
  • Enhanced Safety: Many of the frameworks have inherent safety mechanisms that mitigate varied weak point and threats thus enhancing the safety of your utility.
  • Neighborhood Assist: Frameworks with an energetic neighborhood supply extra supplies like documentation, tutorials and third occasion plugins serving to with downside fixing and growth of the supplied options.
  • Scalability: Frameworks are constructed to accommodate this and can by no means fail to scale your utility because the customers and knowledge hundreds rise.

Prime 5 Python Frameworks

When diving into Python improvement, selecting the best framework could make all of the distinction. Listed below are the highest 5 Python frameworks that stand out for his or her versatility and highly effective options.

Top 5 Python Frameworks

Django

Django – is a excessive stage net framework that permits to create relatively advanced database oriented websites with little effort. It has built-in admin panel, ORM (Object-Relational Mapping), and it ships with most of improvement instruments builders may want. This make for fast prototyping and pretty elegant, sensible structure. The scalability and the safety choices are the points which make Django extremely most popular to be used in powering all the pieces from easy blogs to advanced functions.

Key Options:

  • Constructed-in Admin Interface: Affords a prepared to make use of admin panel to handle complete knowledge of the applying.
  • ORM (Object-Relational Mapping): Eases knowledge manipulation by offering the developer with methods of accessing databases by direct manipulation of Python objects relatively than utilizing SQL statements.
  • Scalability: Customized made to carry out very properly in dealing with massive volumes of visitors.

Strengths:

  • Complete documentation and a big neighborhood.
  • Constructed-in security measures to guard in opposition to frequent net vulnerabilities.

Weaknesses:

  • Could be heavy and complicated for easy functions.
  • The steep studying curve for newcomers.

Flask

Flask is a light-weight framework specializing in giving a fundamental setup for an online app to start out with out of the field that doesn’t impose or prescribe the listing construction or the dependencies on the applying. Its fundamental design and the truth that it helps using third-party plugins by different elements make it a most popular platform amongst builders who prefer to have management over who compiles their elements. Flask is best suited for small to medium functions and of nice scalability; there exists a myriad of third occasion plugins and extensions.

Key Options:

  • Minimalistic: Comes with the fundamentals, permitting builders so as to add extensions as wanted.
  • Routing: Easy and intuitive routing system.
  • Jinja2 Templating: Highly effective templating engine for rendering HTML.

Strengths:

  • Light-weight and straightforward to increase.
  • Extra management over elements and libraries.

Weaknesses:

  • Requires extra configuration and setup in comparison with Django.
  • Fewer built-in options, which can necessitate extra improvement work.

Pyramid

Pyramid is a versatile and modular framework that permits builders to start out small with easy functions and scale as much as extra advanced techniques. It helps each small and enormous tasks, providing a excessive diploma of configurability. Pyramid’s design encourages builders to decide on the elements they want, whether or not they want to make use of SQLAlchemy for database interplay or the built-in Kotti CMS. It’s praised for its flexibility and fine-grained management over the applying construction.

Key Options:

  • Versatile: Helps each small and enormous functions with minimal boilerplate code.
  • Safety: Contains sturdy security measures to guard functions.
  • Customization: Extremely customizable with assist for varied database backends and authentication techniques.

Strengths:

  • Flexibility in design and configuration.
  • Robust assist for each small and enterprise-level functions.

Weaknesses:

  • Smaller neighborhood in comparison with Django and Flask.
  • Extra configuration wanted for preliminary setup.

FastAPI

FastAPI is designed for constructing fashionable, high-performance APIs with Python 3.6+ based mostly on customary Python kind hints. It’s recognized for its velocity and effectivity, boasting spectacular efficiency benchmarks. FastAPI helps asynchronous programming and is constructed on Starlette for the online components and Pydantic for knowledge validation. Its automated era of interactive API documentation and assist for kind checking make it a terrific selection for creating APIs with minimal boilerplate.

Key Options:

  • Efficiency: Constructed on high of Starlette and Pydantic, providing excessive efficiency for API improvement.
  • Sort Hints: Makes use of Python kind hints to supply automated documentation and validation.
  • Asynchronous Assist: Handles asynchronous requests effectively.

Strengths:

  • Wonderful efficiency and automated API documentation.
  • Simple to make use of with fashionable Python options.

Weaknesses:

  • Comparatively new, so the neighborhood and ecosystem are nonetheless rising.
  • Restricted built-in options in comparison with extra mature frameworks.

TensorFlow

Though TensorFlow is seen as a deep studying library it’s on the identical time thought of a machine studying framework. TensorFlow is Google’s machine studying platform containing varied instruments, libraries and different assets which assist in the creation and administration of latest machine studying fashions. It ranges from creating essentially the most fundamental neural community to coaching huge fashions and working them in manufacturing. The TensorFlow has the harness each the primary stage API for high-level mannequin creation and second stage API for mannequin management on the decrease stage.

Key Options:

  • Versatile: Helps a variety of machine studying duties from neural networks to advanced algorithms.
  • Ecosystem: Contains instruments like TensorBoard for visualization and TensorFlow Lite for cellular functions.
  • Scalability: Designed to scale throughout completely different platforms and units.

Strengths:

  • Highly effective and versatile for machine studying duties.
  • Robust assist from Google and a big neighborhood.

Weaknesses:

  • Could be advanced and have a steep studying curve.
  • Efficiency could fluctuate relying on the duty and implementation.

Selecting the Proper Framework

Deciding on the correct framework is dependent upon your mission necessities, workforce experience, and long-term upkeep issues. Elements to contemplate embody:

  • Mission Dimension and Scope: Bigger tasks may profit from full-stack frameworks, whereas smaller tasks could discover microframeworks extra appropriate.
  • Efficiency Wants: For prime-performance necessities, think about frameworks like FastAPI.
  • Neighborhood and Assist: Go for frameworks with energetic communities and ample assets.

Conclusion

Frameworks are very important within the improvement of python since they act as buildings to the functions being developed. Beginning with the wealthy set of options that Django covers, to the unparalleled efficiency of FastAPI, every framework presents its benefits and the place it must be used. Data of those frameworks permits the builders to pick essentially the most acceptable device that must be used of their tasks; thus rising productiveness on the respective tasks.

All in all, irrespective of an online utility, an API, or a journey into machine studying, frameworks for Python are useful and efficient to amplify the method of improvement. If you use the correct framework you understand that you’re setting up apps that conform to fashionable requirements of reliability and effectivity.

Take a look at our complete Python course that covers all the pieces from the fundamentals to superior subjects. It’s an effective way to solidify your understanding of Python and get hands-on expertise.

Often Requested Questions

Q1. What’s a Python framework?

A. A Python framework is a pre-built set of libraries and instruments that gives a construction for creating functions, simplifying duties, and rushing up improvement.

Q2. Which framework is finest for net improvement?

A. Django and Flask are each common selections for net improvement, with Django providing a complete function set and Flask offering flexibility and ease.

Q3. What’s the distinction between Django and Flask?

A. Django is a full-featured framework with many built-in elements, whereas Flask is a micro-framework that gives extra flexibility and requires extra configuration for superior options.

This fall. Is FastAPI appropriate for newcomers?

A. FastAPI is designed for ease of use and fashionable Python options however could also be extra advanced for newcomers in comparison with easier frameworks like Flask.

Q5. How does TensorFlow differ from different frameworks?

A. TensorFlow is targeted on machine studying and deep studying, providing instruments and libraries for creating and deploying machine studying fashions, in contrast to general-purpose net improvement frameworks.