teleren/devto huggingface dataset:
Error when converting PDF to image on Github Actions
Tags: github, actions, rails, imagemagick
Published: 2020-10-15 13:19:44

```bash
Error:
Documents::UploadJobTest#test_#perform_creates_an_activity_for_document:
MiniMagick::Error: `convert /tmp/shrine20201009-22018-5itpj9.pdf[0] -auto-orient /tmp/image_processing20201009-22018-1uk39lv.png` failed with error:
convert-im6.q16: not authorized `/tmp/shrine20201009-22018-5itpj9.pdf' @ error/constitute.c/ReadImage/412.
convert-im6.q16: no images defined `/tmp/image_processing20201009-22018-1uk39lv.png' @ error/convert.c/ConvertImageCommand/3258.

    app/uploaders/document_uploader.rb:13:in `block in <class:DocumentUploader>'
    test/jobs/documents/documents_upload_job_test.rb:8:in `block in <class:UploadJobTest>'
```

In my Ruby on Rails application, this error is raised when using [MiniMagick](https://github.com/minimagick/minimagick) to convert a **PDF** into an image.
MiniMagick uses [ImageMagick](https://imagemagick.org) which uses [Ghostscript](https://imagemagick.org) for anything related to postscript files - for example PDFs.

Due to a [security vulnerability in Ghostscript < 9.24](https://www.kb.cert.org/vuls/id/332928/), ImageMagick changed the default policy to not allow conversions using Ghostscript.
Even if Ghostscript has fixed the vulnerability, the ImageMagick policy has not been changed.

In my application I use MiniMagick via a gem called [Shrine](https://shrinerb.com) where a **PDF** is processed to get a thumbnail. To read more about this, please visit the [Shrine documentation](https://shrinerb.com/docs/processing).

On Github Actions the default linux image is [Ubuntu 18.04 (20.04 in preview)](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on).
Ubuntu 18.04 should have an updated version of Ghostscript, but still has a policy for ImageMagick that disallows conversion from **PDF** to an image.

# Solution

My solution was inspired by this [StackOverflow answer](https://stackoverflow.com/a/61721903/4762756).
It can be added to a Github Action like this:

```yaml
# ---
jobs:
  job01:
    runs-on: ubuntu-latest # ubuntu-18.04
    steps:
      - name: Change ImageMagick policy to allow pdf->png conversion.
        run: |
          sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
      - <more steps>
```

# Mac OS

If you experience this error on Mac OS it can be helpful to reinstall ImageMagick and Ghostscript:

```bash
brew uninstall ghostscript imagemagick
brew install ghostscript imagemagick

gs --version # make sure it is > 9.24 (9.53.3 on my machine currently.)
magick --version # make sure the row `Delegates` includes `gslib`
```
Creating copy button with JS
Tags: javascript, copy, html
Published: 2020-10-15 13:11:22

[[Clique aqui para ler em português]](https://medium.com/walternascimentobarroso-pt/criando-bot%C3%A3o-de-copiar-com-js-319e6df18bc0)

It is quite common that we need to copy something on the screen, either to search later or just to save somewhere, and with that, we will create a quick function to copy text with JavaScript.

## Code

First we will create the interface, we will do something simple, using only HTML.

```html
<input id="input" type="text" />
<button id="execCopy"> execCopy </button>
<button id="clipboardCopy"> clipboardCopy </button>
```

In the HTML structure, an `input` was created that will be the text to be copied, and we have two buttons, which will be used to demonstrate two ways to copy text with JavaScript.

```javascript
// Type 1
document.getElementById('execCopy').addEventListener('click', execCopy);
function execCopy() {
  document.querySelector("#input").select();
  document.execCommand("copy");
}

// Type 2
document.getElementById('clipboardCopy').addEventListener('click', clipboardCopy);
async function clipboardCopy() {
  let text = document.querySelector("#input").value;
  await navigator.clipboard.writeText(text);
}
```

In the first type we add an event to the button with id `execCopy` that calls a function of the same name, in this function we first select the text, and then we use the `execCommand("copy");` function; this is a native function that executes the copy command.

In the second type we add an event to the button with id `clipboardCopy` that calls a function of the same name, in this function we first retrieve the input value and then we move to the `clipboard` function, a detail in this function is that to work correctly it is necessary to use `async` and `await`, or use `then()`, as it is a promise.

ready as simple as that.

## Demo

See the complete project working below.

{% codepen https://codepen.io/WalterNascimento/pen/ZEWNOMM %}

## Youtube

If you prefer to watch, I see the development on youtube (video in PT-BR).

{% youtube Ar1G5EIXeUA %}

***

## Thanks for reading!

If you have any questions, complaints or tips, you can leave them here in the comments. I will be happy to answer!

😊😊 See you! 😊😊
Hactober Fest 2020
Tags: hacktoberfest
Published: 2020-10-15 13:10:34

I am glad to share that I have successfully completed #hactoberfest 2020 challenge!
Though searching projects for PRs was challenging but with each contribution I made, it honestly felt really rewarding to be giving something back to the projects in question. Not only did I feel the accomplishment of having put in the time to put the change together, but I had the satisfaction of knowing that this could benefit many many more people than just myself.
Most importantly, I realised that contributing to open-source projects really doesn’t have to be as scary as it might seem. The maintainers that I interacted with were friendly and helpful.
NodeJS Vs AngularJS
Tags: node, angular, javascript
Published: 2020-10-15 13:10:18


In the following paragraphs, we are going to study the difference between Angular JS and Node JS in comprehensive detail:
Core Architecture

AngularJS has been treated by Google as a web app development framework. Angular has been written totally in JavaScript as compared to other JavaScript frameworks. The JavaScript syntax regulations are even followed by it. On the other side, NodeJS was built based on Google’s V8 JavaScript engine as a cross-platform runtime framework. It has been written in various programming languages including JavaScript, C, as well as C++.

Web Framework

As compared to NodeJS, AngularJS happens to be a web framework. The web framework can be used by the developers for automating common development jobs while creating different types of applications — web applications, websites, web services, plus web app framework. NodeJS cannot be used by the JavaScript programmers in the form of a web framework. However, they will be able to select from a vast range of frameworks which are NodeJS-based including Meteor.js, Socket.io, Express.js, Hapi.js, as well as Sails.js.

Installation

Node JS development services will be able to use JavaScript for writing NodeJS applications. However, it is important to run the applications inside the runtime environment on different platforms including Linux, Windows, plus macOS. As a result, NodeJS has to be installed by the developers of a Node JS development company on their computers while developing the development environment. Conversely, there is no need for the developers to install AngularJS on their computers. The AngularJS files can be embedded by them in the codebase similar to other JavaScript files.

Essential Features

MVC architectural pattern is supported by NodeJS as well as AngularJS. However, both of these JavaScript-based technologies come with different features. AngularJS allows programmers to make use of HTML in the form of a template language. Developers are also allowed by it to express different components of a web app by extending the syntax in HTML. Moreover, AngularJS helps to streamline the development of dynamic and single-page web apps by offering features such as scope, data binding, deep linking, directives, templates, filters, routing, as well as dependency injection.

Alternatively, being a server-side framework, NodeJS offers a collection of innovative features which are needed by the developers for building server-side and networking apps. The features offered by NodeJS will help the developers to simplify the creation of video streaming sites, single-page websites, as well as related I/O intensive web apps. Moreover, programmers can use NodeJS for using asynchronous APIs while significantly enhancing the speed of code execution. NodeJS can also be used by the developers for making the web apps offer information in chunks without any buffering.

Learn more here:https://medium.com/dev-genius/difference-between-nodejs-vs-angularjs-c2ec1a029934
Share some blazing fast and lightweight websites
Tags: discuss, webdev
Published: 2020-10-15 12:59:04

Hi 👋

I like ultra fast websites, built using vanilla technologies.

But I don't know a lot of those websites. Help me discover more of the "[small web](https://ar.al/2020/08/07/what-is-the-small-web/)" by sharing small & fast websites here, please :)
We built a low-code platform in 6 months!
Tags: showdev, saas
Published: 2020-10-15 12:54:49

I'd like to introduce you to [Canonic](https://canonic.dev). 

We started working on it full time about 6 months ago and it gives me great joy to share it with you all!

{% youtube ipR_489Awc8 %}

[Canonic](https://canonic.dev) is a low-code platform that helps you build APIs within minutes and **without writing a single line of code.**

People usually resort to creating APIs manually or hiring dev shops or agencies like the agency I'd started a couple of years back to create them. This is usually a process that lasts anywhere from a few weeks to months. Not only does it take really long to develop, but it also comes with its own set of challenges such as security, scalability, CI/CD, and tech debt.
<br/>
### APIs that would take an average of 4 weeks for an engineer to build, can be built on [Canonic](https://canonic.dev) in a few minutes.
<br/>
Our platform lets them get off the ground with no code. Just define the content model and hit deploy. All basic CRUD APIs are ready to be integrated and used. The Documentation and the CMS are also generated automatically.

As the application grows, the [Canonic's](https://canonic.dev) API graph can be used to add custom APIs, integrate webhooks, and more to build workflows.

<br/>

```
Example workflow: 
user registers -> 
send email to the new user using Mailgun -> 
add a user to a Mailchimp mailing list -> 
Notify administrator on Slack.
```
<br/>
From what started as a simple nodeJS project, [Canonic's](https://canonic.dev) architecture has grown tremendously, we now use everything from **Serverless Lambdas to Grafana for monitoring**.

<br/>
> Quick note: [Grafana](https://grafana.com/) + [Prometheus](https://prometheus.io/) is truly something to behold, once you add [Loki](https://grafana.com/oss/loki/), it's limitless. I'll definitely be writing a post about that soon!

<br/>
####  We are now live on [ProductHunt](https://www.producthunt.com/posts/canonic) 🚀, if you like what you read here, please show us some 🔥 & ❤️

Cheers!
Pratham, and Team Canonic ⚛️
New to this lovely community!
Tags: hacktoberfest, 2020, digitalocean
Published: 2020-10-15 12:50:16

Hi everyone, my name is Shashank and I don't have much to tell about me but the most importantly I am a "developer". I would like to acknowledge Hacktoberfest 2020 for making me a part of this community and I hope that I will learn much from here.
Thank You!
YouTube (Hindi) - https://www.youtube.com/channel/UCwXln15OdezXd_ktDAbP0MA?view_as=subscriber
Create File in bash Terminal
Tags: linux, aws, bash, codequality
Published: 2020-10-15 12:43:46

Knowing Linux is a widely used server-side operating-system  96.3% of the world’s top 1 million servers run only on  Linux. Only 1.9% use Windows servers and 1.8% – FreeBSD servers. Why people love Linux?  Linux is open-source And free Today Our top is How to create a new directory and file is an important skill for anyone using Linux. We can Create Files in bash either from the command line or from the Linux file manager.

Depending on what you want the file to contain:
touch /path/to/file for an empty file
somecommand > /path/to/file for a file containing the output of some command.
  eg: grep --help > randomtext.txt
      echo "This is some text" > randomtext.txt
nano /path/to/file or vi /path/to/file (or any other editor emacs,gedit etc)
It either opens the existing one for editing or creates & opens the empty file to enter, if it doesn't exist
Completed Hacktoberfest 2020 ! OpenSource The-Real-GameChanger
Tags: hacktoberfest
Published: 2020-10-15 12:38:16

## What I Learned From Hacktoberfest

Hacktoberfest is really an amazing opportunity to make your contribution worth. Developers Must Participate in this Hacktoberfest Challange and mark their existence in opensource.I was Very Excited this year for the challenge and wish to contribute in future seasons as well.
Bug, Error, Defect, Failure Explained
Tags: beginners
Published: 2020-10-15 12:36:06

Often, terms like error, bug, defect, failure are used interchangeably. But each one has its own meaning. In this post, I will explain the differences.

# TD;DR

The following quote explains in a nutshell what you need to know about the differences between error, bug, defect, failure.

> A coding mistake is called an **error**. The error found by the tester is called a **defect**. A defect accepted by the development team is called **bug**. If the software does not meet the requirements, then it is **failure**.

# Error

An error happens during coding. This can be a range of things:

- Syntax error (wrongly using the programming syntax)
- Compiling error (the syntax is fine, but there is another problem during compilation, for example, the wrong use of a variable)
- Runtime error (the program crashes when it is running)

In short, something that breaks the code. This always happens at the **development side**, so this is something the programmer/developer detects.

# Defect

When a tester detects that the program does not behave the way it is supposed to, that is a **defect**.

A defect could be caused by an underlying _error_ (but not necessarily). For example, this would happen if a JavaScript error is thrown due to a DOM element not being yet available, but the code is trying to access it. This would result in the rest of the code not running, ergo: Resulting in unexpected behavior.

However, the code could run error-free, but there still could be mistakes in the logic of the code. For example, updating a value in the database and forgetting to save that change. This would not cause an error; however, it would be a _defect_ because the program doesn't behave as it is supposed to.

Defects are usually detected by testers.

# Bug

When a _defect_, detected by a tester, is sent to the developer and they find that indeed it is due to a programming mistake, it is **accepted as a bug**.

The developer looks for the cause of the bug (debugging) and once the culprit is found, the bug is being _fixed_.

> Fun fact: It is called _bug_, because in the early days of computing when electromechanical relays were used, and an actual _bug_ (e.g., a moth) is trapped in a relay, causing the program to malfunction.

# Failure

A failure is when the program can't work the way it was intended to, but not due to a programming mistake.

For example, this could be faulty software requirements (not specifying that something needs to be implemented) or other reasons, such as network problems not caused by the software. (Although the software should catch those programs and show the user an error).

# Summary

Well, there you have it - the differences between an error, a defect, a bug, and a failure. So if next time there is a problem with the program, you can use the correct term, so everyone knows the _nuance_ of the problem at hand.
My hacktoberfest :
Tags: hacktoberfest
Published: 2020-10-15 12:29:41

# Hi guys here i am with my hacktoberfest experience.
## What I Learned From Hacktoberfest 
From hacktoberfest I've learnt many things. Now I know very well how to contribute in open source projects and how to use github. This was a very nice experience very good initiative by @digitalocean for open source projects.
I loved it and I'll participate very year and I want you all to also participate in this contest.


## My tips for you :
1)please try to support open source which are not much popular because I have seen that all the big and popular projects gets most of the PRs .

2)This is one of the main things guys :
NEVER GIVE UP!! Keep going no matter what there will be some PRs of yours which may be listed as spam , cancelled or rejected but keep trying.

3)try to contribute in around 3 projects everyday till 10-15th of October , So your winning chances are higher.more repos = more chances to win , simple logic 😅
Which I kept in mind.

4)And yes guys please do respect the projects rules for PRs otherwise the may list your PR as spam.
And please never ever do SPAM. It's very wrong because the person or team which owns the project has given their or his/her efforts .
So say no to SPAM!!!

5)Guys please do this on your own never ever copy anyone and as per me don't try to do small changes like correcting spelling mistakes or like that. It's ok if your a begginer but try to avoid it.


# So guys this was my hacktoberfest experience it's very interesting and helpful for open source projects .

## And I am greatfull for winning the competition.

# Bye guys keep supporting me!!.
Our documentation site is using Webpack 5 already
Tags: webpack, javascript
Published: 2020-10-15 12:27:05

A couple of days ago, Webpack 5 was released. Webpack is such a great tool that we decided to upgrade it on [our documentation site](https://documentation.platformos.com) with the hope of finding and fixing some bugs to give back to its incredible community. 
We did not find any bugs, but upgrading Webpack is (and always was) a great pleasure. Excellent documentation, migration guide, changelog, support on GitHub. 

### Issues

We encountered only two issues during the migration:

1. Production build time is slower. About two times slower. That is not a big deal, as it will probably improve with time, and incremental builds are much faster because of the persistent cache — no big deal.
2. Docsearch (search script provided by Algolia) was not working because of the missing `process` object. [The is described](https://webpack.js.org/migrate/5/#run-a-single-build-and-follow-advises) in Webpack 5 migration  (but you need to read it to know that), so a couple of lines of polyfill fixed that.

```js
  new webpack.DefinePlugin({
    'process.env': {
      NODE_ENV: JSON.stringify(process.env.NODE_ENV),
    },
  })
```

Credits: https://github.com/algolia/docsearch/issues/980#issuecomment-708388893

### Deprecations, warnings

Webpack warnings and errors communicated everything else, so all the config updates were pretty easy and pointed us in the right direction when it came to cleaning it up a bit. We found two loaders and one configuration option that were not used.

### Build summary 
 
I hope that the build summary will visually improve because it was much easier to scan it in version 4.

Before:
![Before](https://dev-to-uploads.s3.amazonaws.com/i/exlkv4ps5qrn8p3igw5n.jpg)

After:
![After](https://dev-to-uploads.s3.amazonaws.com/i/1x7gylb9ofuq8ebj9hi0.jpg)

**Update**: Colors are back as of 5.1.3 :)

![5.1.3](https://dev-to-uploads.s3.amazonaws.com/i/xkne5c3ozp8hgsoepuqf.png)

---

Hopefully, your migration will go as smoothly as ours, and your builds will be smaller. :)

## Read more

If you are interested in more performance oriented content, follow me and I promise to deliver original, or at least effective methods of improving your website. 

{% link https://dev.to/platformos/using-webp-in-your-existing-webpage-809 %}

{% link https://dev.to/platformos/optimizing-images-for-the-web-18gc %}

{% link https://dev.to/platformos/3-tips-on-preserving-website-speed-5g0c %}
Hacktoberfest 2020 challenge completed!
Tags: hacktoberfest, hacktoberfest2020, digitalocean
Published: 2020-10-15 12:25:30

It was my second year participating in Hacktoberfest.
This time not only did I contribute but also created my own repository which is/was open for Hacktoberfest 2020 contributions.
It was a learning experience!
_Thankyou @vaibhavkhulbe, for guiding me as always :")_

![YAY :D](https://dev-to-uploads.s3.amazonaws.com/i/13wi29786t5y6jjxq2uf.jpg)
![My Contibutions](https://dev-to-uploads.s3.amazonaws.com/i/dcq9auvjyg1gsqedr515.jpg)
Formatting dates in the user's locale using DateFormatter in Swift
Tags: swift, ios
Published: 2020-10-15 12:20:29

Working with dates is hard, there is no doubt about that. And formatting dates properly for every user of your app is no easier (if you want to do everything manually). Luckily, the system can help us.

For example, in the US one would write **"October 15"** while in The Netherlands we write **15 oktober**.

Note that the order of the date and the month is different, the spelling of the month is different and the capitalization is different too.

The DateFormatter in iOS will handle a lot of this for you. For example, if you'd use the following code on a device that uses `nl` as its locale you would see the output that I added to this snippet as a comment:

```swift
let now = Date()
let formatter = DateFormatter()
formatter.dateFormat = "dd MMMM"
formatter.string(from: now) // 15 oktober
```

The output of this code is spot on. Exactly what we need and it matches the specified date format perfectly. If you'd run the same code on a device that uses `en_us` as its locale the output would be **15 October**.

The date formatter got the spelling and capitalization right but the date and month are in the wrong order.

You can fix this by using `setLocalizedDateFormatFromTemplate` on your date formatter instead of assigning its `dateFormat` directly. Let's look at an example that runs on a device with `nl` as its locale again:

```swift
let now = Date()
let formatter = DateFormatter()
formatter.setLocalizedDateFormatFromTemplate("dd MMMM")
formatter.string(from: now) // 15 oktober
```

That still works, perfect. If you'd run this code on an `en_us` device the output would be **October 15**. Exactly what we need.

If you want to play around with `setLocalizedDateFormatFromTemplate` in a Playground you can give it a go with the following code that uses a date formatter in different locales:

```swift
import Foundation

let now = Date()
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_us")
formatter.setLocalizedDateFormatFromTemplate("dd MMMM")
formatter.string(from: now) // October 15

formatter.locale = Locale(identifier: "nl")
formatter.setLocalizedDateFormatFromTemplate("dd MMMM")
formatter.string(from: now) // 15 oktober
```

If you have questions about this Quick Tip, or if you want to reach out to me for other reasons then don't hesitate to send me a message on [Twitter](https://twitter.com/donnywals).

It's a good thing that Swift and Foundation can handle these kinds of
MY HACKTOBERFEST EXPERIENCE
Tags: hacktoberfest
Published: 2020-10-15 12:17:07

This was my first ever Hacktoberfest participation, I heard it from a youtube channel called "Code with Harry", where he explained about this Fest and how to participate and the rules of this Fest, so I thought to try my best and started contributing in the open-source projects especially in Python. People can work on any project and in any language. Remember that it is not about any fest, it is all about contributing to the open-source community and Hacktoberfest is a great place because it not only recognizes your effort but also rewards you for it. Especially the swags given by this platform motivates people to contribute to the Open-Source projects. Hats OFF to the community that is conducting these types of Fest and focusing on the Open Source Development.