Feeds

Declassed Art: Declassed Plausible Deniability Toolkit

Planet Python - Fri, 2022-12-02 19:00
How to make your computer looking an innocent toy, used only to play tux racer and watch cats on youtube. Forensics would find the data with abnormally high entropy in unused sectors, a few suspicious tweaks in your system, but none of explicit evidences of encryption. This may help to avoid rubber-hose cryptanalysis, highly possible if you used LUKS, Tomb, Shufflecake, or simply encrypted your files.
Categories: FLOSS Project Planets

Evolving Web: Leveraging Composability with Drupal

Planet Drupal - Fri, 2022-12-02 15:39

In a previous article, we shared trends we’ve seen in the Acquia ecosystem and how they apply to our projects at Evolving Web. One of those trends is the growing importance of composable digital experience, central to how Drupal works. In this article, we will explore how composability, which started as a development concept, has now an expanding role in content management and content governance.

What is Composability?

Composability is at the very core of Drupal’s open source principles. Composable CMS is the idea that we should create robust building blocks that we can reuse across a single website, an ecosystem of websites, or every single Drupal project. 

Composable CMS isn’t a single thing. It could actually lead us to different architectural choices. For example: 

  • A wheel and spoke model, if we have a content hub that dispatches content to a set of satellite websites
  • Individual websites that don’t share content, but do share the same structure
  • A model where content is generated on many individual websites, and then shared in a completely distributed way, without a central hub
  • A multi-channel setup where content is shared from a CMS to completely separate channels like CRM, digital signage, a native app

Composability implies dividing content up into atoms so that it can more easily translate from one use case to another. For example, if we define an event as having a date field, we can add it to a calendar on our site, but also use schema.org metadata to indicate the event date on Google search results.

Why is Composability Useful?

Composability is a powerful concept because it gives us a content model that is predictable. From there, we can expect each content entity to have particular properties (a label or title, a language)

It helps us make good decisions about code and content reuse, challenging us to think about how configuring a single template, creating a piece of functionality, or authoring a piece of content, might be useful or reusable elsewhere.

With this type of granularity, content becomes searchable and findable when we apply the right markup and metadata that enables reusability.

It helps us create brand and messaging consistency as we should have fewer content elements to keep updated.

Composable Tactics in Drupal

By using a platform like Drupal, you’re already doing composability. You’re reusing the modules and base content structure of every other Drupal project, and benefiting from that. If you want to enable metatags for your content, you can turn on that feature and apply it to all your existing content.

If you’re using Layout Builder with custom block types, or the Paragraphs library to enable reuse of granular “Paragraph” elements, you’re already leveraging composable features for content reuse. You can learn more about how to use Paragraphs and Layout Builder via this article: How content editors use the drupal layout builder.

Features like Drupal’s core Media Library and the Entity Reference field provide content editors with the tools to reuse content within a single Drupal website or project..

You’re also taking advantage of composability when using Drupal’s Migrate API to leverage existing content and pull it into Drupal, or when using JSON:API or REST API to expose Drupal content to other platforms and channels.

Configuration management allows us to export the content model to code, making it potentially sharable to other websites in our ecosystem. The new recipes initiative seeks to make elements of Drupal configuration more portable, to encourage this type of reuse and create a more standardized method of component reuse in Drupal core.

Composability Beyond Drupal Core

Acquia’s Site studio complements Drupal and provides a mature product that teams can use to manage a library of reusable content, and also the templates (components) for storing granular content, and even the layouts and styling that applies to those components.

It provides a predefined/standardized approach to managing the layers of composability that we outlined above. The benefit of a solution like this is that it steers teams towards composability and gives them pre-built examples of how reuse plays out in a typical website.

It also has tools for sharing the library of content across websites in the same ecosystem, which saves architectural time in setting this up.

Site Studio is a great example of taking the potential of Drupal’s composability and laying it out in a way that’s ready for teams to take and run with. It also comes with opinions about how components and content should be managed, which might be too flexible or too restrictive for some teams. I highly recommend taking a deeper dive and checking out Acquia’s Site Studio demo.

Challenges 

Offering site owners and content editors the ability to re-use content and other building blocks comes with a few challenges. 

Challenge 1: Understanding Context

If content is used in many contexts, it’s hard to communicate to content editors what the results of their changes will be. Imagine a typical preview feature, allowing you to preview how content appears on a single page. If you are editing an image to be reused in five different ways, it’s hard to anticipate the impact of cropping it in a certain way. From this comes the question of how to create meaningful previews.

Solution: Help content editors understand the meaning and parameters of their choices:

  • Provide some instructions on image selection that takes into account how the image will be used. And 
  • Provide context about metadata if that metadata is visible when content is displayed on social media, but not when content is displayed on a simple page on the website.
Challenge 2: Accessibility

Multiple contexts also makes accessibility a challenge. Accessibility guidelines encourage teams to create meaningful content structures and flows. When editing a single content component that appears in different pages, think about how it will affect the flow and the hierarchy

Solution

  • Create a robust content model that enforces an accessible content structure. This means planning out which components can be used where so that they follow a logical hierarchy (e.g. a heading structure that doesn’t skip a level). 
  • Educate content editors so that each component is accessible regardless of context (e.g. writing link text that is self-explanatory regardless of context).
Challenge 3: Proliferation of Choices

The sheer quantity of content can also proliferate in the world of composable CMS. While the idea is to reuse components, it often also means sharing of components and adding more options to some websites that might have had a simpler content model in the past. The proliferation of content elements and templates means more choice for content editors, and can lead to more confusion about the use case. 

Solution

  • Provide clear examples of not just how to create content, but why to use one type of component vs. another. 
  • Give content editors the tools they need to find existing content, as well as some context around how it’s already being used.
Challenge 4: Approval Workflows

If content can be reused across different websites within an ecosystem, it likely changes the approval workflow whenever content needs updating. Let’s say you have authored a page, got it approved and published it. In a composable context, some components of your page might have to be approved separately, making it harder for you to update one aspect of the page that is being re-used in other places. 

Solution

  • Create a clear content governance plan that defines what belongs in a content library and how that content gets approved and updated. 
  • Invest time in constantly curating and maintaining the library of reusable content rather than taking a “set it and forget it” approach.
Drupal and the Composable Enterprise 

In our experience at Evolving Web, governance around modularity and composability is and will remain the biggest challenge. But despite all the challenges listed above, composability is an approach that gives institutions a competitive advantage as they can innovate and adapt to changing business needs rapidly. 

When we get to the point when site builders and content creators can have visibility as to what content components are out there and how they’re being used, as well as establishing best practices for making this type of content widely available, we’ll be able to fully take advantage of this approach.

Read more about Content Governance: Why Web Governance Is Essential to Your Digital Content Strategy

+ more awesome articles by Evolving Web
Categories: FLOSS Project Planets

Python for Beginners: Rename Index in a Pandas Series

Planet Python - Fri, 2022-12-02 09:00

We use pandas series objects for various data processing tasks in python. In this article, we will discuss how to rename the index in a pandas series.

Table of Contents
  1. Rename Index in a Pandas Series Using the index Attribute
  2. Rename the Index of a Series Using the rename_axis() Method
  3. Rename Index in a Series Inplace in Python
  4. Conclusion
Rename Index in a Pandas Series Using the index Attribute

When a series is created, the name of the index is empty. To rename the index of the series, you can use the name attribute of the series index object. You can assign the new index name to the name attribute of the index object to rename the series index as shown below.

import pandas as pd import numpy as np letters=["a","b","c","ab","abc","abcd","bc","d"] numbers=[3,23,11,14,16,2,45,65] series=pd.Series(letters,index=numbers) series.index.name="Numbers" print("The series is:") print(series)

Output:

The series is: Numbers 3 a 23 b 11 c 14 ab 16 abc 2 abcd 45 bc 65 d dtype: object

In the above example, We have first created a pandas series using the Series() constructor. Then, we assigned the string "Numbers" to the index.name attribute of the pandas series. Hence, the series index is renamed to "Numbers".

To rename the index of a series, you can also use the rename_axis() method. 

Rename the Index of a Series Using the rename_axis() Method

The rename_axis() method has the following syntax.

Series.rename_axis(mapper=_NoDefault.no_default, *, inplace=False, **kwargs)

Here, 

  • The mapper parameter takes the new name of the index as its input argument. 
  • By default, the rename_axis() method returns a new series object. To modify the original series on which the rename_axis() method is invoked, you can set the inplace parameter to True.

After execution, the rename_axis() method returns a new series with renamed index as shown below.

import pandas as pd import numpy as np letters=["a","b","c","ab","abc","abcd","bc","d"] numbers=[3,23,11,14,16,2,45,65] series=pd.Series(letters,index=numbers) series=series.rename_axis("Numbers") print("The series is:") print(series)

Output:

The series is: Numbers 3 a 23 b 11 c 14 ab 16 abc 2 abcd 45 bc 65 d dtype: object

In the above example, we first created a series. Then, we used the rename_axis() method to rename the index column of the series. Here, the rename_axis() method returns a new series instead of modifying the original series.

Suggested Reading: If you are into machine learning, you can read this MLFlow tutorial with code examples. You might also like this article on clustering mixed data types in Python.

Rename Index in a Series Inplace in Python

You can also modify the original series instead of creating a new series object after renaming the index. For this, you can set the inplace parameter to True in the rename_axis() method as shown below.

import pandas as pd import numpy as np letters=["a","b","c","ab","abc","abcd","bc","d"] numbers=[3,23,11,14,16,2,45,65] series=pd.Series(letters,index=numbers) series.rename_axis("Numbers",inplace=True) print("The series is:") print(series)

Output:

The series is: Numbers 3 a 23 b 11 c 14 ab 16 abc 2 abcd 45 bc 65 d dtype: object

In this example, we have set the inplace parameter to True in the rename_axis() parameter. Hence, the index of the original series has been renamed instead of creating a new series.

Conclusion

In this article, we have discussed how to rename the index in a pandas series using the index attribute and the renam_axis() method. To know more about the pandas module, you can read this article on how to sort a pandas dataframe. You might also like this article on how to drop columns from a pandas dataframe.

The post Rename Index in a Pandas Series appeared first on PythonForBeginners.com.

Categories: FLOSS Project Planets

Droptica: Layout Builder Customization. Creating Custom Layout in Drupal

Planet Drupal - Fri, 2022-12-02 08:14

Layout Builder allows quickly creating website layouts from pre-built components added to sections. By default, Drupal provides four types of sections: one, two, three, and four columns. These columns have a predefined behavior the editors have no control over. Drupal offers the ability to create our own types of sections, so we can tailor them to fit our project. This is the process we'll show you in our article.

How to create a custom section in Layout Builder?

The first and most important step is to define the goals and thus, the list of functionalities that the section should provide. Then it's worth breaking the functionalities into small tasks that can be done in a specific time. The aim of our section will be to provide the ability to add classes to the main section wrapper and to individual regions.

As our base we'll use the template available in the Drupal Layout Builder module, which is the one that's used in the sections available with the module installation. Our task list should include:

  • creating a custom module,
  • the definition of a section in the layouts.yml file,
  • the definition of a template for our sections and the plugin in which we'll embed the logic of adding our classes.
Creating a new module in Drupal

We have to create a standard *.info.yml file, as in every module. For a detailed description please refer to the documentation on Drupal.org.

# filename: custom_layout_builder.info.yml name: Custom Layout Builder sections description: Functionality which extends Layout Builder core_version_requirement: ^9 type: module package: custom dependencies: - drupal:layout_builder

We know what the purpose of the module is because we've defined the required functionality. Therefore, already at this stage, we're sure that the list of dependencies should include at least the Layout Builder module. After defining the info.yml file, it's worth clearing the cache and checking if the module appears on the list. To do this, let’s go to the modules view and search for the module by the title or machine name. We should see our module with a list of required dependencies.

 

As we can clearly see, even though we've provided a dependency to the Layout Builder module only, their list is a bit longer. This is because the Layout Builder module has its own dependency list and it’s inherited by our module.

 

At this stage, it's worth considering the mental health of other developers (or yours, if you come back to this code after a few months) and starting to build its documentation. It's worth beginning with the implementation of the hook hook_help().

 

It's also a good idea to create a README.md file and keep it updated.

Section registration using *.layouts.yml

In order to register a new section, the easiest way is to add the *.layouts.yml file (where * is the machine name of our module). The file should be added in the main folder of the module, where we added the *.info.yml file.

Let's start with defining one section:

# filename: ustom_layout_builder.layouts.yml layout_custom_one_column: # Section main key label: '[CUSTOM] One column' # Section title category: 'Custom layouts' path: layouts/custom_onecol_section # Relative path from the template template: layout--custom-onecol-section # Template name default_region: first icon_map: - [first] regions: # Regions table first: # Region machine name label: First # Region title

After the configuration, when adding sections, we should be able to see our newly defined section.

  Section template defining

In order to be able to add a section, we still need to add the template whose name and path we've specified. In our case, we need to create the layouts/custom_onecol_section folder inside of which the layout--custom-onecol-section.html.twig file must be placed.

By default, the template will have access to four variables: content, attributes, region_attributes, and settings. If we don't put any block in the section, the content variable will return false after being cast to a boolean value. We can take advantage of this behavior to avoid displaying empty HTML tags. Inside the content variable, we'll find the keys corresponding to each defined region, and inside these regions are the blocks we've added. In the content variable, we'll only find the first key, because that's the only one we've defined. The behavior of content.first when casting to a boolean value is analogous to the behavior of the content variable. We'll use this to not display empty tags.

# filename: layout--custom-onecol-section.html.twig {# /** * @file * Default implementation for a custom layout onecol section. * * Available variables: * - content: The content for this layout. * - attributes: HTML attributes for the layout . * - region_attributes: HTML attributes for the region . * - settings: An array of configured settings for the layout. * * @ingroup themeable */ #} {% if content %} {% if content.first %} {{ content.first }} {% endif %} {% endif %}

After adding the template, we should be able to easily add our section:

Defining the Layout plugin

From the end user's perspective, we haven't done anything so far, because the content editor will only see the new section title with the big [CUSTOM] prefix. This is because the section we've added works identically to the default one, provided with the Layout Builder module (with a small exception: our implementation doesn't add any classes). To change its behavior, we have to implement a new layout plugin.

Base class framework

The class should be in the src/Plugin/Layout folder. It'll be generic enough so that it can be used for any number of regions. The Drupal\Core\Layout\LayoutDefault class contains many base methods and implements the needed interfaces. As not to reinvent the wheel, we can expand it in our class.

# filename: CustomLayoutClassBase.php <?php namespace Drupal\custom_layout_builder\Plugin\Layout; use Drupal\Core\Layout\LayoutDefault; /** * Base class of our custom layouts with configurable HTML classes. * * @internal * Plugin classes are internal. */ class CustomLayoutClassBase extends LayoutDefault { } Adding configuration options to a base class

One of the requirements is the possibility to select a class for the tag wrapping the section's regions. To achieve this, we have to first override the defaultConfiguration method and add a new configuration option to it.

/** * {@inheritdoc} */ public function defaultConfiguration() { $configuration = parent::defaultConfiguration(); return $configuration + [ 'wrapper_classes' => '', ]; }

Then we should add the ability to specify a value for this configuration option. We can do this by overriding the buildConfigurationForm and submitConfigurationForm methods.

/** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['wrapper_classes'] = [ '#type' => 'textfield', '#title' => $this->t('Wrapper extra classes'), '#default_value' => $this->configuration['wrapper_classes'], '#description' => $this->t('Extra wrapper classes. Type as many as you want but remember to separate them by using a single space character.'), ]; return parent::buildConfigurationForm($form, $form_state); } /** * {@inheritdoc} */ public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { parent::submitConfigurationForm($form, $form_state); $this->configuration['wrapper_classes'] = $form_state->getValue('wrapper_classes'); }

If there's a need to add form validation, it can be done by overwriting the validateConfigurationForm method. We recommend implementing validation for this field, as classes should comply with the Drupal Community standard. The Html::getClass() method may come in handy in this case.

Using configuration to build sections

The render array is created in the build method, and that's what we're going to overwrite now. If you remember the contents of the template we've added, you probably already know that we add classes to the attributes object.

/** * {@inheritdoc} */ public function build(array $regions): array { $build = parent::build($regions); $wrapper_classes = explode(' ', (string) $this->configuration['wrapper_classes']); $build['#attributes']['class'] = [...$wrapper_classes]; return $build; } Using the base to create a Layout Plugin

Our class is ready, it's time to use it in a section. To do this, go back to the *.layouts.yml file to declare a new plugin. This is done by specifying the full namespace of the class under the class key.

# filename: custom_layout_builder.layouts.yml layout_custom_one_column: label: '[CUSTOM] One column' category: 'Custom layouts' path: layouts/custom_onecol_section template: layout--custom-onecol-section class: '\Drupal\custom_layout_builder\Plugin\Layout\CustomOneColLayout' default_region: first icon_map: - [first] regions: first: label: First

After introducing the above changes, you may notice that the section form has a new field and that the classes entered in that field are in the correct place in HTML.

Adding the option to select classes for regions We can already define a class list for the wrapper element in our section. It's time to think about how to create the logic responsible for adding classes to individual sections of our layout. We should take into consideration the extensibility of our base class. That's why we recommend basing the logic of determining and accessing regions on the basis of the getRegionNames() method of the LayoutDefinition class.

1. First, we add one field to our form for each region:

/** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['wrapper_classes'] = [ '#type' => 'textfield', '#title' => $this->t('Wrapper extra classes'), '#default_value' => $this->configuration['wrapper_classes'], '#description' => $this->t('Extra wrapper classes. Type as many as you want but remember to separate them by using a single space character.'), ]; foreach ($this->getPluginDefinition()->getRegionNames() as $region_name) { $form['region_classes'][$region_name] = [ '#type' => 'textfield', '#title' => $this->t('Extra classes for @region_name region', [ '@region_name' => $region_name, ]), '#default_value' => $this->configuration['region_classes'][$region_name], '#description' => $this->t('Extra classes for the @region_name region wrapper. Type as many as you want but remember to separate them by using a single space character.', [ '@region_name' => $region_name, ]), ]; } return parent::buildConfigurationForm($form, $form_state); }

2. We use a similar loop to write the value:

/** * {@inheritdoc} */ public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { parent::submitConfigurationForm($form, $form_state); $this->configuration['wrapper_classes'] = $form_state->getValue('wrapper_classes'); foreach ($this->getPluginDefinition()->getRegionNames() as $region_name) { $this->configuration['region_classes'][$region_name] = $form_state->getValue(['region_classes', $region_name], ''); } }

3. The last step will be overriding the build method and embedding our classes in the appropriate Attributes class object.

/** * {@inheritdoc} */ public function build(array $regions): array { $build = parent::build($regions); $wrapper_classes = explode(' ', (string) $this->configuration['wrapper_classes']); $build['#attributes']['class'] = [...$wrapper_classes]; foreach (array_keys($regions) as $region_name) { $region_classes = explode(' ', (string) $this->configuration['region_classes'][$region_name]); $build[$region_name]['#attributes']['class'] = [...$region_classes]; } return $build; }

After our latest changes, we should see a new Extra classes for first region field where we can provide a list of classes we want to use.

Keep in mind that the region will only appear if it's not empty. That's why we've added a test block containing the node's title. Let's see if classes are visible in HTML.

Creating different variants of sections The code was written in such a generic way that adding a section with a different number of regions requires only the definition of the region and template from us. Let's add then a new section containing two regions.

First, we add the definition:

# filename: custom_layout_builder.layouts.yml layout_custom_one_column: label: '[CUSTOM] One column' category: 'Custom layouts' path: layouts/custom_onecol_section template: layout--custom-onecol-section class: '\Drupal\custom_layout_builder\Plugin\Layout\CustomLayoutClassBase' default_region: first icon_map: - [first] regions: first: label: First layout_custom_two_columns: label: '[CUSTOM] Two columns' category: 'Custom layouts' path: layouts/custom_twocol_section template: layout--custom-twocol-section class: '\Drupal\custom_layout_builder\Plugin\Layout\CustomLayoutClassBase' default_region: first icon_map: - [first, second] regions: first: label: First second: label: Second

And then we prepare the template:

# filename: layout--custom-twocol-section.html.twig {# /** * @file * Default implementation for a custom layout onecol section. * * Available variables: * - content: The content for this layout. * - attributes: HTML attributes for the layout . * - region_attributes: HTML attributes for the region . * - settings: An array of configured settings for the layout. * * @ingroup themeable */ #} {% if content %} {% if content.first %} {{ content.first }} {% endif %} {% if content.second %} {{ content.second }} {% endif %} {% endif %}

 

The section should be available now.

 

The configuration form should automatically adjust to the number of regions.

After configuring the form and adding test data, we can see the result of our operation in HTML.

 

The module created in this tutorial is available on our GitHub account.

Layout Builder customization - summary

Layout Builder is a great tool whose API allows for full freedom. As always with Drupal, if you can dream it, you can build it. The example shown in this article is only a small part of what can be achieved. If you're interested in the wider use of the Layout Builder API, it's worth reading about the Bootstrap Layout Builder module.

Do you need custom settings in your system? Check out how we can help you as part of our services related to Drupal development.

Categories: FLOSS Project Planets

Web Review, Week 2022-48

Planet KDE - Fri, 2022-12-02 07:22

Let’s go for my web review for the week 2022-48.

osquery | Easily ask questions about your Linux, Windows, and macOS infrastructure

Tags: tech, monitoring

This looks like an interesting OS level monitoring solution.

https://osquery.io/


WebAssembly: Go vs Rust vs AssemblyScript :: Ecostack — a developer blog

Tags: tech, webassembly, performance

Little simple benchmark of WebAssembly performances for the most common languages found there. Careful to the payload size though.

https://ecostack.dev/posts/wasm-tinygo-vs-rust-vs-assemblyscript/


Using Rust at a startup: A cautionary tale | by Matt Welsh | Nov, 2022 | Medium

Tags: tech, programming, rust, architecture

Don’t believe claims about Rust (or any other options in fact) being a language for universal use. It has a few spaces where it shines and others where it’ll be a drag. Picking the right language and stack is a multi-factor decision process where the technical advantages of the language itself say less than half of the story.

https://mdwdotla.medium.com/using-rust-at-a-startup-a-cautionary-tale-42ab823d9454


I am disappointed by dynamic typing • Buttondown

Tags: tech, type-systems, metaprogramming

Interesting take about what could make dynamic typing truly shine if it got all the way to runtime manipulation in a consistent manner. We’re far from it though.

https://buttondown.email/hillelwayne/archive/i-am-disappointed-by-dynamic-typing/


Git Notes: git’s coolest, most unloved­ feature - Tyler Cipriani

Tags: tech, git

Obscure feature definitely but we’re happy it’s there… maybe one day it’ll indeed allow to have much more independence from the code forges.

https://tylercipriani.com/blog/2022/11/19/git-notes-gits-coolest-most-unloved-feature/


I/O is no longer the bottleneck

Tags: tech, performance

Definitely this, we have to stop pointing disk I/O so much for performance issues. This is just not really slow anymore. Obviously network is a different story.

https://benhoyt.com/writings/io-is-no-longer-the-bottleneck/


Falsehoods programmers believe about undefined behavior

Tags: tech, compiler, c, c++, rust

Undefined behavior do exist and well… they’re really undefined, don’t make any assumption about them.

https://predr.ag/blog/falsehoods-programmers-believe-about-undefined-behavior/


Cache invalidation really is one of the hardest problems in computer science – Surfing Complexity

Tags: tech, performance, multithreading

Nice summary on the false sharing problem with caches and how it can impact your performances in multithreaded contexts.

https://surfingcomplexity.blog/2022/11/25/cache-invalidation-really-is-one-of-the-hardest-things-in-computer-science/


Recognizing patterns in memory // TimDbg

Tags: tech, debugging, memory

Interesting set of memory patterns. Didn’t know all of them, some are definitely useful and I already use, I’ll try to look for the others next time I need to.

https://www.timdbg.com/posts/recognizing-patterns/


Massively increase your productivity on personal projects with comprehensive documentation and automated tests

Tags: tech, git, project-management, maintenance

Nice list of things to keep in mind when working on projects, even small personal ones. This greatly improve maintainability in the long run.

https://simonwillison.net/2022/Nov/26/productivity/


Why writing by hand is still the best way to retain information - Stack Overflow Blog

Tags: tech, low-tech, note-taking, book

There’s definitely a tension between something which you can organize and search easily (by typing) and something you can remember better (by hand writing). That’s why I can’t get rid of hand written notes completely, I practice a mix of both depending on the use.

https://stackoverflow.blog/2022/11/23/why-writing-by-hand-is-still-the-best-way-to-retain-information/


Bye for now!

Categories: FLOSS Project Planets

Real Python: The Real Python Podcast – Episode #135: Preparing Data to Measure True Machine Learning Model Performance

Planet Python - Fri, 2022-12-02 07:00

How do you prepare a dataset for machine learning (ML)? How do you go beyond cleaning the data and move toward measuring how the model performs? This week on the show, Jodie Burchell, developer advocate for data science at JetBrains, returns to talk about strategies for better ML model performance.

[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

Categories: FLOSS Project Planets

Lucas Cimon: Animated one-page-dungeon : Escape of the Torment

Planet Python - Fri, 2022-12-02 06:56

Last week, while translating John Harper's micro-TTRPG World of Dungeons: Turbo Breakers, I discovered the wonderful world of one page dungeons, starting with Michael Prescott splendid production at trilemma.com and also the yearly One Page Dungeon Context.

While crawling through the OPDC 2021 entries, I discovered a great map …


Permalink
Categories: FLOSS Project Planets

Andrea Grandi: Ignoring hosts with python vcr when writing tests with pytest and generating cassettes

Planet Python - Fri, 2022-12-02 05:30

How to ignore hosts with python vcr when writing tests with pytest and generating cassettes

Categories: FLOSS Project Planets

Junichi Uekawa: Already December.

Planet Debian - Fri, 2022-12-02 05:13
Already December. Things changed a lot. Six months ago I was at home most of the time. I hope I can keep on going out for a while.

Categories: FLOSS Project Planets

KDE's End of Year Fundraiser is Live

Planet KDE - Fri, 2022-12-02 04:29
You Make KDE Possible

KDE's End of Year Fundraiser is officially live! Your donations will help us reach our goals, support our community, fund our events, and show the world how everybody can benefit from KDE software.

Today we have the ambitious goal of raising 20,000€ for KDE. Your donation allows KDE to continue developing the spectacular Plasma desktop and all the apps you need for education, productivity, and creative work. Here are some of the things we have managed to do over the last year thanks to the generosity of donors:

Reaching the World

  • We have welcomed 2785+ people worldwide who have contributed code, art, translations and more.
  • We added/maintained support for 40+ languages for apps and frameworks.
  • We organized and attended 18 community events/sprints.

Building the Products

  • We hosted 1000+ projects and repositories.
  • We continued developing 260+ applications and addons.
  • We pushed out 11+ updates for KDE's Plasma desktop and related environments, such as Plasma Mobile and Plasma Big Screen and applications.
  • We supported 12 hardware platforms.
  • We continued to develop 83 frameworks.

The work of KDE is made possible thanks to the contributions from KDE Community members, donors and corporations that support us. Every individual counts, and every commitment, large or small, is a commitment to Free Software. Head to the KDE's End of Year fundraiser page and donate now.

Want to help more? Join KDE and contribute to building the future of KDE.

 

Categories: FLOSS Project Planets

Talk Python to Me: #392: Data Science from the Command Line

Planet Python - Fri, 2022-12-02 03:00
When you think data science, Jupyter notebooks and associated tools probably come to mind. But I want to broaden your toolset a bit and encourage you to look around at other tools that are literally at your fingertips. The terminal and shell command line tools. <br/> <br/> On this episode, you'll meed Jeroen Janssens. He wrote the book Data Science on The Command Line Book and there are a bunch of fun and useful small utilities that will make your life simpler that you can run immediately in the terminal. For example, you can query a CSV file with SQL right from the command line.<br/> <br/> <strong>Links from the show</strong><br/> <br/> <div><b>Jeroen's Website</b>: <a href="https://jeroenjanssens.com" target="_blank" rel="noopener">jeroenjanssens.com</a><br/> <b>Jeroen on LinkedIn</b>: <a href="https://www.linkedin.com/in/jeroenjanssens" target="_blank" rel="noopener">linkedin.com</a><br/> <b>Jeroen cohort-based course, Embrace the Command Line. Listeners can use coupon code TALKPYTHON20 for a 20% discount</b>: <a href="https://maven.com/data-science-workshops/embrace-the-command-line" target="_blank" rel="noopener">maven.com</a><br/> <br/> <b>Data Science on The Command Line Book</b>: <a href="https://datascienceatthecommandline.com/2e/index.html" target="_blank" rel="noopener">datascienceatthecommandline.com</a><br/> <b>McFly Shell History Tool</b>: <a href="https://github.com/cantino/mcfly" target="_blank" rel="noopener">github.com</a><br/> <b>Explain Shell</b>: <a href="https://explainshell.com" target="_blank" rel="noopener">explainshell.com</a><br/> <b>CSVKit</b>: <a href="https://csvkit.readthedocs.io/en/latest/index.html" target="_blank" rel="noopener">csvkit.readthedocs.io</a><br/> <b>sql2csv</b>: <a href="https://csvkit.readthedocs.io/en/latest/scripts/sql2csv.html" target="_blank" rel="noopener">csvkit.readthedocs.io</a><br/> <b>pipx</b>: <a href="https://github.com/pypa/pipx" target="_blank" rel="noopener">github.com</a><br/> <b>PyProject.toml to add entry points</b>: <a href="https://github.com/mikeckennedy/twitter-archive-parser/blob/installable/pyproject.toml" target="_blank" rel="noopener">github.com</a><br/> <b>rich-cli</b>: <a href="https://github.com/Textualize/rich-cli" target="_blank" rel="noopener">github.com</a><br/> <b>Typer</b>: <a href="https://typer.tiangolo.com/typer-cli/" target="_blank" rel="noopener">typer.tiangolo.com</a><br/> <b>FasD</b>: <a href="https://github.com/clvv/fasd" target="_blank" rel="noopener">github.com</a><br/> <b>Nerd Fonts</b>: <a href="https://www.nerdfonts.com/font-downloads" target="_blank" rel="noopener">nerdfonts.com</a><br/> <b>Xonsh</b>: <a href="https://xon.sh" target="_blank" rel="noopener">xon.sh</a><br/> <b>iTerm</b>: <a href="https://iterm2.com" target="_blank" rel="noopener">iterm2.com</a><br/> <b>Windows Terminal</b>: <a href="https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us" target="_blank" rel="noopener">microsoft.com</a><br/> <b>ohmyposh</b>: <a href="https://ohmyposh.dev" target="_blank" rel="noopener">ohmyposh.dev</a><br/> <b>ohmyz</b>: <a href="https://ohmyz.sh" target="_blank" rel="noopener">ohmyz.sh</a><br/> <b>Watch this episode on YouTube</b>: <a href="https://www.youtube.com/watch?v=wNJ3tTPkuzY" target="_blank" rel="noopener">youtube.com</a><br/> <b>Episode transcripts</b>: <a href="https://talkpython.fm/episodes/transcript/392/data-science-from-the-command-line" target="_blank" rel="noopener">talkpython.fm</a><br/> <br/> <b>--- Stay in touch with us ---</b><br/> <b>Subscribe to us on YouTube</b>: <a href="https://talkpython.fm/youtube" target="_blank" rel="noopener">youtube.com</a><br/> <b>Follow Talk Python on Mastodon</b>: <a href="https://fosstodon.org/web/@talkpython" target="_blank" rel="noopener"><i class="fa-brands fa-mastodon"></i>talkpython</a><br/> <b>Follow Michael on Mastodon</b>: <a href="https://fosstodon.org/web/@mkennedy" target="_blank" rel="noopener"><i class="fa-brands fa-mastodon"></i>mkennedy</a><br/></div><br/> <strong>Sponsors</strong><br/> <a href='https://talkpython.fm/sentry'>Sentry Error Monitoring, Code TALKPYTHON</a><br> <a href='https://talkpython.fm/foundershub'>Microsoft</a><br> <a href='https://talkpython.fm/assemblyai'>AssemblyAI</a><br> <a href='https://talkpython.fm/training'>Talk Python Training</a>
Categories: FLOSS Project Planets

John Ludhi/nbshare.io: Understand Tensors With Numpy

Planet Python - Fri, 2022-12-02 02:39
Understand Tensors With Numpy

In this notebook, I will explain tensors with Python Numpy. For numpy refresher please checkout following resource...
https://www.nbshare.io/notebook/692176011/Numpy-Basics/

In [1]: import numpy as np

Before we delve in to tensors. We need to understand first what is Scalars, Vectors, Arrays and Matrices.

Scalar - Scalar is just a number. Example number 55 is a scalar. Scalar has no dimensions.
Vector - Vector is one dimensional array or scalar with orientation (i.e. horizontal or vertical). Vector can be 1,2 or n dimensional.
Array - Array is a computer language term used in data structures. Array is a collection of similar data elements.
Matrix - Matrix is a mathematical term. It is a 2D array of numbers represented in rows and columns.

What is Vector

Example of 3 dimensional Vector is shown below.

In [2]: threeDVector = np.array([1,2,3]) In [3]: threeDVector Out[3]: array([1, 2, 3]) In [4]: threeDVector.shape Out[4]: (3,) What is Matrix

Matrix is 2 dimensional array.

In [5]: np.array([[1,2,3],[4,5,6]]) Out[5]: array([[1, 2, 3], [4, 5, 6]]) What is Tensor

Tensor is a mathematical object with more than two dimensions. The number of dimensions of an array defines the order of a Tensor. For example a scalar is 0 order tensor. Similarly vector is a 1 order tensor. A 2D matrix is 2nd order Tensor so on and so forth.

Below is an example of vector which is 1 order tensor.

In [6]: np.array([1,2,3]) Out[6]: array([1, 2, 3])

Let us define a two dimensional tensor.

In [7]: twodTensor = np.arange(36).reshape(6,6) In [8]: twodTensor Out[8]: array([[ 0, 1, 2, 3, 4, 5], [ 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23], [24, 25, 26, 27, 28, 29], [30, 31, 32, 33, 34, 35]])

Let us access the ist row of above tensor

In [9]: twodTensor[0] Out[9]: array([0, 1, 2, 3, 4, 5]) In [10]: twodTensor.shape Out[10]: (6, 6)

Three dimensional Tensor example is shown below...

In [11]: threedTensor = np.arange(36).reshape(4,3,3) In [12]: threedTensor Out[12]: array([[[ 0, 1, 2], [ 3, 4, 5], [ 6, 7, 8]], [[ 9, 10, 11], [12, 13, 14], [15, 16, 17]], [[18, 19, 20], [21, 22, 23], [24, 25, 26]], [[27, 28, 29], [30, 31, 32], [33, 34, 35]]])

Note the 3 enclosing brackets - array[[[]]] which indicates it is 3 dimensional tensor.

Add new dimension or axis to a tensor. In [13]: t3t = np.arange(36).reshape(4,3,3)

Let us make our 3 dimension tensor to a 4 dimension tensor.

In [14]: t4t = t3t[np.newaxis,:,:]

Note the 4 enclosing brackets in the below array.

In [15]: t4t Out[15]: array([[[[ 0, 1, 2], [ 3, 4, 5], [ 6, 7, 8]], [[ 9, 10, 11], [12, 13, 14], [15, 16, 17]], [[18, 19, 20], [21, 22, 23], [24, 25, 26]], [[27, 28, 29], [30, 31, 32], [33, 34, 35]]]])

Note our 4th dimension has only 1 element (the 3x3 array). Let us see that using tensor.shape

In [16]: t4t.shape Out[16]: (1, 4, 3, 3) In [17]: t4t[0] #4th dimension Out[17]: array([[[ 0, 1, 2], [ 3, 4, 5], [ 6, 7, 8]], [[ 9, 10, 11], [12, 13, 14], [15, 16, 17]], [[18, 19, 20], [21, 22, 23], [24, 25, 26]], [[27, 28, 29], [30, 31, 32], [33, 34, 35]]]) Arithmetic with Tensors

Tensors Arithemetic is mathematical operations on vector and matrix.

Example - Find the dot product of two 3 dimensional vectors, we can use np.dot

In [18]: array1 = np.array([4,4,3]) array2 = np.array([2,2,3]) In [19]: array1.shape Out[19]: (3,) In [20]: array2.shape Out[20]: (3,) In [21]: np.dot(array1,array2) Out[21]: 25

Dot product two matrix is shown below.

In [22]: array1 = np.array([[1,2,3],[4,4,3]]) array2 = np.array([[2,2,3],[1,2,3]]) In [23]: print(array1) print("\n") print(array2) [[1 2 3] [4 4 3]] [[2 2 3] [1 2 3]] In [24]: np.dot(array1,array2) #this will throw error because row of first matrix is not equal to column of second matrix - Refer matrix multiplication fundamentals --------------------------------------------------------------------------- ValueError Traceback (most recent call last) Input In [24], in <cell line: 1>() ----> 1 np.dot(array1,array2) File <__array_function__ internals>:180, in dot(*args, **kwargs) ValueError: shapes (2,3) and (2,3) not aligned: 3 (dim 1) != 2 (dim 0) In [25]: array1 = np.array([[1,2,3],[4,4,3],[1,1,1]]) array2 = np.array([[2,2,3],[1,2,3],[1,2,3]])

Dot product for above matrices will work because both the arrays are 3x3 matrices.

In [26]: np.dot(array1,array2) Out[26]: array([[ 7, 12, 18], [15, 22, 33], [ 4, 6, 9]])
Categories: FLOSS Project Planets

Help KDE hire more people!

Planet KDE - Thu, 2022-12-01 23:34

KDE’s 2022 year-end fundraiser is now live! Please go donate if you can.

It’s been several years since we did a fundraiser at the end of the year, and we’re going to be more on the ball about this going forward, given how much the KDE e.V. is expanding hiring. This year’s fundraiser sets the fairly modest goal of 20k €, which will help offset the cost of some of that hiring.

But of course… there’s no reason not to exceed the goal! The more money raised, the more contributors the KDE e.V. can hire directly, effecting the kind of professionalization needed to take KDE to the next level! We have big plans and we can’t do it without your help!

I know I’ve asked for a lot of donations recently, so if you’re feeling tapped out, this is a good time to go nudge your friends and family members who you’ve converted to KDE over the years! Help KDE challenge the big dogs and win!

Categories: FLOSS Project Planets

Paul Wise: FLOSS Activities November 2022

Planet Debian - Thu, 2022-12-01 21:13
Focus

This month I didn't have any particular focus. I just worked on issues in my info bubble.

Changes Issues Review Administration
  • Debian IRC: setup topic/entrymsg to redirect OFTC #debian-jp to the Debian Japan IRC server, cleaned up #debianppc ChanServ metadata
  • Debian wiki: unblock IP addresses, approve domains, approve accounts
Communication Sponsors

The libemail-outlook-message-perl, purple-discord, sptag, celery work was sponsored. All other work was done on a volunteer basis.

Categories: FLOSS Project Planets

Matt Layman: Learn Python By Example - Ghost Gobble Arcade Game

Planet Python - Thu, 2022-12-01 19:00
Learn Python By Example shows a simple Python exercise from Exercism. This problem illustrates booleans in Python.
Categories: FLOSS Project Planets

Oomph Insights: Oomph Earns Acquia Drupal Cloud Practice Certification

Planet Drupal - Thu, 2022-12-01 19:00
We are thrilled to share that Oomph has been recognized as an Acquia Certified Drupal Cloud Practice for completing Acquia’s rigorous evaluation program, which recognizes the highest standards of technical delivery on the platform. To earn Drupal Cloud Practice Certification, Acquia partners must meet a stringent set of technical criteria. These requirements include a core team of Acquia certified developers, significant hands-on experience delivering Acquia Drupal Cloud products to clients, and a meticulous company review with Acquia partner specialists.  “I am incredibly proud that our team…
Categories: FLOSS Project Planets

Reproducible Builds (diffoscope): diffoscope 228 released

Planet Debian - Thu, 2022-12-01 19:00

The diffoscope maintainers are pleased to announce the release of diffoscope version 228. This version includes the following changes:

[ FC Stegerman ] * As an optimisation, don't run apktool if no differences are detected before the signing block. (Closes: reproducible-builds/diffoscope!105) [ Chris Lamb ] * Support both the python3-progressbar and python3-progressbar2 Debian packages, two modules providing the "progressbar" Python module. (Closes: reproducible-builds/diffoscope#323) * Ensure we recommend apksigcopier. (Re: reproducible-builds/diffoscope!105) * Make the code clearer around generating the Debian substvars and tidy generation of os_list. * Update copyright years.

You find out more by visiting the project homepage.

Categories: FLOSS Project Planets

Pages