Skip to content
Menu
Open World News Open World News
  • Privacy Policy
Open World News Open World News

Category: News

Blog Website Par Progress Bar Kaise Lagaye | Blog Website Progress Bar | Blogging Buzz

Posted on May 4, 2024 by Michael G
Blog Website Par Progress Bar Kaise Lagaye | Blog Website Progress Bar | Blogging Buzz | Please Don’t forget to LIKE, COMMENT SHARE & SUBSCRIBE …

Related Keyword –
blogger progress bar
blogger progress bar tutorial
add progress bar in blogger
blogger customization
blogger tips and tricks
website progress bar
HTML progress bar
CSS progress bar
JavaScript progress bar
Youtube Progress Bar
Website Loading Bar
Website Loading

Please Follow Me On Social Media Links –
Facebook – https://www.facebook.com/bloggingbuzz…
Instagram – https://www.instagram.com/blogging_buzz/
Dailymotion – https://www.dailymotion.com/bloggingbuzz

Website Link –
Website – https://tinyurl.com/4w66uva3

Copyright Disclaimer under section 107 of the Copyright Act of 1976, allowance is made for “fair use” for purposes such as criticism, comment, news reporting, teaching, scholarship, education, and research. Fair use is a use permitted by copyright statutes that might otherwise be infringing.

Women’s day celebrations 2024 – SheLeads and WITc

Posted on May 4, 2024 by Michael G
“நிமிர்ந்த நன்னடை நேர்கொண்ட பார்வையும்,நிலத்தில் யார்க்கும் அஞ்சாத நெறிகளும்,திமிர்ந்த ஞானச் செருக்கும் இருப்பதால்செம்மை மாதர் திறம்புவ தில்லையாம்;அமிழ்ந்து பேரிரு ளாமறி யாமையில்அவல மெய்திக் கலையின் றி வாழ்வதைஉமிழ்ந்து தள்ளுதல் பெண்ணற மாகுமாம்உதய கன்ன உரைப்பது…

Joachim’s blog: Refactoring with Rector

Posted on May 4, 2024 by Michael G

Rector is a tool for making changes to PHP code, which powers tools that assist with upgrading deprecated code in Drupal. When I recently made some refactoring changes in Drupal Code Builder, which were too complex to do with search and replace regexes, it seemed like a good opportunity to experiment with Rector, and learn a bit more about it.

Besides, I’m an inveterate condiment-passer: I tend to prefer spending longer on a generalisation of a problem than on the problem itself, and the more dull the problem and the more interesting the generalisation, the more the probability increases.

So faced with a refactoring from this return from the getFileInfo() method:

    return [
      'path' => '',
      'filename' => $this->component_data['filename'],
      'body' => [],
      'merged' =>$merged,
    ];

to this:

    return new CodeFile(
      body_pieces: $this->component_data['filename'],
      merged: $merged,
    );

which was going to be tedious as hell to do in a ton of files, obviously, I elected to spend time fiddling with Rector.

The first thing I’ll say is that the same sort of approach as I use with migrations works well: work with a small indicative sample, and iterate small changes. With a migration, I will find a small number of source rows which represent different variations (or if there is too much variation, I’ll iterate the iteration multiple times). I’ll run the migration with just those sources, examine the result, make refinements to the migration, then roll back and repeat.

With Rector, you can specify just a single class in the code that registers the rule to RectorConfig in the rector.php file, so I picked a class which had very little code, as the dump() output of an entire PHP file’s PhpParser analysis is enormous.

You then use the rule class’s getNodeTypes() method to declare which node types you are interested in. Here, I made a mis-step at first. I wanted to replace Array_ nodes, but only in the getFileInfo() method. So in my first attempt, I specified ClassMethod nodes, and then in refactor() I wrote code to drill down into them to get the array Array_ nodes. This went well until I tried returning a new replacement node, and then Rector complained, and I realised the obvious thing I’d skipped over: the refactor() method expects you to return a node to replace the found node. So my approach was completely wrong.

I rewrote getNodeTypes() to search for Array_ nodes: those represent the creation of an array value. This felt more dangerous: arrays are defined in lots of places in my code! And I haven’t been able to see a way to determine the parentage of a node: there do not appear to be pointers that go back up the PhpParser syntax tree (it would be handy, but would make the dump() output even worse to read!). Fortunately, the combination of array keys was unique in DrupalCodeBuilder, or at least I hoped it was fairly unique. So I wrote code to get a list of the array’s keys, and then compare it to what was expected:

        foreach ($node->items as $item) {
            $seen_array_keys[] = $item->key->value;
        }
        if (array_intersect(static::EXPECTED_MINIMUM_ARRAY_KEYS, $seen_array_keys) != static::EXPECTED_MINIMUM_ARRAY_KEYS) {
            return NULL;
        }

Returning NULL from refactor() means we aren’t interested in this node and don’t want to change it.

With the arrays that made it through the filter, I needed to make a new node that’s a class instantiation, to replace the array, passing the same values to the new statement as the array keys (mostly).

Rector’s list of commonly used PhpParser nodes was really useful here.

A new statement node is made thus:

use PhpParserNodeName;
use PhpParserNodeExprNew_;

        $class = new Name('DrupalCodeBuilderFileCodeFile');
        return new New_($class);

This doesn’t have any parameters yet, but running Rector on this with my sample set showed me it was working properly. Rector has a dry run option for development, which shows you what would change but doesn’t write anything to files, so you can run it over and over again. What’s confusing is that it also has a cache; until I worked this out I was repeatedly confused by some runs having no effect and no output. I have honestly no idea what the point is of caching something that’s designed to make changes, but there is an option to disable it. So the command to run is: $ vendor/bin/rector --dry-run --clear-cache. Over and over again.

Once that worked, I needed to convert array items to constructor parameters. Fortunately, the value from the array items work for parameters too:

use PhpParserNodeArg;

        foreach ($node->items as $array_item) {
                $construct_argument = new Arg(
                   $array_item->value,
                );

That gave me the values. But I wanted named parameters for my constructor, partly because they’re cool and mostly because the CodeFile class’s __construct() has optional parameters, and using names makes that simpler.

Inspecting the Arg class’s own constructor showed how to do this:

use PhpParserNodeArg;
use PhpParserNodeIdentifier;

                $construct_argument = new Arg(
                    value: $array_item->value,
                    name: new Identifier($key),
                );

Using named parameters here too to make the code clearer to read!

It’s also possible to copy over any inline comments that are above one node to a new node:

            // Preserve comments.
            $construct_argument->setAttribute('comments', $array_item->getComments());

The constructor parameters are passed as a parameter to the New_ class:

        return new New_($class, $new_call_args);

Once this was all working, I decided to do some more refactoring in the CodeFile class in DrupalCodeBuilder. The changes I was making with Rector made it more apparent that in a lot of cases, I was passing empty values. Also, the $body parameter wasn’t well-named, as it’s an array of pieces, so could do with a more descriptive name such as $body_pieces.

Changes like this are really easy to do (though by this point, I had made a git repository for my Rector rule, so I could make further enhancements without breaking what I’d got working already).

        foreach ($node->items as $array_item) {
            $key = $array_item->key->value;

            // Rename the 'body' key.
            if ($key == 'body') {
                $key = 'body_pieces';
            }

And that’s my Rector rule done.

Although it’s taken me far more time than changing each file by hand, it’s been far more interesting, and I’ve learned a lot about how Rector works, which will be useful to me in the future. I can definitely see how it’s a very useful tool even for refactoring a small codebase such as DrupalCodeBuilder, where a rule is only going to be used once. It might even prompt me to undertake some minor refactoring tasks I’ve been putting off because of how tedious they’ll be.

What I’ve not figured out is how to extract namespaces from full class names to an import statement, or how to put line breaks in the new statement. I’m hoping that a pass through with PHP_CodeSniffer and Drupal Coder’s rules will fix those. If not, there’s always good old regexes!

Tags: 
refactoring
Rector
PhpParser
drupal code builder
  • Add new comment

Setting up ActiveStorage + CloudflareR2 + Quill

Posted on May 4, 2024 by Michael G
In this post, I explain how you can set up Quill Editor on Ruby on Rails with Active Storage and Cloudflare R2! Let me know your thoughts!

January-March 2024 Status Report

Posted on May 4, 2024 by Michael G
The January to March Status Report is now available with 21 entries.

Abbie Richards on the wild world of conspiracy theories and battling misinformation on the internet

Posted on May 4, 2024 by Michael G

At Mozilla, we know we can’t create a better future alone, that is why each year we will be highlighting the work of 25 digital leaders using technology to amplify voices, effect change, and build new technologies globally through our Rise 25 Awards. These storytellers, innovators, activists, advocates, builders and artists are helping make the internet more diverse, […]

The post Abbie Richards on the wild world of conspiracy theories and battling misinformation on the internet appeared first on The Mozilla Blog.

Gary Benson: git submodule forgetting

Posted on May 4, 2024 by Michael G

Did you forget the -r when cloning a git repo with submodules? The command you’re looking for is git submodule update --init

FreeBSD is building a graphical installer

Posted on May 4, 2024 by Michael G
FreeBSD is working on a graphical installer. Finally. The first hurdle to overcome when testing a new Operating System is to get it installed. What is more, the first impression new users gather from an Operating System is its installation process. The state of the art for Operating System installers nowadays definitely involves a graphical process. This is the case for mainstream systems but also for other UNIX systems comparable to FreeBSD: RedHat Enterprise Linux, Ubuntu, Debian GNU/Linux, or even Devuan GNU+Linux Regardless of the technical level of the actual user, this is how the platform will be compared in the public eye. Instead, with knowledge of the current bsdinstall(8) and bsdconfig(8) utilities, I envisioned a BSD-licensed replacement for Xdialog(1). Just like when invoking bsdconfig with the -X switch for graphical mode, it could be dropped in instead of bsddialog(1) and allow graphical installation – while sharing the infrastructure of the current installer. To avoid confusion with the current implementation of Xdialog from the x11/xdialog port, I have named its replacement gbsddialog(1). It also has to be said that Xdialog is quite obsolete (latest release in 2006) and this shows visually too. ↫ Pierre Pronchery in the FreeBSD status report I can’t believe it’s taken FreeBSD this long to both consider and build a graphical installer. Currently being enveloped in the world of OpenBSD, there’s clearly so much the BSD world has to offer to desktop users such as myself, but at the same time, there’s a lot of low-hanging fruit that the various BSDs can address to make the experience just that little bit more pleasant. They obviously don’t have to – not every project is aiming at desktop use – but it just makes onboarding so much nicer. The next step – perhaps in 2037 – would be to offer a desktop-oriented installation image, with a default desktop environment and settings optimised for desktop use. Right now, a lot of fiddling and optimisation for this use case is left to the user, and for newcomers such as myself this means a lot of reading, making sense of contradictory advice and suggestions, wading through endless, often outdated, online guides, and so on. Now, I don’t particularly mind doing this, but I’m sure it’s chasing people away who could end up making meaningful contributions. Meanwhile, after trying out FreeBSD for a while a few weeks ago but it not being a good fit for me, I’m now exploring and using OpenBSD and it’s been a great experience. Although unlikely, I hope OpenBSD, too, can perhaps consider making some minor affordances to desktop users – because as I’ve learnt, OpenBSD feels right at home on a desktop, more so than I ever expected.

(Android) Blue Reflection Sun – 123 – Ayami Heroine Stories #3 w/dodgy translation

Posted on May 3, 2024 by Michael G
(Android) Blue Reflection Sun – 123 – Ayami Heroine Stories #3 w/dodgy translation

move file android mac os sonoma 2024

Posted on May 3, 2024 by Michael G
pindahkan data android ke mac os sonoma 2024
  • Previous
  • 1
  • …
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • …
  • 821
  • Next

Recent Posts

  • [TUT] LoRa & LoRaWAN – MikroTik wAP LR8 kit mit The Things Network verbinden [4K | DE]
  • Mercado aguarda Powell e olha Trump, dados e Haddad | MINUTO TOURO DE OURO – 11/02/25
  • Dan Levy Gets Candid About Learning How To Act Differently After Schitt’s Creek: ‘It’s Physically…
  • Building a Rock Shelter & Overnight Stay in Heavy Snow 🏕️⛰️
  • Les milliardaires Elon Musk et Xavier Niel s’insultent copieusement

Categories

  • Android
  • Linux
  • News
  • Open Source
©2025 Open World News | Powered by Superb Themes
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT