Posts

Showing posts from 2020

An Automatic Table of Contents Generator in Javascript

Build a Table of Contents in Javascript  Web articles and reports can be made easier to navigate with a table of contents. They can be tedious to create and maintain, so let Javascript take the strain.
Web Articles or Reports Do you write articles for the web, or publish reports there? Then you should enhance them with a stylish table of contents so that your reader can find their way around.

And the good things is that you don't need to do much apart from include some Javascript and CSS in your page along with a single <div> tag. By doing this you'll end up with a table of contents that looks like the one on this page.
How it works All of the sections in your article need to be given a header - you doubtless already do this - and the script that I am going to show you will scan those headers, create anchors in the HTML and build the table in a panel at the top of the page.

First we need to settle on a header that we are going to use for our section headings. Let's…

Give your old PC new life with Lubuntu Linux

Image
Got an old pc or laptop? Give it a new lease of life. Install a lightweight Linux, like Lubuntu.
Simple is better I've never been a great fan of complicated user interfaces. To be honest, 20 odd years ago, I would have been perfectly happy to stick with Windows 2000 but my son persuaded me to upgrade to XP.
It's been downhill ever since.

But Linux is different - it's simple to use and most of the applications that you would expect to find on a modern PC are available for it.
"Reduce, Reuse, Recycle" - Jack Johnson Also, moving to Linux had never been easier and updating an old PC is good for the environment if you reuse it rather than buy a new one. "Reduce, reuse, recycle" as the Jack Johnson song goes.

So let's look at how to install Lubuntu, a lightweight version of the popular Ubuntu Linux, and see what the benefits are of a lightweight Linux on old hardware.

The first benefit is performance. I converted an old Windows Vista laptop to Lubuntu…

COVID-19 Data Tracking with Python and Smartable AI

Image
Building a COVID-19 data tracker in Python with the Smartable AI API






The COVID-19 pandemic is extremely worrying for everyone but are the facts and figures that you see in the media clear? Do you sometimes look at the numbers and the graphs that appear on the TV and the web and think something like, “That’s fine but what about trends?” It’s all very well reporting the scary absolute numbers, and we need to know these things but are things getting better or worse? Just how worried do we need to be?



Sometimes the apocalyptic news reports are less than crystal clear about the progress of the virus. But now you don’t have to rely on third party sources. Now you can create your own graphs and do your own analysis.
There are a number of sources for COVID-19 data — Johns Hopkins University is a great example. But you can create your own data tracking app that and derive your own indicators or concentrate on the data that you are interested in, with the Smartable AI API.
It’s free to use alt…

Creating a Basic Python Web App with Flask

Image
Simple web applications in Python are easily constructed with the Flask micro-framework.Why would you want a web app and not just a web page?

You can make quite sophisticated web pages with just HTML and Javascript but if you want to incorporate data that needs to be stored somewhere, or needs some sort of sophisticated processing, you might be better off building a proper application.

Traditionally, web applications were written in PHP, JSP or ASP. But these days Python is an perfectly good choice for creating web apps.
In this article we are going to make a simple example of a Python web app using Python and Flask. Here's what we'll do:

1. Get the Flask library for Python and learn how to use it.
2. Writea Flask-based program to provide some simple data. 3. Write a web page template to display that data.
You don't need a high level of skill to follow this tutorial but you do need to have a basic knowledge of Python and HTML, and know what a web page and a server is. I als…

Visualizing Simple Twitter Statistics with Python and Pandas

Image
Twitter statistics are great to see how well you are engaging with your audience but you can use Python to see how are others doing?

If you use Twitter cards or adverts, you can get a very good idea how people are engaging with your tweets from the official Twitter statistics. But what about your friends, your colleagues… your competitors? Just a little bit of Python code (that you can download) might do the trick.


Need An introduction to Python? Just Enough Python
Imagine that you are a global news giant and are wondering just how well you are regarded by your audience compared with, say, CNN, or the BBC. One thing you might do is compare the level of engagement of their tweets and compare them to your own.

While you may not be able to see the same engagement statistics as for your own account, there are some simple stats that you can see. It just takes a little programming and a Twitter Developer account.

I’m going to show you how it is really quite straightforward to monitor the nu…

Plotting with Pandas: An Introduction to Data Visualization

Image
If you are a budding Data Scientist or Data Journalist, being able to visualize your data with Python and Pandas gives you the ability to better understand and communicate it. And little programming knowledge is required.



Visualizing data gives you the opportunity to gain insights into the relationships between elements of that data, to spot correlations and dependencies, and to communicate those insights to others. By following this article you will learn how to plot impressive graphics using Python and Pandas.

Here is what you’ll cover: Importing the appropriate librariesGetting data about the weather in LondonProduce a first Pandas visualization using the plot() methodFind out how different types of charts are createdPlotting simple charts: line charts, bar charts, pie charts and scatter diagramsPlotting statistical Pandas charts— spotting unusual eventsBox Plots — Showing the range of dataHistogramsChanging the number of bins to focus on the outliers — Just how often is it really, …