teleren/devto huggingface dataset:
Build your audiobook from any PDF with Python
Tags: python, tutorial, showdev, productivity
Published: 2021-04-28 11:45:19



Did you know that you can build your audiobook with Python from any PDF? Sounds cool, isn't it?
In this quick tutorial, I will show you how to build an audiobook with Python. 

In our example, we will be using `PyPDF2` and `pyttsx3`. 

[PyPDF2](https://pypi.org/project/PyPDF2/) is a pure-Python library built as a PDF toolkit. It is capable of:

-   extracting document information (title, author, …)
-   splitting documents page by page
-   merging documents page by page
-   cropping pages
-   merging multiple pages into a single page
-   encrypting and decrypting PDF files
-   and more!

By being Pure-Python, it should run on any Python platform without any dependencies on external libraries. It can also work entirely on StringIO objects rather than file streams, allowing for PDF manipulation in memory. It is therefore a useful tool for websites that manage or manipulate PDFs.

[Pyttsx3](https://pypi.org/project/pyttsx3/) is a text-to-speech conversion library in Python. Unlike alternative libraries, it works offline, and is compatible with both Python 2 and 3.

Let's jump to the code:

First we need to import our dependencies:
```python
import PyPDF2
import pyttsx3
```
Then we need to open our `pdf`

```python
pdf_file =  open('test.pdf', 'rb')
```
where `mode='rb'` is used for open the file in binary format for reading.

We define PDF file reader:
```python
pdf_read = PyPDF2.PdfFileReader(pdf_file)
```
Then we need to give number of pages in PDF file:

```python
num_pages = pdf_read.numPages
```
Then we define our `init` and we also can do a `print` :
```python
engine = pyttsx3.init()
print('Read PDF')
```
After that, we define our loop that will read all pages one by one:
```python
for n in range(0, num_pages):
    page = pdf_read.getPage(n)
    text = page.extractText()
    x = n + 1
    print(f"Reading page {x}/{num_pages}.")
    engine.say(text)
    engine.save_to_file(text, 'book.mp3')
    engine.runAndWait()
```
This part of the code retrieves a page by the number from this PDF file, extracts text from the page, and reads text from the page. Also we save to mp3 file. 


Thank you all.
Wednesday Links - Edition 2021-04-28 
Tags: java, jvm, database, saas
Published: 2021-04-28 11:28:47


JVM is a good choice if you worry about the Earth (30m read) 🤩
https://mobile.twitter.com/MIT_CSAIL/status/1385269509188096004

Consider use timestamp instead of boolean in your DB (3m read) 📆
https://changelog.com/posts/you-might-as-well-timestamp-it

GraalVM seems not to be production ready yet (30s read) 💩
https://twitter.com/bsideup/status/1386591251764482048

How SaaS can accelerate your business (18m read) 🤑
https://martinfowler.com/articles/platform-prerequisites.html

Have you known that you can compile your Java code to older bytecode version? Here you can check how it works (10m read) ⚙️
https://www.morling.dev/blog/the-anatomy-of-ct-sym-how-javac-ensures-backwards-compatibility/

How to use mocks with deep stubs? (9m read) 🤿
https://rieckpil.de/creating-deep-stubs-with-mockito-to-chain-method-stubbing/

Crypto miners are killing free CI (3m read) 🤬
https://layerci.com/blog/crypto-miners-are-killing-free-ci/

Do you need compile time reflection in Kotlin? Here you have (4m read) ⛑
https://github.com/JetBrains-Research/reflekt
React Native ActivityIndicator Andriod IOS Example
Tags: reactnative, android, mobile, opensource
Published: 2021-04-28 11:25:02

This tutorial explains how to display loading screen or activity indicator in react native application for android and ios device. ActivityIndicator is the common circular loading indicator used in both android and iOS devices. This type of loader which is basically used to display a loading dotted moving circle on android and iPhone devices, When user trying to loading something from server.

React Native ActivityIndicator Andriod IOS Example 


React Native ActivityIndicator Example 
Lets see the complete source code that helps to display loading screen or activity indicator in react native application for android and ios device.

Step 1: Create a new react native project, if you don’t know how to create a new project in react native just follow this tutorial.

Step 2: Open App.js File in your favorite code editor and erase all code and follow this tutorial.

Step 3: Through react , react-native packages import all required components.
import React, { Component } from 'react';
import { StyleSheet, View, ActivityIndicator, Button } from 'react-native';

Step 4: Lets create constructor block inside your App component. In the constructor block we have created state variables that helps to hide and show activity indicator from the device screen.

<a href="https://www.skptricks.com/2019/08/react-native-activityindicator-example.html"> Read more... </a>
Crafting a Dark Mode switch with Vuetify
Tags: vue, vuetify, javascript
Published: 2021-04-28 11:24:18

This tutorial will show how to create a dark mode toggle using [Vuetify](https://vuetifyjs.com/en/). This tutorial assumes you already have a Vue2 app with Vuetify. At the time of writing this article Vuetify doesn't fully support Vue3. 
Here is an accompanying [GitHub repository](https://github.com/N8ers/vuetify-dark-mode) if you'd like to have a working copy to clone.

###Step 1: Modifying vuetify.js
`vuetify.js` is a file that gets created when you first add Vuetify to your Vue application. It can be found here: `src/plugins/vuetify.js`. We will make the modifications below.
```js
import Vue from 'vue';
import Vuetify from 'vuetify/lib/framework';
import colors from 'vuetify/lib/util/colors'
Vue.use(Vuetify);

export default new Vuetify({
  theme: {
    themes: {
      light: {
        primary: colors.green.accent3,
        secondary: colors.deepOrange.lighten1
      },
      dark: {
        primary: '#90CAF9',
        secondary: '#E91E63'
      },
    },
  },
});
```
You can set these colors to be what ever you'd like, just make sure if you have a `primary` color for your `light theme` that you have one for your `dark theme` as well.

If you want to use the colors built into Vuetify, make sure you import the color library on line 3. You can always use hex instead, but you will need to place it in quotes (I did that in the dark theme as an example).

###Step 2: Adding a toggle
The [documentation on vuetify switches](https://vuetifyjs.com/en/components/switches/) uses a `v-model` to bind the data. We want to break that `v-model` out into a `:value=""` that reads the data from the data object, and an `@change=""` that will trigger a method. This setup allows for greater flexibility on *what* the switch will do.
Inside of the `toggleDarkMode()` we want to switch the Vuetify theme. We can access the Vuetify theme using `this.$vuetify.theme`, here is the documentation for it: [this.$vuetify.theme](https://vuetifyjs.com/en/features/theme/#light-and-dark).

```vue
<template>
  <v-app>
    <v-app-bar app color="primary">Dark Mode Toggle</v-app-bar>

    <v-main>
      <v-container>
        <v-switch 
          :value="darkMode" 
          @change="toggleDarkMode" 
          :label="`toggle ${switchLabel} mode`"
        ></v-switch>
        <v-col class="primary">I am a primary card</v-col>
        <v-col class="secondary">I am a secondary card</v-col>
      </v-container>
    </v-main>
  </v-app>
</template>

<script>
export default {
  name: 'App',
  data: () => ({ 
      darkMode: false
    }),
    methods: {
      toggleDarkMode: function () {
        this.$vuetify.theme.dark = !this.$vuetify.theme.dark;
        this.darkMode = !this.darkMode;
      }
    },
    computed: {
      switchLabel: function () {
        return this.darkMode ? 'light' : 'dark';
      }
    }
};
</script>

```
There you have it! A switch that toggles between a light and dark theme!


Vuetify is a living, changing UI Library. Specifics of this article may change over time. If you notice something is out of date, feel free to contact me. Happy designing!
# Big O
Published: 2021-04-28 11:17:05

## Why Big O

Big O is used to compare algorithms and analyze the efficiency of an algorithm, since comparing the time taken to execute an algorithm is not very accurate, because different computers have different processing speed's and an algorithm might run faster or slower depending on computer specifications.

## What is big O?

To put it simply it is a way of analyzing an algorithm or a function with respect to the size of the input. Here input could be an array or a string anything.

To better understand let us say you have to send a file to your friend, you can do it by sending it online or you could go to him and hand it over, here if you choose to send it online it takes linear time i.e O(n) **see the image below**, if your file is 10MB it takes say 4 seconds if your file is 20MB it takes 8 seconds and if your file is 1TB then it might take even a day, so the time complexity to send the file depends on the input size, the time increases linearly as input increases. But if you choose to go over and hand it to him that is constant time O(1) **(see the image below)**, i.e the time to send doesn't depend on the size of the file it takes the same amount of time to deliver 10MB or 1TB.

So Big O is a measure of the increase of time with respect to the input size.


![Alt text of image](https://danielmiessler.com/images/big-o-chart-tutorial-bazar-aymptotic-notations-1.png)

### Now let us look at some algorithms and find their time complexities

Ex 1: The following program prints all the elements in an array one by one

```java
 public static void traverseArray(int[] array) {
        for (int i : array) {
            System.out.println("i :" + i);
        }
    }
```

Here the time complexity is O(N)**linear time** where N is the size of the array, i.e the time taken to execute increases linearly with an increase in input size i.e array size, because we have to do an operation i.e printing the element for all elements in the array, assume one operation takes one second and if we have 5 elements the total time is 5 seconds and if we have 20 elements the total time is 20 seconds i.e the time grows linearly with respect to the input.

Ex 2: The following program prints all pairs of elements in an array

```java
public static void traverseArray(int[] array) {
        for (int i : array) {
            for (int j : array) {
                System.out.println("(" + i + "," + j + ")");
            }
        }
```
Here the time complexity is O(N**2) where N is size of the input.
why O(N**2)? because for each element there is O(N) work to be done in the inner loop, and this has to be repeated for every element in the outer loop so big O becomes O(N*N) i.e O(N**2).

TO get a better understanding checkout these resources:
[Youtube video](https://youtu.be/v4cd1O4zkGw)
[examples of big O analysis](https://www.geeksforgeeks.org/examples-of-big-o-analysis/)
Regularization
Tags: regularization, neuralnetwork, machinelearning
Published: 2021-04-28 11:08:39

**Regularization** refers to training our model well enough that it can generalize over data it hasn’t seen before. Regularization is a common method used to reduce overfitting and improve the model’s performance for new inputs.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8cboet2rgm8b8f5sghfi.jpg)
**How regularization works**

***Regularization methods*** are techniques that seek to reduce overfitting (i.e., reduce generalization errors) by keeping network weights small. There are three very popular and efficient regularization techniques called L1, L2, and dropout.

**1. L1 regularization**

In the case of L1 regularization (also knows as Lasso regression), we simply use another regularization term, Ω. This term is the sum of the absolute values of the weight parameters in a weight matrix. L1 encourages weights to 0.0 (if possible), which results in more sparse weights (more weights with values equal to 0.0). Hence, the cost function in L1 becomes:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t7zbeqkzxh2kwhj13byc.jpg)
**2. L2 regularization**

L2 regularization offers more nuance by penalizing larger weights more severely, thus resulting in weights that are less sparse. The regularization term (Ω) is defined as the Euclidean Norm (or L2 norm) of the weight matrices and is the sum over all squared weight values of a weight matrix. The cost function in L2 becomes:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b78ithbo63hfg21hqpdk.jpg)
**3. Dropout regularization**

Dropout regularization involves a neuron of the neural network getting turned off during training with a probability of P. This results in a simpler neural network since some neurons are not active at all.

A simpler version of the neural network results in less complexity, which can reduce overfitting. The deactivation of neurons with a certain probability (P) is applied at each forward propagation and weight update step.
Mapa Personalizado no Strava: #statmaps
Tags: strava, ciclismo, corrida
Published: 2021-04-28 10:47:45

O [Strava](https://www.strava.com/) Lançou uma funcionalidade para assinantes que colore seu trajeto no mapa de acordo com os dados escolhidos, basta inserir uma das tags abaixo na descrição da atividade:

- **\#maparitmo ou \#PaceMap:** uma velocidade mais alta/um ritmo mais lento será indicado por um azul mais escuro.
- \#mapavelocidade ou \#SpeedMap: uma velocidade mais alta/um ritmo mais lento será indicado por um azul mais escuro.
- \#mapafrequênciacardíaca ou \#HeartRateMap: uma frequência cardíaca mais alta será indicada por um vermelho mais escuro.
- \#mapaelevação ou \#ElevationMap: uma elevação absoluta mais baixa será indicada em preto e uma elevação superior será indicada em amarelo.
- \#mapainclinação ou \#GradientMap: as descidas serão indicadas em amarelo e as subidas em vermelho.
- \#mapapotência ou \#PowerMap:uma potência mais alta será indicada por um roxo mais escuro. Lembre-se que este estilo de mapa não está disponível para atividades com potência estimada.
- \#mapatempo ou \#TimeMap: um tempo decorrido mais longo será indicado em vermelho mais escuro.
- \#mapatemperatura ou \#TemperatureMap: temperaturas mais altas serão indicadas em vermelho mais escuro.

Fonte: https://support.strava.com/hc/pt-br/articles/360049869011-Linhas-de-atividade-personalizadas-statmaps
Mac でVim（MacVim）でファイルを開く方法・MacVimをapplication folderに出現させる方法
Tags: vim, mac, application, app
Published: 2021-04-28 10:41:29

# MacVimをapplication folderに出現させる方法

## Macvimのinstall

```
brew install macvim
```

## Macvim.appの位置の確認

```
ls /usr/local/Cellar/macvim/8.2-171/MacVim.app
```

* [8.2-171]の部分はinstallしたversionによって異なるので注意

## /Applicationにsymbolic linkを作成

```
ln -s /usr/local/Cellar/macvim/8.2-171/MacVim.app /Applications
```

## そしたらこんなふうに出てくる

![Screen Shot 2021-04-28 at 19.38.08](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/laylqp5stfim2tonwbf7.png)


# Mac でVim（MacVim）でfileを開く方法

上記の「MacVimをapplication folderに出現させる方法」を実行

↓

vimで開きたい拡張子のfileを右click -> get info -> open withからmacvimをselect、change allをclick


![Screen Shot 2021-04-28 at 19.41.07](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3lunpsnsx5r65gjkau2a.png)
Plotly4Nagios - A Graph plugin for nagios monitoring
Tags: monitoring, opensource, nagios, linux
Published: 2021-04-28 10:06:35


[Plotly4Nagios](https://github.com/vignesh88/plotly4nagios) is a nagios plugin to display the performance data in Graph. It uses the RRD database provided by pnp4nagios and visualize it in interactive graph format using plotly javascript. The first pre-release is published today in [github](https://github.com/vignesh88/plotly4nagios) and here is the installation document. You can experiment it and report the issue/feedback for further enhancement.

> Plotly4Nagios is accepted and listed under official [nagios addons](https://exchange.nagios.org/directory/Addons/Graphing-and-Trending/Plotly4Nagios/details)

## Demo

!['demo'](https://raw.githubusercontent.com/vignesh88/plotly4nagios/main/img/plotly4nagios.gif)

## Features

- Easy integration with nagios `notes_url`.
- Single page view for all performance metrics.
- Easy template change using configuration variable.
- Docker container based deploy and run.

## Prerequisite

- [pnp4nagios](https://support.nagios.com/kb/article/nagios-core-performance-graphs-using-pnp4nagios-801.html)

## Installation

- Download plotly4nagios.tar.gz and extract it under /usr/local/plotly4nagios
- Modify the config.json variables according to the environment
- Copy the plotly4nagios/plotly4nagios.conf to /etc/http/conf.d/ folder and restart httpd
- Add the follwing with  notes_url to templates.cfg.

``` bash
    notes_url /plotly4nagios/plotly4nagios.html?host=\$HOSTNAME\$&srv=_HOST_
    notes_url /plotly4nagios/plotly4nagios.html?host=\$HOSTNAME$&srv=\$SERVICEDESC$
```

- Restart httpd and nagios.

## Installation with docker(Ubuntu image)

- Build the docker image using the below command

```bash
git clone https://github.com/vignesh88/plotly4nagios.git
cd plotly4nagios
docker build -t plotly4nagios .
```

- Run the docker container using the below command

```bash
docker run -it --name plotly4nagios -p 80:80 plotly4nagios
```

Alternatively direct pull and run from docker hub.

```bash
docker run -d -p 80:80 --name plotly4nagios vignesh88/plotly4nagios
```

> Open from the browser and view the application at http://localhost/nagios

### Login details

- Username : nagiosadmin
- Password : nagios

## Screenshot

### Dark mode

!['Dark mode'](https://raw.githubusercontent.com/vignesh88/plotly4nagios/main/img/screenshot_darkmode.png)

## License

Copyright 2020-2021 © Vignesh Ragupathy. All rights reserved.

Licensed under the [MIT License](https://github.com/vignesh88/plotly4nagios/blob/ed09f8d687014107c8002d92acbc7acd2f62468a/LICENSE)
JavaSript GitHub Repositories for Interview Prep!
Tags: html, webdev, productivity, beginners
Published: 2021-04-28 09:55:39

I decided to spend the better part of this month learning how JavaScript actually works under the hood. I also decided to study some fundamental computer science topics, such as data structures and algorithms.

I have found the following resources extremely useful during this journey of improving my basic JavaScript basics:

###1.[JavaScript Algorithms and Data Structures](https://github.com/trekhleb/javascript-algorithms)
![JavaScript Algorithms and Data Structures](https://res.cloudinary.com/practicaldev/image/fetch/s--27SwYsye--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8dly1c533wc9sbof01hf.gif)

Amazing repo that presents JavaScript-based examples of many popular algorithms and data structures. Furthermore, each algorithm and data structure has related explanations and YouTube video links for further reading.

###2.[You Don't Know JS](https://github.com/getify/You-Dont-Know-JS)
![You Don't Know JS](https://res.cloudinary.com/practicaldev/image/fetch/s--wFSWbaV_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oujqazrz5nmg3i83ij5a.jpg)

Basically a holy grail for JS developers, this book series dives deep into the core mechanisms of the JavaScript language. Kyle Simpson, the author has made all the books available for [free online](https://github.com/getify/You-Dont-Know-JS/blob/1st-ed/README.md).


###3.[JavaScript Questions](https://github.com/lydiahallie/javascript-questions)
![JavaScript Questions](https://res.cloudinary.com/practicaldev/image/fetch/s--XQUVivkl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z0t8ia47ptl5q8yyc6yc.png)

###4.[Clean Code JavaScript](https://github.com/lydiahallie/javascript-questions)

Not necessarily interview-related, this repo is based on Robert C. Martin's book [Clean Code](https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882), adapted for JavaScript. It's a guide to producing readable, reusable, and refactorable software in JavaScript.

It has tons of useful examples and can be handy for pair-programming or take-home challenges.

These are the repositories I am currently using for my JS re-education. Please comment below if you have found any other resources to be more helpful and I will add them in a different post.

Hope this was helpful. Happy coding! 👩‍💻🚀👨‍💻
CREATING A REACT.JS APP
Tags: react, javascript
Published: 2021-04-28 09:55:34

React.js is a JavaScript library used for building user interfaces. Some refer to it as a framework but a library is more reasonable as it gives developers control over its usage.

React.js is managed by Facebook and a community of developers. An important feature of this technology is flexibility. It can display a simple page, also be combined with other tools and be used as a framework for complex applications. 

Some advantages of building apps with react are highlighted below:
1. Components: React apps can be divided into smaller components that can be re-used easily.

2. Properties & states: props (short for “properties”) and state are JavaScript objects used by components in React. The objects can be changed and passed to other elements and components within it; hence, there is reusable code and better organization.

3. Document object model (DOM): React uses a virtual DOM, which is a faster version of the DOM. Whenever changes are made to the states or props, React only re-renders the elements changed, instead of rendering the whole document.

**Building a React app**

The libraries required for React are downloaded using node package manager (npm) so NodeJS needs to be downloaded. After installation, the create-react-app node package assists in setting up a react project. It is installed using the command below in a command prompt:

**npm install –g create-react-app**

The project can then be created using create-react-app with the command below:

**npx create-react-app first-app**

first-app is the name of the application and the command above automatically creates a folder named first-app. The command below navigates to the project folder.

**cd first-app**

The next command is npm start. After this, your application should be running. 
The create-react-app creates several files. Some of the important files and folders are the package.json file, public/index.html, src/index.js, src/index.css, src/App.js and others.

In the URL “localhost:3000”, the application will look like this in your browser:
![react](https://thepracticaldev.s3.amazonaws.com/i/8b4746wvb57rgvo4cyeo.png)
How to use Schedule Template?
Published: 2021-04-28 09:54:48

A schedule template is used to make a schedule, different type of schedule templates are available these days such as daily work schedule template, training schedule template, class schedule template, monthly work schedule template, and more.

There are number of schedule templates available these days and these templates can be used to make any type of schedule. The utilization of the schedule template has made the process of making a schedule easy and fluent.

Source:

http://freescheduletemplate.com/
http://freescheduletemplate.com/weekly-schedule-template/
http://freescheduletemplate.com/daily-schedule-template/
http://freescheduletemplate.com/employee-work-schedule-template/
http://freescheduletemplate.com/class-schedule-template/
http://freescheduletemplate.com/cleaning-schedule-template/
http://freescheduletemplate.com/study-schedule-template/
http://freescheduletemplate.com/construction-schedule-template/
http://freescheduletemplate.com/meeting-schedule-template/