Elena 'valhalla' Grandi: New pajama

Planet Debian - Mon, 2017-03-27 03:38
New pajama

I may have been sewing myself a new pajama.


It was plagued with issues; one of the sleeve is wrong side out and I only realized it when everything was almost done (luckily the pattern is symmetric and it is barely noticeable) and the swirl moved while I was sewing it on (and the sewing machine got stuck multiple times: next time I'm using interfacing, full stop.), and it's a bit deformed, but it's done.

For the swirl, I used Inkscape to Simplify (Ctrl-L) the original Debian Swirl a few times, removed the isolated bits, adjusted some spline nodes by hand and printed on paper. I've then cut, used water soluble glue to attach it to the wrong side of a scrap of red fabric, cut the fabric, removed the paper and then pinned and sewed the fabric on the pajama top.
As mentioned above, the next time I'm doing something like this, some interfacing will be involved somewhere, to keep me sane and the sewing machine happy.

Blogging, because it is somewhat relevant to Free Software :) and there are even sources https://www.trueelena.org/clothing/projects/pajamas_set.html#downloads, under a DFSG-Free license :)
Categories: FLOSS Project Planets

MD Systems blog: Drupal 8 security features: user-submitted data sanitization

Planet Drupal - Mon, 2017-03-27 03:21
Recently, we had to create a security report for one of our clients about their Drupal 8 project. We described how Drupal 8 protects against most common vulnerabilities and added some project specific tests to secure as good as possible that it cannot be attacked. This resulted in a document that we thought is worth to be transferred into a series of blog posts.
Categories: FLOSS Project Planets

Abu Ashraf Masnun: Django REST Framework: Using the request object

Planet Python - Mon, 2017-03-27 02:49

While working with Django REST Framework aka DRF, we often wonder how to customize our response based on request parameters. May be we want to check something against the logged in user (request.user) ? Or may be we want to modify part of our response based on a certain request parameter? How do we do that? We will discuss a few use cases below.

ModelViewSet - Filtering based on request

This is very often required while using ModelViewSets. We have many Items in our database. But when listing them, we only want to display the items belonging to the current logged in user.

from rest_framework.permissions import IsAuthenticated class ItemViewSet(ModelViewSet): permission_classes = (IsAuthenticated,) serializer_class = ItemSerializer def get_queryset(self): queryset = Item.objects.all().filter(user=request.user) another_param = self.request.GET.get('another_param') if another_param: queryset = queryset.filter(another_field=another_param) return queryset

If you are using the awesome ModelViewSet, you can override the get_queryset method. Inside it, you can access the request object as self.request. In the above example, we are only listing the items which has our current user set as their user field. At the same time, we are also filtering the queryset based on another parameter. Basically you have the queryset and self.request available to you, feel free to use your imagination to craft all the queries you need!

Serializers - Modifying Response based on request

What if we don’t want to display item_count for the users by default? What if we only want to display that field when a request parameter, show_count is set? We can override the serializer to do that.

class UserSerializer(ModelSerializer): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) context = kwargs.get('context', None) if context: request = kwargs['context']['request'] show_count = request.GET.get('show_count') if show_count: self.fields['item_count'] = IntegerField(source="item_count")

When Serializers are constructed by DRF, it gets the request in the context. So we should always check if it exists and use it as needed. We can override the serializer fields by accessing self.fields.

Please note: The request object will be passed only if DRF constructs the serializer for you, for example when you just pass the serializer_class to a ModelViewSet. But if you are using the Serializer in your custom views, please do remember to pass the request manually, otherwise it won’t work.

item_serializer = ItemSerializer(item, context={"request": request})

In our case we have just used IntegerField. You can of course use another serializer to embed the full data of a related field.

Using request in Serializer Fields

Serializer fields have context too!

class ShortURLField(ReadOnlyField): def to_representation(self, value): return self.context['request'].build_absolute_uri(value)

and here’s the serializer:

class URLSerializer(ModelSerializer): short_url = ShortURLField() class Meta: model = URL fields = "__all__"

In the URL model, there is a method named short_url that returns a slug for that url. In our custom ShortURLField, we have customized the to_representation method to use the build_absolute_uri(value) method on current request for creating the full url from the slug.

Categories: FLOSS Project Planets

Mike Driscoll: Python 101 Screencast: Episode #13 – The csv module

Planet Python - Sun, 2017-03-26 21:56

This video tutorial is about Python’s csv module. It comes from my first book, Python 101. You can also read a version of this here.

Categories: FLOSS Project Planets

Platform.sh: Now you can save time in a database

Planet Drupal - Sun, 2017-03-26 21:00

(With due apologies to Jim Croce.)

Our efforts to expand the power and capability of users of Platform.sh continues! The latest addition to our services suite is Influx DB 1.2. Influx DB is a time-series database well suited to recording large volumes of data over time. That makes it a good choice for high-volume logging, data collection, and metrics.

In fact, we are planning to use it ourselves for that last point. Stay tuned…

Categories: FLOSS Project Planets

undpaul: undpaul is in Munich now

Planet Drupal - Sun, 2017-03-26 20:00
We are used to successfully work with our clients all over Germany. It is not important for us, in what part of the country the next project awaits us. But instead we are eager to prepare a great environment for our team, so it can provide good quality that leads the project to success. Our focus is always on supporting our clients to reach their goals and exceed them. …
Categories: FLOSS Project Planets

Justin Mason: Links for 2017-03-26

Planet Apache - Sun, 2017-03-26 19:58
  • American Snoper – Medium

    The grugq on Putin vs France:

    How modern conflicts play out in the informatics sphere, what I mean when I talk about cyber war, is happening in France. After France there will be Germany, then the Scandinavian countries have their elections. There is no chance that Putin attempting to shape the world to best suit Russian interests will abate. Currently, the strongest area that he can contend in is the informatics sphere, the cyber realm, where human perception of reality is shaped.

    (tags: putin france elections russia cyber-war hacking security wikileaks)

Categories: FLOSS Project Planets

Dirk Eddelbuettel: RcppTOML 0.1.2

Planet Debian - Sun, 2017-03-26 18:12

A new release of RcppTOML is now on CRAN. This release fixes a few parsing issues for less frequently-used inputs: vectors of boolean or date(time) types, as well as table array input.

RcppTOML brings TOML to R. TOML is a file format that is most suitable for configurations, as it is meant to be edited by humans but read by computers. It emphasizes strong readability for humans while at the same time supporting strong typing as well as immediate and clear error reports. On small typos you get parse errors, rather than silently corrupted garbage. Much preferable to any and all of XML, JSON or YAML -- though sadly these may be too ubiquitous now. TOML is making good inroads with newer and more flexible projects such as the Hugo static blog compiler, or the Cargo system of Crates (aka "packages") for the Rust language.

Changes in version 0.1.2 (2017-03-26)
  • Dates and Datetimes in arrays in the input now preserve their types instead of converting to numeric vectors (#13)

  • Boolean vectors are also correctly handled (#14)

  • TableArray types are now stored as lists in a single named list (#15)

  • The README.md file was expanded with an example and screenshot.

  • Added file init.c with calls to R_registerRoutines() and R_useDynamicSymbols(); also use .registration=TRUE in useDynLib in NAMESPACE

  • Two example files were updated.

Courtesy of CRANberries, there is a diffstat report for this release.

More information is on the RcppTOML page page. Issues and bugreports should go to the GitHub issue tracker.

This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.

Categories: FLOSS Project Planets

PyBites: Code Challenge 12 - Build a Tic-tac-toe Game

Planet Python - Sun, 2017-03-26 18:01

Hi Pythonistas, a new week, a new 'bite' of Python coding! After last week's conceptual challenge (generators), we'd like to challenge you this week to build Tic-tac-toe. Every time we do games (previously Word Values and Hangman) we learn a lot. Enjoy and we review solutions end of this week.

Categories: FLOSS Project Planets

Carl Chenet: Retweet all tweets matching a regex with the Retweet bot

Planet Python - Sun, 2017-03-26 18:00

When using the Retweet bot to retweet some tweets from a Twitter account to another one, you may need some complex patterns, not easy to match with the common string you usually use.

The match feature

Starting from Retweet version 0.10 and thanks to a great contribution by @vanekjar, you are now able to use the parameter match in the [retweet] section of the configuration file  to use regular expressions for your pattern matching. Have a look at the following configuration file:

[retweet] match=[Rr]etweet v.* available

The following configuration will retweet any tweet with a pattern matching the regular expression above, like « retweet v0.10 available » or « Retweet v1.0 available ».  Pretty cool hmm?

Full setup for Retweet

Ok, now, lets setup a full environment. First lets install the last version of retweet

# pip3 install retweet

Then lets create a retweet user with the home /var/lib/retweet:

# adduser --home /var/lib/retweet retweet

The proper way to store our configuration file is to put it in the /etc/retweet directory:

# mkdir -p /etc/retweet

Now lets write our configuration file. You have a full example available in the Configure section of the official Retweet documentation.

# vim /etc/retweet/retweet.ini

Almost ready! Last step: write a line in the crontab in order to launch Retweet on a regular basis:

*/10 * * * retweet retweet /etc/retweet/retweet.ini

And voila! Your Retweet bot is ready.

… and finally

You can help the Retweet Bot by donating anything through Liberaypay (also possible with cryptocurrencies). That’s a big factor motivation

Categories: FLOSS Project Planets

Nikola: Nikola v7.8.4 is out!

Planet Python - Sun, 2017-03-26 14:26

On behalf of the Nikola team, I am pleased to announce the immediate availability of Nikola v7.8.4. It fixes some bugs and adds new features.

What is Nikola?

Nikola is a static site and blog generator, written in Python. It can use Mako and Jinja2 templates, and input in many popular markup formats, such as reStructuredText and Markdown — and can even turn Jupyter (IPython) Notebooks into blog posts! It also supports image galleries, and is multilingual. Nikola is flexible, and page builds are extremely fast, courtesy of doit (which is rebuilding only what has been changed).

Find out more at the website: https://getnikola.com/


Install using pip install Nikola or download tarballs on GitHub and PyPI.

Changes Features
  • Refactor RSS feed generation to allow better plugin access
  • Add Jupyter config as dependency for jupyter posts (by @knowsuchagency)
  • Make nikola plugin --list-installed more readable (Issue #2692)
  • Accept now in post-list date conditions
  • Add RSS_COPYRIGHT, RSS_COPYRIGHT_PLAIN, and RSS_COPYRIGHT_FORMATS options in conf.py which can be disabled by specifying copyright_=False to generic_rss_renderer, or overriden by specifying an explicit value.
  • Write PID of detached nikola serve process to a file called nikolaserve.pid
  • Append file name (generated from title) if nikola new_post receives directory name as path (Issue #2651)
  • Add a require_all_tags parameter to the post-list directive to show only posts that have all specified tags. (Issue #2665)
  • Add META_GENERATOR_TAG option in conf.py allowing the meta generator tag to be disabled (Issue #2628)
  • Allow setting custom GUID in feeds (Issue #2378)
  • Remove misplaced and duplicated meta description tags (Issue #2694)
  • Fix crash if PAGE_INDEX is enabled and make them actually work (Issues #2646, #2702)
  • Ignore NEW_POST_DATE_PATH when creating pages (Issue #2699)
  • Ensure post.updated is timezone-aware (Issue #2698)
  • Pass previously missing post object and language to reST compiler and language to Markdown compiler (for shortcodes)
  • Fix crashes when rendering subcategories (Issue #2681)
  • Prevent writing cache files outside of the cache folder (Issue #2684)
  • Fix mimetype guessing in auto mode (Issue #2645)
  • Fix filters.html5lib_xmllike for laters html5lib (Issue #2648)
  • Skip the current post in post lists (Issue #2666)
  • Fix poor performance when compiling multiple markdown documents with the markdown compiler. (Issue #2660)
  • Fix crash if SHOW_INDEX_PAGE_NAVIGATION is True while INDEXES_STATIC is False. (Issue #2654)
  • Make NEW_POST_DATE_PATH follow rrule if it exists (Issue #2653)
Categories: FLOSS Project Planets

Erik Marsja: How to do Descriptives Statistics in Python using Numpy

Planet Python - Sun, 2017-03-26 14:15

In this short post we are going to revisit the topic on how to carry out summary/descriptive statistics in Python. In the previous post, I used Pandas (but also SciPy and Numpy, see Descriptive Statistics Using Python) but now we are only going to use Numpy. The descriptive statistics we are going to calculate are the central tendency (in this case only the mean),  standard deviation, percentiles (25 and 75), min, and max.

Loading the data

In this example I am going to use the Toothgrowth dataset (download here). It is pretty easy to load a CSV file using the genfromtxt method:

import numpy as np data_file = 'ToothGrowth.csv' data = np.genfromtxt(data_file, names=True, delimiter=",", dtype=None)

Notice the arguments we pass. The first row has the names and that is why we set the argument ‘names’ to True. One of the columns, further, has strings. Setting ‘dtype‘ to None enables us to load both floats and integers into our data.

Descriptive statistics using Numpy

In the next code chunk, below, we are going to loop through each level of the two factors (i.e., ‘supp’, and ‘dose’) and create a subset of the data for each crossed level. If you are familiar with Pandas, you may notice that subsetting a Numpy ndarray is pretty simple (data[data[yourvar] == level). The summary statistics are then appended into a list.

summary_stats = [] for supp_lvl in np.unique(data['supp']): for dose_lvl in np.unique(data['dose']): # Subsetting data_to_sum = data[(data['supp'] == supp_lvl) & (data['dose'] == dose_lvl)] # Calculating the descriptives mean = data_to_sum['len'].mean() sd = data_to_sum['len'].std() max_supp = data_to_sum['len'].max() min_supp = data_to_sum['len'].min() ps = np.percentile(data_to_sum['len'], [25, 75] ) summary_stats.append((mean, sd, max_supp, min_supp, ps[0], ps[1], supp_lvl, dose_lvl))

The results

From the list of data we are going to create a Numpy array. The reason for doing this is that it will get us a bit prettier output. Especially, when we are setting the print options (line 19, below).

results = np.array(summary_stats, dtype=None) np.set_printoptions(suppress=True) print(results)

That was it. I still prefer doing my descriptives statistics using Pandas. Primarily, because of that the output is much more nicer but it’s also easier to work with Pandas dataframes compared to Numpy arrays.

The post How to do Descriptives Statistics in Python using Numpy appeared first on Erik Marsja.

Categories: FLOSS Project Planets

fluffy.pro. Drupal Developer's blog: Panels: custom cache plugin

Planet Drupal - Sun, 2017-03-26 08:27
Last time we've created a style plugin. Now we will learn how to cache panel panes with custom cache plugins.
Read more »
Categories: FLOSS Project Planets

PyBites: Twitter digest 2017 week 12

Planet Python - Sun, 2017-03-26 06:29

Every weekend we share a curated list of 15 cool things (mostly Python) that we found / tweeted throughout the week.

Categories: FLOSS Project Planets

Import Python: Import Python Weekly Issue 117 - Memoization and Decorators, Apache Airflow, Machine learning & more

Planet Python - Sun, 2017-03-26 04:57
Worthy Read
Memoization and Decorators with Python With memoization, we can “memoize” (remember, store) the result of problems that we’ve dealt with before, and return a stored result instead of repeating calculations.
Cloud Hosted Databases 9 DBs to choose from, 5 min setup, auto-scaling, Cloud hosted. Free for 30 Days. Sponsor
Get started developing workflows with Apache Airflow Apache Airflow is an open-source tool for orchestrating complex computational workflows and data processing pipelines. If you find yourself running cron task which execute ever longer scripts, or keeping a calendar of big data processing batch jobs then Airflow can probably help you. This article provides an introductory tutorial for people who want to get started writing pipelines with Airflow.
Essential Statistics for Data Science: A Case Study using Python, Part I In this post, we'll take a step back to cover essential statistics that every data scientist should know.
PyMedium PyMedium is an unofficial Medium API written in python flask. It provides developers to access to user, post list and detail information from Medium website. This is a read-only API to access public information from Medium, you can customize this API to fit your requirements and deploy on your own server.

Visualization in TensorFlow: Summary and TensorBoard This article is going to discuss some basic methods and functions in tensorflow used to visualize and monitor the training process. I believe visualization is top priority for the research. Because the deep learning itself is a “black box”. So, if the visualization could help us analyze why the final result is successful or failed.
Predicting Housing Prices with Linear Regression using Python, pandas, and statsmodels pandas
Pandas & Seaborn - A guide to handle & visualize data elegantly pandas
Playing With Machine Learning Algorithms machine learning
Hack The Virtual Memory virtual memory
Build a Distributed Streaming System with Apache Kafka and Python kafka
Drag and Drop Files with HTML5 and Flask flask
How we use IBM Watson speech-to-text to transcribe our classes In this step by step guide we’ll show you how to transcribe an audio file using IBM Watson speech-to-text API and a little bit of Python.
How to Make a Text Summarizer - Intro to Deep Learning I'll show you how you can turn an article into a one-sentence summary in Python with the Keras machine learning library. We'll go over word embeddings, encoder-decoder architecture, and the role of attention in learning theory.
machine learning, video
Continuous Integration with Python and Circle CI CI
How to dynamically filter ModelChoice's queryset in a ModelForm? django
Python 3.6.1 is now available core-python
Building a serverless Python app in minutes with GCP Google's answer to aws lambda.
google cloud, cloud functions
Django Admin: Expensive COUNT(*) Queries If you have maintained a website with a huge amount of data, you probably already know that Django Admin can become very slow when the database table gets so large. If you log the SQL queries (either using Django logging or using Django Debug Toolbar), you would notice a very expensive SQL query, something like this.

Aeneas – a Python audio/text aligner - 793 Stars, 38 Fork aeneas is a Python/C library and a set of tools to automagically synchronize audio and text (aka forced alignment) http://www.readbeyond.it/aeneas/
Snaky - 28 Stars, 2 Fork A snake game, three versions of AI included, implemented in python, pygame.
facebook-messenger-bot-tutorial - 10 Stars, 0 Fork facebook-messenger-bot-tutorial use Python Django
Ticky - 9 Stars, 3 Fork Tic Tac Toe game, implemented in python, pygame. It includes a unbeatable computer AI. Have a try : )
Categories: FLOSS Project Planets

Jeff Geerling's Blog: Soup to Nuts: Using Drupal VM to build local and prod

Planet Drupal - Sat, 2017-03-25 23:06

In preparing for my session Developing for Drupal 8 with Drupal VM at MidCamp later this month, I wanted to build out an example of a canonical "this is the way I'd do it" Drupal 8 site using nothing but Drupal VM and Composer. And I wanted to build both my local development environment and a production environment on DigitalOcean, all using the Ansible automation playbooks built into Drupal VM.

I also wanted to brush up Drupal VM's production environment management capabilities, so I made a few more tweaks to Drupal VM and the main Ansible role that powers the Drupal deployment and installation, and released Drupal VM 4.4 with some great production environment improvements!

Categories: FLOSS Project Planets

Dirk Eddelbuettel: RApiDatetime 0.0.2

Planet Debian - Sat, 2017-03-25 18:38

Two days after the initial 0.0.1 release, a new version of RApiDatetime has just arrived on CRAN.

RApiDatetime provides six entry points for C-level functions of the R API for Date and Datetime calculations. The functions asPOSIXlt and asPOSIXct convert between long and compact datetime representation, formatPOSIXlt and Rstrptime convert to and from character strings, and POSIXlt2D and D2POSIXlt convert between Date and POSIXlt datetime. These six functions are all fairly essential and useful, but not one of them was previously exported by R.

Josh Ulrich took one hard look at the package -- and added the one line we needed to enable the Windows support that was missing in the initial release. We now build on all platforms supported by R and CRAN. Otherwise, I just added a NEWS file and called it a bugfix release.

Changes in RApiDatetime version 0.0.2 (2017-03-25)
  • Windows support has added (Josh Ulrich in #1)
Changes in RApiDatetime version 0.0.1 (2017-03-23)
  • Initial release with six accessible functions

Courtesy of CRANberries, there is a comparison to the previous release. More information is on the rapidatetime page.

For questions or comments please use the issue tracker off the GitHub repo.

This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.

Categories: FLOSS Project Planets

foss-north speaker line-up

Planet KDE - Sat, 2017-03-25 17:35

I am extremely pleased to have confirmed the entire speaker line-up for foss north 2017. This will be a really good year!

Trying to put together something like this is really hard – you want the best speakers, but you also want a mix of local and international, various technologies, various viewpoints and much, much more. For 2017 we will have open hardware and open software, KDE and Gnome, web and embedded, tech talks and processes, and so on.

The foss north conference is a great excuse to come visit Gothenburg in the spring. Apparently, Sweden’s wildest city!

Categories: FLOSS Project Planets

Bits from Debian: Debian Project Leader elections 2017

Planet Debian - Sat, 2017-03-25 17:30

It's that time of year again for the Debian Project: the elections of its Project Leader!

The Project Leader position is described in the Debian Constitution.

Two Debian Developers run this year to become Project Leader: Mehdi Dogguy, who has held the office for the last year, and Chris Lamb.

We are in the middle of the campaigning period that will last until the end of April 1st. The candidates and Debian contributors are already engaging in debates and discussions on the debian-vote mailing list.

The voting period starts on April 2nd, and during the following two weeks, Debian Developers can vote to choose the person that will fit that role for one year.

The results will be published on April 16th with the term for new the project leader starting the following day.

Categories: FLOSS Project Planets
Syndicate content