teleren/devto huggingface dataset:
Caddy 2 server the silver bullet of serving
Tags: backend, server, reverseproxy, caddy
Published: 2020-08-10 06:42:29

---
title: "Caddy 2 server the silver bullet of serving"
published: true
description: "Node.js is beautiful and brilliant. It takes a mature developer to admit where something shines and where it could use some help. With every language, or library the authors make some choices on where it should it shine and what can lag."
tags: ["backend", "server", "reverseproxy", "caddy"]
canonical_url: "https://gregbenner.life/caddy-2-server-the-silver-bullet-of-serving/"
//cover_image: https://direct_url_to_image.jpg
---

## Caddy 2 server the silver bullet of serving

_First and foremost this post is about a Go-lang server; wait it will be in a node.js context!_

Node.js is beautiful and brilliant. It takes a mature developer to admit where something shines and where it could use some help. With every language, or library the authors make some choices on where it should it shine and what can lag.

I won't drill down into the nitty gritty but where I think node can use a friend like Caddy are things like serving binary files, rate limiting access to the server, creating an HTTP/2 or /3 server. (node recently made HTTP/2 a first class citizen but you still need to setup a Let's encrypt certificate)

HTTP/2 really shines with serving static assets, in the past with HTTP/1 we used CDN's to maximize parallel requests and dns lookups. Nowadays you can create many requests with only one DNS lookup and all the assets over the same wire.

I've been using Caddy since the early v1 days, there are a few feature I miss that haven't landed in v2 yet; such as protecting routes with JWT via a plugin. Overall if you are creating a new project you should use V2.

Getting started!
You can download the binary [here](https://caddyserver.com/docs/download) or use the handy [DigitalOcean](https://digitalocean.com) [droplet](https://marketplace.digitalocean.com/apps/caddy)

For me a common use case of Caddy is as a static file server and a reverse proxy for my backend services. Here's what works for me as "Caddyfile" the yaml edition of the configuration file

```yaml
example.com {
encode gzip
header Cache-Control max-age=31536000
file_server {
root /var/www/html
}
log {
output file /var/log/access.log
}

}

api.example.com {
reverse_proxy 127.0.0.1:3000
}
```

And just like that you are likely to get 100 lighthouse score on google served over http/2.

[Here's](https://caddyserver.com/v2) more information about Caddy, hope this helps!

Comments and retweets welcome https://twitter.com/cactusanddove/status/1274861623094763531?s=20
Convert Flash to HTML5
Published: 2020-08-10 06:37:11

End of Flash by 2020 - Convert Flash to HTML5 eLearning
https://www.swiftelearningservices.com/flash-to-html5-conversion-services/
Did you aware that your FLASH based courses may not work after 2020?

Flash has been serving for long. But now the days are shifting and the phase of flash is coming to an end. By the end of 2020, Adobe will eventually stop support to Flash and all major browsers may not run FLASH content.

Make your training content future proof by converting them into html5. As there are many authoring tools available in the industry for effective HTML5 elearning courses.

Points to note:
- Check whether your elearning courses are developed in FLASH
- Check whether your source files are available or not
- Outsource your conversion to ensure a smoother process
- Make sure you upgrade all your browsers of learners after conversion
As it's nearing to the end of 2020, this is the right time to convert your Flash courses to HTML5 before it's too late.
Elm Tricks from Production–From Angular v1 to Elm in 4 Days
Tags: functional, elm
Published: 2020-08-10 06:16:00

You can keep reading here or [jump to my blog](https://odone.io/posts/2020-08-10-elm-tricks-from-production–from-angular-v1-to-elm-in-4-days.html) to get the full experience, including the wonderful pink, blue and white palette.

---


You might be wondering, how the hell did they manage to migrate the entire frontend of AirCasting from Angular to Elm in 4 days? The answer is simple: we cheated. But we swear this is totally legit and we encourage people to do the same!

In a [previous post](https://blog.lunarlogic.io/2019/elm-tricks-from-production-migration/) we explained why and how we choose not to rewrite the entire frontend from scratch:

> The best way to rewrite any application from one technology to another is incrementally, while it continues to run. At first the new language can take over separate parts of the application and then gradually incorporate more and more code.

In particular, over the last year, we have been using new features as an excuse to bring us closer to the finish line. In other words, we never stopped producing value for our customers. Also, having the removal of Angular in the back of our minds at all times, allowed us to come up with more and more tricks on how to make it happen. We actually kept a list on the wall in front of us to function as a constant reminder.

After several months of work, we realized we got close enough to remove Angular completely. That is when we took 4 days off the development of new features to [complete our mission](https://github.com/HabitatMap/AirCasting/pull/388).

We are pretty sure the cost of those 4 days was worth it. In fact, it will probably be repaid in the next iteration not needing to learn Angular v1 or having to deal with its complexity.

There is still a long way in front of us. As a matter of fact, we only removed Angular by extracting code to vanilla JavaScript and kept the Elm ports. But, for sure, the future looks brighter now!


---

Get the latest content via email from me personally. Reply with your thoughts. Let's learn from each other. Subscribe to my [PinkLetter](https://odone.io#newsletter)!
Next js vs Gatsby
Published: 2020-07-02 19:32:47

---
title: Next js vs Gatsby
description: Which one is a better fit for you?
canonical_url: https://padding-0.com/next-js-vs-gatsby/
---


Both Next js and Gatsby allow you to create static websites using React. There are three main differences to consider when choosing between them.

## SSR vs. SSG
SSR and SSG are different paradigms of website rendering. Let's define them first.

**SSR (Server-side rendering)** - the content of your page renders at the run-time. Every browser request triggers a portion of code on the server that generates a page. It gives more freedom for customization.

**SSG (Static-side generation)** - generates pages at build-time. Each browser request simply fetches a static, pre-built HTML page.  It provides the best performance.

[Here is an excellent in-depth comparison article.](https://frontarm.com/james-k-nelson/static-vs-server-rendering)

Initially, Next js was SSR only. Eventually, they added SSG support. Gatsby was always just SSG. In this regard, there are more options available with Next, while Gatsby may have a maturer approach to SSG.

## Data handling
Next js provides a [set of helper functions](https://nextjs.org/docs/basic-features/data-fetching) to handle data. You can use plain Node syntax to return any data from these functions asynchronously. With Gatsby, you must provide [GraphQL queries](https://www.gatsbyjs.org/docs/graphql/) to get the data.

Your attitude towards GraphQL may dictate your pick here.

## Philosophy
Next js approach is to give you as much freedom as possible. It only provides API to communicate with the framework. Besides that, you are on your own. You can use a plain Node environment to build whatever you want.

Gatsby relies on existing abstractions called plugins. If you want to add anything, you should check for a plugin first. The current library of Gatsby plugins is pretty extensive and various.

## Summary
If you need SSR or want better customization, use Next js. Looking for SSG that works out of the box? Gatsby is a better choice. Just make sure there are plugins out there for what you want to achieve. 
  
  
[Original article](https://padding-0.com/next-js-vs-gatsby/)
Floating Ghost 👻
Tags: html, css, beginners, tutorial
Published: 2020-08-10 06:08:54

Hello, coding people hope you are not in fear of this cute ghost 👻. In this Dev Post, we will learn how to make this floating ghost with only HTML and CSS. Here we don't need to know about any third language just 🏹 HTML and CSS.

😅Nothing much tricky we are just using Div under in HTML and much absolute CSS property that's it. So open my source codepen in this code to understand Ghost.

{% codepen https://codepen.io/atulcodex/pen/MWywJav %}
Basic Calculator - LeetCode Problem
Tags: leetcode, basiccalculator
Published: 2020-08-10 06:03:12

{% youtube d9VRxFnG-3U %}

## 問題

* https://leetcode.com/problems/basic-calculator-iii/

## コード

```cpp
class Solution {
 public:
  int calculate(string s) {
    long l1 = 0, o1 = 1;  // level one: +, -
    long l2 = 1, o2 = 1;  // level two: *, /
    bool s2 = false;      // weather l2 is set or not
    const int n = s.size();
    for (int i = 0; i < s.size(); i++) {
      auto c = s[i];
      if (isdigit(c)) {  // parse digits
        int last = i + 1;
        for (; last < n; last++) {
          if (!isdigit(s[last])) {
            break;
          }
        }
        long num = stol(s.substr(i, last - i));
        s2 = true;
        i = last - 1;
        l2 = (o2 == 1 ? l2 * num : l2 / num);
      } else if (isalpha(c)) {
        // TODO: parse variable
      } else if (c == '(') {
        int last = i + 1;
        int count = 1;  // parenthesis count
        for (; last < n; last++) {
          if (s[last] == '(') {
            count++;
          } else if (s[last] == ')') {
            count--;
          }
          if (count == 0) {
            break;
          }
        }
        string subExpr = s.substr(i + 1, last - i + 1 - 2);
        int num = calculate(subExpr);
        i = last;
        s2 = true;
        l2 = (o2 == 1 ? l2 * num : l2 / num);
      } else if (c == '*' || c == '/') {
        o2 = (c == '*' ? 1 : -1);
      } else if (c == '+' || c == '-') {
        if (s2) {
          l1 = l1 + o1 * l2;
        }
        o1 = (c == '+' ? 1 : -1);
        s2 = true;
        l2 = o2 = 1;
      } else {  // space
        continue;
      }
    }
    return l1 + o1 * l2;
  }
};

```

参考:  https://leetcode.com/problems/basic-calculator-iii/discuss/113592/Development-of-a-generic-solution-for-the-series-of-the-calculator-problems
Adding dynamic menus in Wagtail
Tags: python, wagtail, cms, wagtailmenus
Published: 2020-08-10 05:59:00

---
title: Adding dynamic menus in Wagtail
published: true
tags:
- 'Python' 
- 'Wagtail'
- 'CMS'
- 'Wagtailmenus'
---

## Adding dynamic menus in Wagtail

> original post in https://skamalakannan.dev/posts/wagtailmenus/
I was experimenting with [wagtail](https://wagtail.io/) CMS (Content Management System) for quite some time for one of my projects. Wagtail is a Django based CMS, which providers powerful features in building a website. In this post, I'm going to explain how we can build dynamic menus in the Wagtail website.

Read here: https://skamalakannan.dev/posts/wagtailmenus/
Add a “Show Password” checkbox to a login form with JavaScript
Tags: javascript, tutorial, webdev
Published: 2020-08-10 05:54:33

[ [CodePen Demo](https://codepen.io/michaelburrows/pen/NWNqYov) | [Original Article](https://www.michaelburrows.xyz/show-password-checkbox/) ]

Show password functionality allows a user to check if they’re entering a password correctly.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/dmih7wb5j167o7ttr6rd.gif)

They helps prevent frustration for users who aren't sure why the password isn't working because of a miss spelling.

This tutorial will show you how this functionality can be implemented with some simple JavaScript.

First thing we need to do is setup a HTML form with a password input field field and checkbox:

```html
<form id="login">
   <div>    
    <input type="password" id="password" name="password" />    
    <input type="checkbox" id="toggle-password" />
    <label for="toggle-password">Show Password</label>
  </div>
</form>
```

Now for the JavaScript.

First let’s define a couple of variables for the password field and checkbox:

```javascript
const password = document.getElementById("password");
const togglePassword = document.getElementById("toggle-password");
```
Next add an event listener that calls a `toggleClicked()` function when the checkbox is clicked:

```javascript
togglePassword.addEventListener("click", toggleClicked);
```

`toggleClicked()` determines if `toggle-password` is “checked” and changes the password field type accordingly:

```javascript
function toggleClicked() {  
  if (this.checked) {
    password.type = "text";
  } else {
    password.type = "password";
  }
}
```

This works as plain text input fields don’t obscure the characters making them visible to the user.

We can take this a step further by adding an “eye” icon to indicate the toggle state of the password.

Add the following to the `toggleClicked()` function to toggle a “visible” CSS class on the password field:

```javascript
password.classList.toggle('visible'); 
```

Next we’ll add a “visible” icon to the password field and an “invisible” icon when the `.visible` class is activated:

```css
#password {  
  background-image: url("https://img.icons8.com/material-sharp/20/000000/visible.png");
  background-position: 97% center;
  background-repeat: no-repeat;
}
#password.visible {
  background-image: url("https://img.icons8.com/material-outlined/20/000000/invisible.png");
}
```

Finally hide the checkbox and position the label over the icon so when clicked the visibility is toggled:

```css
#toggle-password {
  display: none;
}
#toggle-password + label {
  text-indent: -9999px;
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-left: -32px;
  cursor: pointer;
}
```
Understand the concept: What is CLASS in programming?
Tags: beginners, javascript, programming, concept
Published: 2020-08-10 05:49:56

---
title: Understand the concept: What is CLASS in programming?
published: true
description: simple explanation of class in programming language
tags: beginner, javascript, programming, concept
---

I am sure class is class in the real world and programming world.

It is a set or category of things having some property or attribute in common and differentiated from others by kind, type, or quality. 

I will explain CLASS from 6 angles so that you can understand the concept of class:


###👉 1. Real World Class.

###👉 2. HTML & CSS Class.

###👉 3. "Programming" class.

###👉 4. The relationships among classes.

###👉 5. The relationships among members & class.

###👉 6. And how they are similar.


When I was in class SSS3 in high school, my class mates and I had a lot in common in terms of age, purpose, duties, activities and many others.


We sat for the same subjects, the same exams and we could call one another easily because we were close and bound together in a CLASS.


So, in the real world, who will be in the class of billionaires?


1. Me 😄.
2. Jeff Bezos
3. Bill Gates
4. Mark Zuckerberg
And other billionaires.


In short, class is used to group/categorise things or people that have things in common.


In HTML & CSS.


<div class="billionaire entrepreneur"> Class of billionaires </div>


<div class="billionaire entrepreneur"> Class of billionaires </div>


These divs belong to two classes - billionaire and entrepreneur just like I can belong to one or many classes - African & Nigerian.


.billionaire {
    business: true;
    influencial: true;
}


. entrepreneur {
    smart: true;
    bad: possible;
    good: possible;
    stupid: impossible;
}


What is baffling is how beginners don't see the similarities between HTML & CSS class and the Programming CLASS.


Let me show you how class looks like in JavaScript.


class Entrepreneur {
    // constructor () {}
   
    isBad () {
      //Write the logic
    }
   
    isGood () {
     //Write the logic
    }

    isSmart () {
     //Write the logic
     //It is inbuilt in css
    }
}


From this one can deduce that the major difference between HTML & CSS and Programming CLASS is abstraction.


You have to create most things in programming languages but in html and css, you just use inbuilt "APIs", sorry, markups, attributes, values and properties.


Follow me here or on twitter: [Shakespeare of Code](twitter.com/codingnninja)


For continuation.


Comment your views below.
Deploy ReactJS Production Build with PM2
Tags: javascript, react, pm2, ubuntu
Published: 2020-08-10 04:45:41

Hello, This is my very first Post in Dev.to and i want to share about how to deploy ReactJS Production Build using VPS with PM2

###Server Environment :
OS : Ubuntu 18.04.4 LTS
NodeJS : 10.19.0
NPM : 6.14.2
 

##1. Build it
Make sure you build it (using yarn build / npm run build)

##2. Upload build file to VPS
in this step, you can upload to your vps, in my case i put it in /var/www/myReactApp

##3. Install PM2
you need pm2 to serve the apps, by using this command in terminal 
```
sudo npm install pm2 -g
```
##4. Run PM2 Command
this is the pm2 command to serve
```
pm2 serve <path> <port>
```
now we need to put our project in the command by calling
```
pm2 serve myReactApp/ 3000 --name "my-react-app" --spa
```
* myReactApp/ : folder of the app
* 3000 : the port for serve
* "my-react-app" : name for PM2 Process, will visible in "pm2 list"
* --spa : parameter for Single Page Application, redirect to root URL

##5. Apps Running
now your apps Running on the port :3000, we can open browser and access to yourdomain.com:3000 or by using your-ip:3000.

we also can setup the apache sites-enabled to hide the port from url by using ProxyPreserveHost and ProxyPass

##6. Monitoring Running Apps with PM2
we can see all of our pm2 process by calling this command
```
pm2 list
```

we can start, stop or delete process from list by using
```
pm2 <start/stop/delete> <process id/process name>
```
example :
```
pm2 stop my-react-app
```

and we can view pm2 dashboard for monitoring all running process by using
```
pm2 monit
```

now our apps deployed :D
i hope this article is useful, and i'm so sorry if there is a mistake and my poor english.

Have a Nice Day ;)
JSON-LD with a splash of gridsome
Tags: frontend, json, javascript
Published: 2020-08-10 04:41:02

---
title: "JSON-LD with a splash of gridsome"
published: true
description: "How to structure your data for rich results and better SEO."
tags: ['frontend', 'json', 'javascript']
canonical_url: "https://gregbenner.life/json-ld-with-a-splash-of-gridsome/"
//cover_image: https://direct_url_to_image.jpg
---


## JSON-LD and Gridsome

[JSON-LD](https://json-ld.org/)

> [Linked Data](https://en.wikipedia.org/wiki/Linked_data) empowers people that publish and use information on the Web. It is a way to create a network of standards-based, machine-readable data across Web sites. It allows an application to start at one piece of Linked Data, and follow embedded links to other pieces of Linked Data that are hosted on different sites across the Web.

[Here's](https://developers.google.com/search/docs/guides/intro-structured-data#search-appearance) googles introduction to the JSON-LD and Structured data. What's interesting to note here is how structured data effects search results.

![rich data example](https://res.cloudinary.com/https-gregbenner-life/image/upload/v1592606068/Screenshot_from_2020-06-19_18-30-10_fvr7no.png)

You can test a webpage for rich results [here](https://search.google.com/test/rich-results) 
Not all sites / content will qualify.



a JSON-LD should be wrapped in a script tag like so
```js 
<script type="application/ld+json">
...
</script>
```

You can use [this](https://webcode.tools/json-ld-generator/article) tool to shape your data easily online


That's all for JSON-LD below I'll quickly cover how to make use of it with Gridsome, should you be using that. It was a bit tricky to figure out how to write a dynamic then statically generated inline script.

```js
metaInfo() {
const  script = [
{ 
  innerHTML:  this.generateScheme(), 
  type: "application/ld+json" }
]
```

   ```js
   const url = "https://gregbenner.life"
   generateScheme() {
          return JSON.stringify({
            "@context": "http://schema.org",
            "@type": "BlogPosting",
            mainEntityOfPage: {
              "@type": "WebPage",
              "@id": `${url}${this.$page.post.path}`
            },
            headline: this.$page.post.title,
            image: {
              "@type": "ImageObject",
              url: `${url}${this.$page.post.cover_image.src}`
            },
            datePublished: this.$page.post.date,
            dateModified: this.$page.post.date,
            description: this.$page.post.description,
            author: {
              "@type": "Person",
              name: "Greg Benner"
            },
            publisher: {
              "@type": "Organization",
              name: "Greg",
              logo: {
                "@type": "ImageObject",
                url:
                  "/assets/static/author.fdsdfsdfsdffds.jpg"
              }
            }
          });
        }
```
You now have improved SEO and search results hurrah!

Hopefully this was helpful

Comments appreciated here https://twitter.com/cactusanddove/status/1274116607971930112
73: Evaluation and Asking for help
Published: 2020-08-10 04:35:57

👨🏻‍💻 👩🏾‍💻 👨🏼‍💻 👩🏿‍💻 👨🏽‍💻 👨🏿‍💻 👩🏻‍💻 👩🏼‍💻 👨🏾‍💻 👩🏽‍💻 -> COVID Friendly Coding :) 

If your help request is hard to understand, though, the community might not have an answer for you. How can you help your helpers?

------------
#**QUESTION**
First, update your program to help the community understand 

* the code:
Add comments to your code to describe what the different parts of your program are meant to do.

* Make your code easier to read by using descriptive variable names and white space between parts of your code.


------------
#**FEEDBACK** 
Then write a help request that the community will love 

answering:

Start the request by describing the issue.
"I want Hopper's glasses to be transparent, so her eyes still show underneath them, but I don't want them completely transparent. How can I make the glasses look tinted?"

Be specific, referring to code lines and their corresponding functions when you can.

"The fill command in line 7 does not affect the arc command in line 11. Why is that, and how can I fix it?”

The more effort you put into your help request, the more likely others will be willing to help!


------------
#**COMMUNICATION** 
When you do get a response, remember that the best answers are the ones which put you on the right track, not the ones that do all the work for you.

And finally, as you learn more, don’t forget to check out the help requests to see if you can contribute on the answering side! 

Even if you don’t know how to solve the problem, you can always learn from the answers that others are giving.

[Khan Academy and Chill]
(https://www.khanacademy.org/computing/computer-programming/programming/becoming-a-community-coder/a/evaluate-peer-projects)
Meilleures sonneries gratuites 2020
Published: 2020-08-10 04:29:02

Désormais, les sonneries de téléphone ont également leur propre langue, en fonction du contexte, du message que vous souhaitez envoyer et, en outre, elles décrivent les goûts et la personnalité du propriétaire du modèle de téléphone lent. Ces sonneries gratuites uniques et intéressantes surprendront toujours les personnes à proximité chaque fois qu'un appel arrive.
Veuillez visiter la page d'accueil qui fournit des sonneries de chien gratuites ici:https://sonneriepro.com/