FLOSS Project Planets

DrupalCon News: Additional ways to participate in Drupal training

Planet Drupal - Tue, 2017-04-18 13:04

A week at DrupalCon is a fantastic way to level up your skills and bring new knowledge back to your work. We have had such high interest in these training courses, that many have sold out!  We know there are still people out there who want to learn these valuable skills, and we want to be sure you have that chance, even if it's not at DrupalCon. 

Categories: FLOSS Project Planets

Web Wash: How to Crop Images using Crop API, Image Widget Crop and Focal Point in Drupal 8

Planet Drupal - Tue, 2017-04-18 13:00
If you’ve done any Drupal site building, I’m sure you’ve experienced this issue. You create an image style with the “Scale and crop” effect and everything is going great until an editor uploads an image with a different aspect ratio. Now instead of images getting cropped correctly, they’re getting cut in half, or the top part is chopped off, and images are not displaying nicely. You could fix this problem by tweaking the image style to handle different aspect ratios, but it’ll never be the perfect solution. The best option is to crop image directly in Drupal, and this is what you’ll learn today. In this tutorial, you’ll learn how to avoid these situations by using Crop API. Now, Crop API doesn’t offer any interface on its own; it’s just an API. The two modules that provide an interface are Image Widget Crop and Focal Point. We’ll take a look at these modules in detail, in this tutorial.
Categories: FLOSS Project Planets

Mikkel Høgh: Why I care about the Drupal drama

Planet Drupal - Tue, 2017-04-18 12:23
Why I care about the Drupal drama

There’s been a lot said and written about the most recent drama in the Drupal community, quite a few people have asked me why I care. This is hard to answer without sounding flippant in 140 characters, so I’ve taken the time to write another blog post about the topic. This one a little less angry and more reasoned than the first.

mikl Tue, 2017-04-18 - 18:23 Tags Drupal Drupal Planet
Categories: FLOSS Project Planets

William Minchin: Pelican Trove Classifiers Added to PyPI

Planet Python - Tue, 2017-04-18 12:04

PyPI is the “package index” for Python and a wonderful tool for finding and sharing Python libraries.

On the index, there is a system of trove classifiers (see the full list here) that serve to allow package authors to tag their projects to help user find them. Some groups classifiers cover the Python version targeted, the “development status” (alpha, beta, stable, etc.), the license, the framework used, as so on.

Recently, trove classifiers for Pelican were added! This is great because it will allow for better discover-ability of Pelican themes and plugins. So I’ve re-released by collection of Pelican plugins and themes with the new classifiers, so the following releases:

PyPI also has the ability to show you everything tagged with Pelican.

Categories: FLOSS Project Planets

NumFOCUS: NumFOCUS is Now Hiring: Events Coordinator

Planet Python - Tue, 2017-04-18 11:56
NumFOCUS seeks applicants for the position of Events Coordinator. Join our small but mighty team and help support data science communities all over the world! This is a junior-level position with the opportunity to make a big impact. Why Work at NumFOCUS? We support the scientific software that makes reproducible science possible! Come work with […]
Categories: FLOSS Project Planets

qutebrowser development blog: Second qutebrowser crowdfunding launched!

Planet Python - Tue, 2017-04-18 11:53

Like last year, I'd love to spend my summer holidays working full-time on qutebrowser again!

This is why I started another crowdfunding - with the goal of finally implementing the new config system. See the Kickstarter campaign for details.

In a nutshell, that means:

  • There's a separate (optional) config file, which will never be touched by qutebrowser, and is much better suited for people who prefer editing their config by hand and/or managing it in a VCS like git.
  • Many new possibilities for the config, like setting the backend (QtWebKit/QtWebEngine), or other things which need to be available early (like disabling canvas reading).
  • The ability to set many settings for individual domains - such as enabling JavaScript individually (like NoScript), or setting user-stylesheets for some pages (like Stylish).
  • Much more powerful configuration (in Python).
  • Many other configuration bugs and quirks which will be fixed along the way.

Like last year, you can get qutebrowser stickers and t-shirts by contributing to the crowdfunding. Also, expect to see regular updates on this blog again!

Categories: FLOSS Project Planets

Xeno Media: Xeno Media’s Jim Birch presents on Bootstrap Paragraphs at Baltimore DrupalCon 2017

Planet Drupal - Tue, 2017-04-18 11:22

Attendees to Baltimore's DrupalCon 2017 should check out Xeno Media Strategist Jim Birch's presentation, Bootstrap Paragraphs, on April 26 at 10:45am.

In it, you will learn how to combine the power of the world's most popular front end framework, Bootstrap with Drupal Paragraphs, the powerful module that allows content creators to build layouts and structured pages.

Using the Bootstrap Paragraphs Drupal 8 module, you'll be able to create Bootstrap features like Accordions, Carousels, Modals, Tabs, and Multi-column layouts.  We'll also demonstrate how to harness the power of Drupal referencing Text, Images, Contact Forms, Blocks, and even Views!  We will also review how the module adds different widths and backgrounds which can be modified in the Drupal theme layer.

This presentation will review:
  • Why use the Bootstrap framework?
  • Why use the Paragraphs module?
  • What goes into the different types of bundles?
  • How we add width and background options
  • How to override, and build on top of the defaults
Learning Objectives & Outcomes:

Attendees will come away learning how to build a site using the Bootstrap Paragraphs module, how to customize it in their own themes, and how to use the module as a baseline to develop their own Paragraphs bundle types.

Categories: FLOSS Project Planets

Norbert Preining: Gaming: Firewatch

Planet Debian - Tue, 2017-04-18 11:04

A nice little game, Firewatch, puts you into a fire watch tower in Wyoming, with only a walkie-talkie connecting him to his supervisor Delilah. A so called “first person mystery adventure” with very nice graphics and great atmosphere.

Starting with your trip to the watch tower, the game sends the player into a series of “missions”, during which more and more clues about a mystery disappearance are revealed. The game development is rather straight forward, one has hardly any choices, and it is practically impossible to miss something or fail in some way.

The big plus of the game is the great atmosphere, the funny dialogues with Delilah, the story that pulls you into the game, and the development of the character(s). The tower, the cave, all the places one visits are delicately designed with lots of personality, making this a very human like game.

What is weak is the finish. During the game I was always thinking about whether I should tell Delilah everything, or keep some things secret. But in the end nothing matters, all ends with a simple escape in the helicopter and without any tying up the loose ends. Somehow a pity for such a beautiful game to leave the player somehow unsatisfied at the end.

But although the finish wasn’t that good, I still enjoyed it more than I expected. Due to the simple flow it wont keep you busy for many hours, but as a short break a few evenings (for me), it was a nice break from all the riddle games I love so much.

Categories: FLOSS Project Planets

EuroPython: EuroPython 2017: Call for Proposals Extended

Planet Python - Tue, 2017-04-18 10:56

The Call for Proposals ended last Sunday.  We do have received many great proposals for talks and trainings. Thanks to all the submitters - great work!

Though many seem to have missed the deadline due to the bank holidays and general Easter holiday season.

So the program work group has decided to extend the call for a few more days until Sunday, 23rd of April.

Some pointers, you may submit anything you see fit, but we would love to see more proposals for:

- Makers
- Artificial Intelligence & Deep Learning
- Internet of Things / Industrie 4.0 / Industrial Internet
- Robotics
- Security
- Python in Education

We also could use some more posters. If you don’t know what posters are - they are a great way of discussing (and challenging) your project with others in person, more: here

Please submit your proposals via the CfP form.


EuroPython 2017 Team

Categories: FLOSS Project Planets

Enthought: Handling Missing Values in Pandas DataFrames: the Hard Way, and the Easy Way

Planet Python - Tue, 2017-04-18 10:21

This is the second blog in a series. See the first blog here: Loading Data Into a Pandas DataFrame: The Hard Way, and The Easy Way

No dataset is perfect and most datasets that we have to deal with on a day-to-day basis have values missing, often represented by “NA” or “NaN”. One of the reasons why the Pandas library is as popular as it is in the data science community is because of its capabilities in handling data that contains NaN values.

But spending time looking up the relevant Pandas commands might be cumbersome when you are exploring raw data or prototyping your data analysis pipeline. This is one of the places where the Canopy Data Import Tool helps make data munging faster and easier, by simplifying the task of identifying missing values in your raw data and removing/replacing them.

Why are missing values a problem you ask? We can answer that question in the context of machine learning. scikit-learn and TensorFlow are popular and widely used libraries for machine learning in Python. Both of them caution the user about missing values in their datasets. Various machine learning algorithms expect all the input values to be numerical and to hold meaning. Both of the libraries suggest removing rows and/or columns that contain missing values.

If removing the missing values is not an option, given the size of your dataset, then they suggest replacing the missing values. The scikit-learn library provides an Imputer class, which can be used to replace missing values. See the sci-kit learn documentation for an example of how the Imputer class is used. Similarly, the decode_csv function in the TensorFlow library can be passed a record_defaults argument, which will replace missing values in the dataset. See the TensorFlow documentation for specifics.

The Data Import Tool provides capabilities to handle missing values in your dataset because we strongly believe that discovering and handling missing values in your dataset is a part of the data import and cleaning phase and not the analysis phase of the data science process.

Digging into the specifics, here we’ll compare how you can go about handling missing values with three typical scenarios, first using the Pandas library, then contrasting with the Data Import Tool:

  1. Identifying missing values in data
  2. Replacing missing values in data, and
  3. Removing missing values from data.

Note : Pandas’ internal representation of your data is called a DataFrame. A DataFrame is simply a tabular data structure, similar to a spreadsheet or a SQL table.

Identifying Missing Values – The Hard Way: Using Pandas

If you are interested in identifying missing values in a row/column of a DataFrame, you need to understand the isnull, any, all methods on a DataFrame.

Taking a detour, we have so far described missing values as being represented by NA or NaN. Instead, what if missing values in a column are values that aren’t of the same type as the rest of the cells in the column, say for example a string in a column containing integers? Doing so in Pandas is not trivial.

Identifying Missing Values – The Easy Way: Using the Data Import Tool

Highlighting null values using the Data Import Tool

Instead of giving you the column names and index values of the cells containing missing values, the Data Import Tool shows them to you. Simply checking the `Highlight Missing Values` checkbox in the bottom-left corner of the Data Import Tool will paint the DataFrame to show you the cells that contain missing values. Further, the Data Import Tool understands that your data file might have errors, like having a string value in a column otherwise containing integers. The Data Import Tool highlights the cell and displays the underlying content too.

The Data Import Tool can highlight missing value cells, helping you easily identify columns or rows containing NaN values

Replacing Missing Values – The Hard Way: Using Pandas

While Pandas does a great job at handling column operations even if the columns contain NaN values, our data analysis workflow might need us to replace the missing values in our data.

After spending a little time browsing through the Pandas documentation, you will come across the `fillna` method on a DataFrame, which can be used to replace a missing values. The arguments you pass to the fillna method will determine what value the missing values in your DataFrame are replaced with and how the underlying column dtypes change after replacing the missing values.

DataFrame.fillna(value=None, method=None, axis=None, inplace=False, limit=None, downcast=None, **kwargs)

Replacing Missing Values – The Easy Way: Using the Data Import Tool

With the Data Import Tool, you can replace missing values by right-clicking on the column containing missing values selecting the appropriate Fill Missing Values item. Opting to replace missing values in the column with a specific column will open an additional dialog, prompting you to enter the value.

Replace missing values in your DataFrame using the Canopy Data Import Tool

Removing Missing Values – The Hard Way: Using Pandas

While removing columns or rows containing missing values might be a little extreme, it might be necessary. Pandas suggests that you use the dropna method on the DataFrame to drop columns or rows that contain missing values. The arguments you pass to the dropna method will determine what rows/columns are removed from the DataFrame.

DataFrame.dropna(axis=0, how='any', thresh=None, subset=None, inplace=False)

Removing Missing Values – The Easy Way: Using the Data Import Tool

With the Data Import Tool on the other hand, you can remove rows/columns containing missing values by selecting the “Delete Empty Columns” or “Delete Empty Rows” item from the “Transform” menu. An additional dialog will pop up asking you how lenient you want to be in removing rows/columns containing missing values – if you choose ‘any’, the Data Import Tool will remove rows/columns that contain any missing values; if you choose ‘all’, the Data Import Tool will only remove those rows/columns which contain only missing values.

Delete empty cells in rows/columns using the Canopy Data Import Tool

Choose to delete columns containing any null value or columns full of null values using the Canopy Data Import Tool

Finally, we have data that contains no missing values. So far, we’ve used the DIT to easily discover the missing values in our dataset and to remove/replace the missing values. Finally, by clicking on ‘Use DataFrame’, you can import the dataset as a pandas DataFrame into the IPython workspace of the Canopy Editor. If you’re a data scientist, your data is now void of missing values and can be converted to arrays or variables and passed on to scikit-learn, TensorFlow or any other Machine Learning library of your choice.

Ready to try the Canopy Data Import Tool?

Download Canopy (free) and click on the icon to start a free trial of the Data Import Tool today

This is the second blog in a series. See the first blog here: Loading Data Into a Pandas DataFrame: The Hard Way, and The Easy Way

Additional resources:

Watch a 2-minute demo video to see how the Canopy Data Import Tool works:

See the Webinar “Fast Forward Through Data Analysis Dirty Work” for examples of how the Canopy Data Import Tool accelerates data munging:

The post Handling Missing Values in Pandas DataFrames: the Hard Way, and the Easy Way appeared first on Enthought Blog.

Categories: FLOSS Project Planets

Colm O hEigeartaigh: Apache CXF 3.1.11 released

Planet Apache - Tue, 2017-04-18 08:11
Apache CXF 3.1.11 (and 3.0.13) has been released. This release fixes a large number of bugs (there are over a 100 issues fixed in the CXF JIRA for this release). From a security POV, here are some of the more notable bug fixes and changes:
  • CXF-7315 - Abstract the STS client token caching behaviour to allow the user to plug in a custom implementation
  • CXF-7296 - Add support to enable revocation for TLS via configuration (see here). 
  • CXF-7314 - Custom BinarySecurityTokens are not used to set up the security context
  • CXF-4692 - Allow customization of Request Security Token Response
  • CXF-7252 - TLSParameterJaxBUtils.getTrustManagers getting password from wrong system property
In addition, two new security advisories have been issued for bugs fixed in this release:
  • CVE-2017-5653 - Apache CXF JAX-RS XML Security streaming clients do not validate that the service response was signed or encrypted.
  • CVE-2017-5656 - Apache CXF's STSClient uses a flawed way of caching tokens that are associated with delegation tokens.
Please update to the latest releases if you are affected by either of these issues.
Categories: FLOSS Project Planets

Updates on the KActionRunner thinkering.

Planet KDE - Tue, 2017-04-18 06:51

First I would like to answer a few questions that I had on my latest entry:

1 – KActionRunner is *not* a unified-menu, and it does not tries to be. It shouldn’t be used to display the menu of the application in a unified way.

2 – Somebody told me that this looked like the Eclipse “Quick Access” feature, and that’s exactly what this is.

Changes in the code currently on my machine, *not merged yet*:

  • Enabled in every K-App that uses KXmlGui
  • ctrl + alt + space triggers the Action Runner
  • Search for the action you wanna trigger
  • Trigger it.

Obligatory Screenshoot running on KDevelop:

I certainly need to iron out a few things before trying to merge this, so I’m not doing a review again this soon (my older review was shut down pretty fast

  • Prettier delegate displaying more information about the Action
  • Display the list of actions when you type (currently it completes inline)
  • don’t crash on exit

I’m using it on all my KDE applications locally and this is starting to behave the way I want.


Categories: FLOSS Project Planets

Python Piedmont Triad User Group: PYPTUG Monthly Meeting "Meet Eliza" April 25th 2017

Planet Python - Tue, 2017-04-18 06:39

Come join PYPTUG at out next monthly meeting (April 25th 2017) to learn more about the Python programming language, modules and tools. Python is the perfect language to learn if you've never programmed before, and at the other end, it is also the perfect tool that no expert would do without. Monthly meetings are in addition to our project nights.

WhatMeeting will start at 6:00pm.
We will open on an Intro to PYPTUG and on how to get started with Python, PYPTUG activities and members projects, then on to News from the community.

Main Talk: "Meet Eliza"

by Francois Dion, Data Scientist, Inmar Inc.


When I was a child, I spoke with Eliza at a science museum, and everything changed from that moment on. Who was Eliza? Perhaps you haven't heard of Eliza. You will be able to meet Dr. Eliza and exchange some thoughts with her.

After meeting Eliza, we will discuss Artificial Intelligence. Ever wondered what it means? Can you trust AI? If AI can make works of art? Poems? What about legal ramifications? Should I confide in Siri or Cortana? What does an artificial neuron look like? Do androids dream of electric sheep? If you've asked yourself one of these questions, then you'll be glad to attend this presentation and discussion. 
And since this is a discussion, you'll be able to ask questions, to participate, to voice your opinion.
Lightning talks! 
We will have some time for extemporaneous "lightning talks" of 5-10 minute duration. If you'd like to do one, some suggestions of talks were provided here, if you are looking for inspiration. Or talk about a project you are working on.Some are already lined up.
WhenTuesday, April 25th 2017
Meeting starts at 6:00PM

WhereWake Forest University, close to Polo Rd and University Parkway:
Manchester Hall
room: Manchester 241 Wake Forest University, Winston-Salem, NC 27109
 Map this
See also this campus map (PDF) and also the Parking Map (PDF) (Manchester hall is #20A on the parking map)
And speaking of parking:  Parking after 5pm is on a first-come, first-serve basis.  The official parking policy is:"Visitors can park in any general parking lot on campus. Visitors should avoid reserved spaces, faculty/staff lots, fire lanes or other restricted area on campus. Frequent visitors should contact Parking and Transportation to register for a parking permit."Mailing List
Don't forget to sign up to our user group mailing list:
It is the only step required to become a PYPTUG member.
RSVP on meetup:https://www.meetup.com/PYthon-Piedmont-Triad-User-Group-PYPTUG/events/238774609/

Categories: FLOSS Project Planets

Colorfield: Update a project installed via composer_manager or drush to a CI based Composer template under Drupal VM

Planet Drupal - Tue, 2017-04-18 06:24
Update a project installed via composer_manager or drush to a CI based Composer template under Drupal VM christophe Tue, 18/04/2017 - 12:24

If you have to go for a Drupal core update from a previous install based on composer_manager or drush (both deprecated), consider installing something robust, Composer friendly, that also enables CI tools like Phing, Behat, PHPUnit, ...

If you don't have already Drupal VM installed, head to the documentation.

Categories: FLOSS Project Planets

Multithreaded Programming with Future & Promise

Planet KDE - Tue, 2017-04-18 04:19

This is a guest post by 2016 Qt Champion Ben Lau.

Ben has a long history with Qt, and many interesting projects on GitHub.

Here’s an idea from him on making multithreading simpler in some cases.

The Basics

Multithreading programming may not be difficult at the first glance. You have to pay attention to your shared data to avoid race conditions/deadlocks. So you learn mutex and semaphore and do it carefully. The result works perfectly on your machine.

But one day, your program hangs. You spend an hour to trace out the problem and find out the order of code execution is not same as your expectation. So you add a few mode condition checking and fix the problem.

After a few week of development, the program is getting more complicated. And it begins to crash randomly. This time even after a day you still can’t figure out what is wrong and admit that it is totally out of control.

Does that sound like a familiar story? It is not rare to find complaints about random crashes/hangs due to misuse of a thread. Is it really difficult to write multithreaded programs?

The answer is yes and no. It depends on your software requirement and architecture.

In this article, it is going to introduce a lock-free multithreaded programming method by using QtConcurrent and AsyncFuture. These make multithreaded programming easier.

Let’s take an example. The code below shows an asynchronous ImageReader class. The readImageWorker function will be executed on another thread that won’t block the UI. QFuture represents the result of computation and reports the status change.

class ImageReader : public QObject { public:     QFuture<QImage> read(const QString& fileName); }; QFuture<QImage> ImageReader::read(const QString &fileName) {     auto readImageWorker = [](const QString &fileName) {         QImage image;         image.load(fileName);         return image;     };     return QtConcurrent::run(readImageWorker, fileName); }

Example of use

ImageReader reader; QFuture future = reader.read(INPUT); QFutureWatcher *watcher = new QFutureWatcher(); connect(watcher, &QFutureWatcher::finished, [=]() { setImage(future.result()); }); watcher->setFuture(future);

Multithreaded programming with QtConcurrent is pretty easy. It just takes an input, then produce an output later. QtConcurrent handles all of the low-level threading primitives.

But it is limited to the condition that the concurrent function does not access shared data with other threads. If that happens, it may still need a lock in order to maintain a critical session. That will fall back to the old traditional way.

Make it support Image caching

The above example is quite an ideal case. And of course, a real world problem is usually not that simple. Let’s change the requirement – Make it support image caching.

QFuture ImageReader::read(const QString &fileName) { auto readImageWorker = [](const QString &fileName) { QImage image; image.load(fileName); return image; }; QFuture future = QtConcurrent::run(readImageWorker, fileName); QFutureWatcher *watcher = new QFutureWatcher(this); auto updateCache = [=]() { m_cache[fileName] = future.result(); watcher->deleteLater(); }; connect(watcher, &QFutureWatcher::finished, updateCache); watcher->setFuture(future); return future; }

The class declaration:

class ImageReader : public QObject { public: bool isCached(const QString& fileName) const; QImage readCache(const QString& fileName) const; QFuture read(const QString& fileName); private: QMap<QString,QImage> m_cache; }; bool ImageReader::isCached(const QString &fileName) const { return m_cache.contains(fileName); } QImage ImageReader::readCache(const QString &fileName) const { return m_cache[fileName]; }

Before getting an image, you have to query is the cache available:

if (reader.isCached(INPUT)) { setImage(reader.readCache(INPUT)); return; } QFuture future = reader.read(INPUT);

This solution works, but the API is not ideal. Because it would violate the “Tell, don’t ask” principle. The best way is to combine readCache() and read() into a single function that always returns a QFuture object. But there is a problem, QFuture/QtConcurrent can only obtain a result from a thread. It is quite odd to start a thread but the data is already available. To get rid of this problem, we need a 3rd party library.


AsyncFuture is a C++ library that could converts a signal into a QFuture type and uses it like a Promise object in Javascript. It provides a unified interface for asynchronous and concurrent tasks. The library only contains a single header file, so that it is very easy to bundle in your source tree. Or you may install it by qpm.

Project Site:

Let’s rewrite the above function with AsyncFuture:

QFuture ImageReader::read(const QString &fileName) { if (m_cache.contains(fileName)) { // Cache hit. Return an already finished QFuture object with the image auto defer = AsyncFuture::deferred(); defer.complete(m_cache[fileName]); return defer.future(); } if (m_futures.contains(fileName)) { // It is loading. Return the running QFuture return m_futures[fileName]; } auto readImageWorker = [](const QString &fileName) { QImage image; image.load(fileName); return image; }; auto updateCache = [=](QImage result) { m_cache[fileName] = result; m_futures.remove(fileName); return result; }; QFuture future = AsyncFuture::observe(QtConcurrent::run(readImageWorker, fileName)).context(this, updateCache).future(); m_futures[fileName] = future; return future; }

This time it is almost perfect. The deferred object provides an interface to complete/cancel a QFuture manually. That could replace readCache() by returning an already finished future object.

Moreover, it has added a new feature to avoid duplicated image reading. In case you have made requests to load the same image twice before it is cached, the original design would start two threads which are totally wasting CPU power. This version solves it by keeping all the running future in a future pool and return that future for duplicated read.

Make the example more complicated

Currently the example is very simple. Let’s try to make it more complicated.


  1. Add a readScaled(fileName, size) function that returns an image which is scaled to specific size
  2. Code reuse is a must
  3. The scaling must be done in another thread to emulate a high CPU usage function
  4. Load cached image if available
  5. But scaled image do not need to keep in cache

The most optimistic solution is to make use of the result of read() directly. That mean you have to create a thread that depends on the result of another thread. That is a bit hard to get it works with only QtConcurrent and probably it needs to use a lock. But it can be easy to be done with AsyncFuture’s future chaining feature.

QFuture ImageReader::readScaled(const QString &fileName, const QSize &size) { auto scaleImageWorker = [=](QImage input) { return input.scaled(size); }; auto callback = [=](QImage result) { return QtConcurrent::run(scaleImageWorker, result); }; QFuture input = read(fileName); QFuture output = AsyncFuture::observe(input).context(this, callback).future(); return output; }

First of all, it calls read() function to obtain an image from QFuture. It doesn’t care about the caching mechanism as it is already handled by the read() function.

Then it creates a new future object to represent the whole work flow of the chain:

QFuture output = AsyncFuture::observe(input).context(this, callback).future(); ^^^^^^^^^

A chain begins with a observe() function, then followed by an observer function to bind the callback to the observed future, and that will create a new future object to represent the result of the callback.

auto callback = [=](QImage result) { return QtConcurrent::run(scaleImageWorker, result); };

You may wonder if it is alright to run another worker function within the callback function. In fact, this is a feature of AsyncFuture. It provides a chainable API that works like a Promise object in JavaScript. If the callback returns a QFuture object, it will be added to the chain. Then the final output future will depend on the returned future. Therefore, the output future is in fact represents the result of read() , callback() and scaleImageWorker(). The flow could be visualised by this diagram:

Diagram: The workflow of readScaled() – it shows how it uses a single QFuture to represent the result of a multiple steps task.


Using QtConcurrent without sharing data between threads could make multithreaed programming easier because it doesn’t need to manage an access lock. But real world problems are usually more complicated. A task may not be able to complete without interaction from other threads. In this case, it may still need an access lock to protect critical session. But once you have used it, it will fall back to the old traditional way, and probably it may get the same problem mentioned at the beginning.

In this article an alternative solution is presented: Use Concurrent API together with asynchronous callback then chain them into a sequence by a promise like API. It works by breaking down a task into multiple steps. Whanever a concurrent function seeks for extra information from another thread, it should just terminate itself and pass the control back to the main thread. So that it doesn’t need an access lock that may raise issues like deadlocks and race conditions.

The whole workflow could be represented by a QFuture object, a unified interface for all kind of asynchronous workflow.

However, this doesn’t mean we get rid of locks completely. They are still necessary for some scenarios. So choose your solution case by case.

The post Multithreaded Programming with Future & Promise appeared first on Qt Blog.

Categories: FLOSS Project Planets

Uncovering 32 Qt best practices at compile time with clazy

Planet KDE - Tue, 2017-04-18 04:00

In a previous blog post we introduced clazy, a clang plugin which makes the compiler understand Qt semantics, allowing you to get compile-time warnings about Qt best practices ranging from unneeded memory allocations to misuse of API, including fix-its for automatic refactoring.

Today we’ll do a round-up and present the checks related to connect statements, Qt containers (including QString) and misc Qt facilities.

Connects 1. old-style-connect

Finds connect() statements still using the old SIGNAL()/SLOT() syntax. The Qt …

The post Uncovering 32 Qt best practices at compile time with clazy appeared first on KDAB.

Categories: FLOSS Project Planets

Dataquest: NumPy Cheat Sheet - Python for Data Science

Planet Python - Tue, 2017-04-18 04:00

NumPy is the library that gives Python its ability to work with data at speed. Originally, launched in 1995 as ‘Numeric,’ NumPy is the foundation on which man importany Python data science libraries are built, including Pandas, SciPy and scikit-learn.

The printable version of this cheat sheet

It’s common when first learning NumPy to have trouble remembering all the functions and methods that you need, and while at Dataquest we advocate getting used to consulting the NumPy documentation, sometimes it’s nice to have a handy reference, so we’ve put together this cheat sheet to help you out!

If you’re interested in learning pandas, you can consult our NumPy tutorial blog post, or you can signup for free and start learning NumPy through our interactive python data science course.

Key and Imports

In this cheat sheet, we use the following shorthand:

arr A NumPy Array object

You’ll also need to import numpy to get started:

import numpy as np ...
Categories: FLOSS Project Planets

Ortwin Glück: [Code] Gentoo updates perl from 5.22 to 5.24

Planet Apache - Tue, 2017-04-18 03:43
On desktop systems emerge usually complains that there are packages requiring 5.22 and refuses to update: !!! Multiple package instances within a single package slot have been pulled !!! into the dependency graph, resulting in a slot conflict: dev-lang/perl:0 (dev-lang/perl-5.24.1-r1:0/5.24::gentoo, ebuild scheduled for merge) pulled in by =dev-lang/perl-5.24* required by (virtual/perl-MIME-Base64-3.150.0-r2:0/0::gentoo, installed) ^ ^^^^^ (and 8 more with the same problem) (dev-lang/perl-5.22.3_rc4:0/5.22::gentoo, installed) pulled in by dev-lang/perl:0/5.22=[-build(-)] required by (dev-perl/Digest-HMAC-1.30.0-r1:0/0::gentoo, installed) ^^^^^^^^ (and 13 more with the same problem) To resolve that:

Forcibly update perl (-O), then clean up:
# emerge -1uavO perl # perl-cleaner --all (repeat perl-cleaner if emerge fails) There may still be perl virtuals that need reinstalling: # emerge -1av $(qlist -IC 'virtual/perl-*') This should leave you with a consistent perl build and emerge should no longer suggest a downgrade.
Categories: FLOSS Project Planets

Valuebound: How to Sync Blocks Between different environments in a Drupal 8 website

Planet Drupal - Tue, 2017-04-18 03:32

A custom block is made of two entities, one for the placement and one for the actual content. Only the actual placement can be exported with cim. The content can not. Therefore this will result in "Block description Broken/Missing" error on site where the config is imported. And since there is no option to disable custom blocks from being exported through Configuration management, this will break the functionality.

Steps to reproduce

On Site A:

Create custom block

Assign this custom block to any region

Export configuration of the site

On Site B:

Import configuration from site A…

Categories: FLOSS Project Planets
Syndicate content