teleren/devto huggingface dataset:
Convert PDF to PDF/A with a free Java API
Tags: java, pdfa, free, api
Published: 2021-04-14 05:52:57

PDF/A is a kind of PDF format designed for archiving and long-term preservation of electronic documents. Unlike paper documents that are easily damaged or smeared, PDF/A format ensures that documents can be reproduced in exactly the same way even after long-term storage. This article will demonstrate how to convert PDF to PDF/A-1A, 2A, 3A, 1B, 2B and 3B compliant PDF using Free Spire.PDF for Java.

**Import jar dependency** (2 Methods)
● Download the [Free Spire.PDF for Java](https://www.e-iceblue.com/Download/pdf-for-java-free.html) and unzip it.Then add the Spire.Pdf.jar file to your project as dependency.

● Directly add the jar dependency to maven project by adding the following configurations to the pom.xml.
```xml
<repositories>
        <repository>
            <id>com.e-iceblue</id>
            <name>e-iceblue</name>
            <url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>
        </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>e-iceblue</groupId>
        <artifactId>spire.pdf.free</artifactId>
        <version>4.3.0</version>
    </dependency>
</dependencies>
```

**Code Snippet**
```java
import com.spire.pdf.conversion.PdfStandardsConverter;

public class ConvertPdfToPdfA {
    public static void main(String[] args) {

        //Specify input file path
        String inputFile = "C:/Users/Administrator/Desktop/sample.pdf";

        //Specify output folder
        String outputFolder = "C:/Users/Administrator/Desktop/Output/";

        //Create a PdfStandardsConverter instance, passing in the input file as a parameter
        PdfStandardsConverter converter = new PdfStandardsConverter(inputFile);

        //Convert to PdfA1A
        converter.toPdfA1A(outputFolder + "ToPdfA1A.pdf");

        //Convert to PdfA1B
        converter.toPdfA1B(outputFolder + "ToPdfA1B.pdf");

        //Convert to PdfA2A
        converter.toPdfA2A(outputFolder + "ToPdfA2A.pdf");

        //Convert to PdfA2B
        converter.toPdfA2B(outputFolder + "ToPdfA2B.pdf");

        //Convert to PdfA3A
        converter.toPdfA3A(outputFolder + "ToPdfA3A.pdf");

        //Convert to PdfA3B
        converter.toPdfA3B(outputFolder + "ToPdfA3B.pdf");
    }
}
```

**Output**
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pbe7j1rb1pz7m2qurnnj.jpg)
45 Udacity FREE Courses on Machine Learning and Data Science
Tags: machinelearning, deeplearning, datascience, analytics
Published: 2021-04-14 06:55:05

**Udacity** is one of the most popular **MOOC-based e-learning platforms** in the world. Udacity has a wide range of machine learning and data science courses. Some are free and some are paid. But in this article, I am gonna discuss all the **Udacity FREE Courses on Machine Learning and Data Science.**

For these courses, **You don’t need to pay a single buck**. So give your few minutes to this article and check out the Udacity FREE Courses on Machine Learning and Data Science for you.

Now without any further ado, let’s get started-

Udacity FREE Courses on Machine Learning and Data Science
For your convenience, I have created a table from where you can filter out the course according to your **skill level, topics you want to learn, and the duration of the course.**

So let’s start with the Udacity FREE Courses on machine learning-

##**Udacity FREE Courses on Machine Learning-**
**[Click to continue reading...](https://www.mltut.com/udacity-free-courses-on-machine-learning/)**
I18n in StimulusReflex
Tags: rails, ruby, stimulusreflex, i18n
Published: 2021-04-14 06:45:00

How do you use I18n in your Reflexes?

There is an official approach in the [Documentation of StimulusReflex](https://docs.stimulusreflex.com/rtfm/patterns#internationalization) to do that.

However, here's another one:

```ruby
# ./app/reflexes/application_reflex.rb
class ApplicationReflex < StimulusReflex::Reflex
  around_reflex :switch_locale

  private

  def switch_locale(&action)
    # replace `session[:locale]` with your custom logic
    locale = session[:locale] || I18n.default_locale
    I18n.with_locale(locale, &action)
  end
end
```

Yes, it is basically the same thing as Rails suggests for [Managing the Locale across Requests](https://guides.rubyonrails.org/i18n.html#managing-the-locale-across-requests).

This way I like that all reflexes have the locale set **by default**, and I do not have to care about it anymore when adding new reflexes.

What's your experience/opinion regarding I18n in StimulusReflex?

(Cover image by [Nareeta Martin on unsplash](https://unsplash.com/@splashabout?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText))
Astro: Meta framework of future web development
Tags: astro, snowpack, javascript, react
Published: 2021-04-14 06:43:06

I wasn’t hyped that much for a long time. But in my opinion, something big is coming. Folks behind [Snowpack](https://www.snowpack.dev/) and [Skypack](https://www.skypack.dev/) presented a little sneak peek of what they are currently working on.

You can see the full video here: [https://www.pscp.tv/w/1nAJELQkljlGL](https://www.pscp.tv/w/1nAJELQkljlGL "https://www.pscp.tv/w/1nAJELQkljlGL")

## What is Astro?

Yet, another framework for building sites. But this one is different. The first thing, Astro using opt-in hydration. So when you want to use javascript on your site you need to explicitly set that you are using it. It’s not like Vite, SvelteKit, or Next.js. It’s more like [Eleventy](https://www.11ty.dev/) with first-class support for using your client-side code.

### How does this work?

Astro compiles and treats your files as regular HTML. When you are using client-side libraries like React, Vue, or Svelte then those parts of the app you are using client-side code treat like, independent application and is pushing its code.

You have two types of serving client-side code to users:

* **Idle** — serving code when the page is requested. It’s great for whole apps that have parts of the webpage statically generated.
* **Visible** _—_ import code when the user enters a place where this code is needed. It’s great when you add a small component and don’t want to lose all benefits from static generation performance.

### ![](https://cdn-images-1.medium.com/max/1600/1*GpzjSPpZhB4vMbIzN7n1cw.gif)

### Why is this so needed?

Most of the technologies have it’s own tools. Gatsby, Next.js, Nuxt, Gridsome, Eleventy, SvelteKit. All of them are fantastic and have some unique great features, but you are closed to use only one of them. They are not focused on their own environment and library. It’s good for them, but not for developers. When you are building a site you want to build it fast, without friction, and the best performance.  
Also, all of those frameworks need proper setup. With Astro, you can go to [Bit](https://bit.dev/) pick a component, add to your site without hassle, and not sacrifice performance!

### Other features

* **Transforming extended markdown files into pages** — like in eleventy, we can drop in a markdown file, add layout property and build a page on that. Except for this, we can use your components in that files, similar to [MDX](https://mdxjs.com/).
* **Files based routing** — everything that is in the `/pages` directory will be transformed to page.
* **Templating system** — we can split code into templates and reuse them.

## Summary

I think it will be a game-changer in building websites. Especially those without much client-side javascript. In such a setup, performance will be high by default, with templating system and MDX-like features maintaining a codebase will be easy enough for everyone, even for those without knowledge about client-side libraries.

_On_ [_Astro discord_](https://discord.gg/ynyH4BVp)_, you can get invited to the Astro repository and have, a chance to check yourself how Astro._
Day 31 of 100 Days of SwiftUI
Tags: swift
Published: 2021-04-14 06:35:42

I just completed day 31 of 100 Days of SwiftUI. Today I worked on finished working on the Word Scramble app. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/83vh2diiyp3u9m1adi08.png)

Here's a link to the app on (github)[https://github.com/sanmiAde/WordScramble]
Hacking time management
Tags: management, devlive
Published: 2021-04-14 06:29:25

People keep asking me the same question, how do you manage to write every single day?

But I see these kinds of questions pop everywhere, whether it is a YouTuber doing videos quite often or people pushing out e-books at an enormous pace.

I can't speak for these people, but I can tell you how to approach this time hack.

## Why do you want to hack time?

Hacking time is an excellent way to get more or different things done.
You as a person can't change the fact that there are 24 hours in a day.

You want to be able to do as much as possible in the little time you got.

And yes, this can be a variety of things:

- I want to play more games
- I want to exercise more
- I want to help a Nobel cause
- I want to publish more articles
- I want to learn more about this or that topic

As you can see, there are many things we as humans want to achieve, and there is a way to get more done than you are doing now!

## Hack your time wisely

When it comes to hacking time, you might think of the obvious one.
Cut down on your sleep, and you will have more time for other stuff.
But this is far from true, at least for me.

I used to be a person that only had about 5 hours of sleep each night, and the moment I changed this to be 8+ hours, I actually became more productive.

But that is not nescesarry the hack I'm talking about today.

This hack involves assessing your time at the moment.
And you can do this very low-leveled.

After every activity, you do ask yourself did it contribute to your happiness, did it enrich you?

Some examples:

- You spend 6 hours watching a show you didn't even enjoy
- You had to visit that aunt you don't even like
- You traveled 2 hours to a job you don't enjoy
- You went shopping for 4 hours and hated it

Simple things like that, can you cut the down?

For me, the main dominator was travel time and watching shows.
Of course, you still want and need to relax, so please don't fully give up on fun things. But cut them out to do something you want to.

## I don't have time that I want to give up?

Well that is unfortunate, are you sure you can't make your time more efficient?

Can you combine specific tasks?
Watching a show while doing your laundry, or watching it while being on a home trainer, for instance.

Can you do some meetings while driving to work?

But all and all, it's about being happy with your day.
Meaning if you find your day fulfilling and you did enough, it's a good day!

I hope you can cut down on some time and make your life even better!

### Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on [Facebook](https://www.facebook.com/DailyDevTipsBlog) or [Twitter](https://twitter.com/DailyDevTips1)
Annoying TypeScript discriminating union gotcha
Tags: typescript
Published: 2021-04-14 06:28:28

Can you spot what's wrong with this code?

![Discriminating union gone wrong](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s7vnfvzljv6bz8y1tc7z.png)

https://www.typescriptlang.org/play?ts=4.2.3#code/C4TwDgpgBACgTgezAZygXigbwFBT1AS2QEE44BDEALigDNyAbZCAGl31oDsaAKAN0YBXCDWTA4BTgHMAlOgB8UPggIATbAF8oAHyzs8RUhWpRxwtvjrco-ISKhiJ0gNoBdOWkXK1m7NgDGCJxiUADCCAC2YEEQnMDoNpiGZJQsVho08EjIHoo4loHB8f6MDABG5P4A1gk8uXqWlgS0NsnGcvmNXVw8zgDk5MiqtKp97vqNWhBM0J1dlj19AIwATADMfTITlhoTuxpAA
Testing with Mocha – 3. Testing asynchronous code
Tags: testingwithmocha, bdd, javascript, mocha
Published: 2021-04-14 13:04:20

---
title: Testing with Mocha – 3. Testing asynchronous code
published: true
date: 2021-04-14 06:23:02 UTC
tags: TestingwithMocha,bdd,JavaScript,Mocha
canonical_url: https://www.danielwerner.dev/testing-with-mocha-3-testing-asynchronous-code
---

In JavaScript we often write asynchronous code, for example ajax calls, database operations etc. When testing our code we want to be able to test this asynchronous parts of our code as well. Let’s see how we can achieve this when testing with Mocha.

## Asynchronous code with callbacks

For testing async code which uses callbacks we can use Mocha’s `done` function. When passing `done` in the test Mocha knows that it should wait for that callback to be called. Let’s see and example. Let’s add a save method to our collection, which will operate asynchronously.

See the Pen [Testing with Mocha – Example 3.1](https://codepen.io/daniel-werner-the-decoder/pen/YzNaMNo) by Daniel Werner ([@daniel-werner-the-decoder](https://codepen.io/daniel-werner-the-decoder)) on [CodePen](https://codepen.io).

<script async="" src="https://cpwebassets.codepen.io/assets/embed/ei.js"></script>
## Asynchronous code with Promises

If our code use promises instead of callback we can use doesNotReject assertion. Note: when testing promises  **do not**  use the `done` callback. Let’s see and example how to test promises. We’ll “reimplement” the save method of our collection to use promises.

**Important:**  When asserting promises, you should  **return**  the result of the assertion for Mocha to pick them up. Otherwise you’d in case when test should not pass, it passes, but you’d get an error.

See the Pen [bGgvJYg](https://codepen.io/daniel-werner-the-decoder/pen/bGgvJYg) by Daniel Werner ([@daniel-werner-the-decoder](https://codepen.io/daniel-werner-the-decoder)) on [CodePen](https://codepen.io).

<script async="" src="https://cpwebassets.codepen.io/assets/embed/ei.js"></script>
## Asynchronous code with async/await

If our code uses async/await, we can test it easily with Mocha. Let’s rewrite the previous example from using promises to use async/await.

See the Pen [QWdmXBb](https://codepen.io/daniel-werner-the-decoder/pen/QWdmXBb) by Daniel Werner ([@daniel-werner-the-decoder](https://codepen.io/daniel-werner-the-decoder)) on [CodePen](https://codepen.io).

<script async="" src="https://cpwebassets.codepen.io/assets/embed/ei.js"></script>

As you can notice, we’ve added the **async** keyword to the save method, and when calling the method we use the await to wait for the asynchronous call result.

```

let result = await collection.save();

```

* * *

_Check out all posts in the series_ **[Testing with Mocha](https://www.danielwerner.dev/category/testing-with-mocha/)**_._

The post [Testing with Mocha – 3. Testing asynchronous code](https://www.danielwerner.dev/testing-with-mocha-3-testing-asynchronous-code/) appeared first on [Daniel Werner](https://www.danielwerner.dev).
5 Best Football Apps for Android and iOS
Published: 2021-04-14 06:21:10

<p>Football season is upon us again, and whether you run your own fantasy league (and you should), watch the games on TV, or simply just love the sport, you know that the best way to keep up with the latest trends in the world of football is with apps.</p>
<p>Football is more than just the <a href="https://prosoccerstore.co/product/nike-mercurial-vapor-13-elite-fg-new-lights-blue-hero-white/">Nike mercurial vapor 13 elite new lights</a> as opposed to what the brand would like you to believe. You can just start by <a href="https://trendingnow.journoportfolio.com/articles/importance-of-having-a-great-pair-soccer-cleats/">selecting the best pairs of them</a> and enjoy the game. Quit keeping up with game progress throughout the season by checking the box scores. With the help of these five apps, you can do that on the fly.</p>
<h2>1. Stats Zone</h2>
<p>Stats Zone is for detailed statistics of everything in every game. If you are a football nerd then this app is the best for you.s</p>
<h2>2. Forza Football</h2>
<p>Forza Football is popularly loved by a lot of football fans worldwide. It is a one-stop for news, live updates, fixtures, stats, and more of over 400 leagues. It is one of a kind because it gives so much and that too for free in a very easy to use format. Polls and pre-match lineups are also a feature and the quality of news, updates and others is amazing.</p>
<h2>3. Feedly</h2>
<p>&nbsp; Using Feedly you can follow a whole bunch of everything football. From blogs, websites, youtube channels to every other media, you can build your very own library of football content with these. You select the news you want, this gives it the advantage of being highly personalized and customized.</p>
<h2>4. ESPN+</h2>
<p>ESPN is a free app however, ESPN+ is not. It costs $4.99 per month and is amazing for those who rigorously follow North American. It does not provide live coverage for NBA and NFL games. The best part is that it enables you to access Major League Baseball (MLB), Major League Soccer (MLS), and National Hockey League (NHL) games exclusively!</p>
<h2>5. Onefootball</h2>
<p>Onefootball is among the most popular football apps among fanatics. It is free to download, but it is loaded with lots of ads. Onefootball app also includes a social media platform. You can follow your favorite club or national team It is a great app for those who want to follow their favorite teams and players, and it also provides highlights from matches across the world. (Including the major leagues in the US and Europe). You can also check out various health tips like <a href="https://blog.storymirror.com/read/jpzjcebh/helpful-footcare-tips-for-soccer-players">foot care tips for soccer players</a> and tips to recover quickly from injury. However, it is more inclined towards the US football scene. It provides the users with news, fixtures, updates, schedules, and results.</p>
Best API Development Framework
Tags: discuss
Published: 2021-04-14 06:14:46

Gentlemen, I need some advice on the best Rest API development framework as per your experiences.

![Gentlemen - Let's Do it](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ngvhgi7ymt20ne7udnla.gif)

**Use case**: Intensive Querying for a real time Blood Donor-Seeker GPS based application

*PS: I need Power 💪.*

Please include following aspects in your response:
+ Scalability
+ Performance
+ Documentation
+ Developer Friendliness
+ *Add what you like...*
Hearts, Roam Research, Algorand and Microservices
Tags: blockchain, webdev, microservices, programming
Published: 2021-04-14 06:01:16

Greetings..

Every Monday Morning I publish my newsletter/Blog. Throughout the week I try to gather some useful links and post them in a specific format and I believe this would help my readers and the community.

Read about this week's newsletter by clicking this link or using the below URL:

https://gokhale.me/hearts-roam-research-algorand-and-microservices
Did you hear about DhiWise yet?
Tags: kotlin, mernstack, android, ios
Published: 2021-04-14 05:10:23

DhiWise is World’s 1st 100% developer-centric ProCode platform which helps you to develop MERN stack and Native mobile apps at lightning speed and on the go.

With DhiWise you can avail features like creating Schema Models, API routes, Cron jobs, import React Theme Designs, Form validation, State management, Manage Project Configurations, Design to Kotlin code, API calls, Integrate 3rd Party tools, and Business Logic Management. 

Here is the first glimpse of DhiWise: https://www.youtube.com/watch?v=t4gXLU2hWEk

DhiWise helps you do these essential tasks in minutes instead of hours and Apps are built in days, not weeks. With an enormous amount of time in your hands you can focus on Complex Business Logic, Performance, Security, and the things you love to do as a developer.

We empower startups, enterprises, and developers to expedite their development journey. Thousands of them have already registered!
What are you waiting for? 

Sign up for early access and you can be among our first users to get early access to our platform.
dhiwise.com/early-access
49 Days of Ruby: Day 18 - Parameters
Tags: ruby
Published: 2021-04-14 05:05:12

---
title: 49 Days of Ruby: Day 18 - Parameters
published: true
description: Join us on a 49 day learning journey through Ruby!
series: 49 Days of Ruby
tags: #ruby
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/9m73qaetuse3nm3y3it8.png
---

**Welcome to day 18 of the 49 Days of Ruby! 🎉**

Methods as we discussed yesterday are building blocks of your code. Parameters are the inputs for your methods!

This lesson today is going to be a quick one, as we're going to briefly expand upon yesterday and fill in an important detail about how to use parameters.

## Parameters in Ruby

Let's say I had the following method:

```ruby
def coffee
  puts "Here's your coffee!"
end
```

If I ran this method, the output would be `Here's your coffee!`. What if I also wanted to output the customer's name? I could create a method for each customer:

```ruby
def coffee_for_sarah
  puts "Here's your coffee, Sarah!"
end

def coffee_for_joe
  puts "Here's your coffee, Joe!"
end
```

That does not feel very scalable though. A method for each customer will quickly become impossible to manage.

There is a better way:

```ruby
def coffee(customer)
  puts "Here's your coffee, #{customer}"
end
```

Now, I can invoke it like the following:

```ruby
> coffee("Jill")

# => "Here's your coffee, Jill!"
```

We learned about string interpolation earlier on in this journey. It's where you combine a variable with a string to produce a new unified result.

In this case, we build our method of `#coffee` with a parameter of `customer`. We are basically instructing our method to expect a data input. We don't tell the method anything about what the data is, only that it should be there.

That's a parameter!

Try building parameters with methods on your own and share your learning!

**Come back tomorrow for the next installment of 49 Days of Ruby! You can join the conversation on Twitter with the hashtag [#49daysofruby](https://twitter.com/hashtag/49daysofruby).**
LeetCode 560. Subarray Sum Equals K
(javascript solution)
Tags: algorithms, javascript
Published: 2021-04-14 04:41:34

###Description:
Given an array of integers nums and an integer k, return the total number of continuous subarrays whose sum equals to k.

###Solution:
Time Complexity : O(n)
Space Complexity: O(n)

```javascript
var subarraySum = function(nums, k) {
    let count = 0, sum = 0;
    const map = new Map();
    // Add 0 to map as a sum that we have seen and 1 as its value which will be he amount of times we have seen this sum so far
    map.set(0, 1);
    for (let i = 0; i < nums.length; i++) {
        // Get the current sum
        sum += nums[i];
        // Increase the count if we have seen a sum that equals sum - k
        if (map.has(sum - k))
            count += map.get(sum - k);
        // Set a new value in the map or increase the amount of times this sum has been seen by 1
        map.set(sum, (map.get(sum) || 0) + 1);
    }
    return count;
};
```
Pie & AI lahore is coming back after a break with an exciting opportunity for students and AI practitioners.
Tags: ai, tenserflow, machinelearning, deeplearning
Published: 2021-04-14 04:08:27

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xcoghy14yyl1f95gaway.jpg)
Pie & AI lahore is coming back after a break with an exciting opportunity for students and AI practitioners. We will discuss AI learning path and Tensorflow certification by Google.
Speaker:
Ammar Mohanna
Tensorflow Aficionado, PhD in AI
Genoa, Liguria, Italy.
April 17, 2021
8:00 PM to 9:00 PM Pakistan Standard Time.

Registration link: https://www.eventbrite.com/.../pie-ai-lahore-ai-learning...