teleren/devto huggingface dataset:
Why you shouldn't use the file creation time to represent a date
Tags: gatsby, graphql, netlify, dates
Published: 2020-08-10 12:53:13

---
title: Why you shouldn't use the file creation time to represent a date
published: true
description: One reason: It might break on CI/CD.
tags: Gatsby, GraphQL, Netlify, Dates
//cover_image: https://direct_url_to_image.jpg
---
Let's say you build a blog with Gatsby where each article is written in markdown and queried from your local filesystem with GraphQL with the help of the plugin `gatsby-source-filesystem`.

Now you also want to show the date of when the article was created.

So you go to Gatsby's interactive GraphQL interface (see below) and search for a field name that looks like it's a date. You find `birthTime`. Sounds great! The intuition here is that the article creation date is identical to the date **when the file was first created on a hard drive/file system**, which is what `birthTime` signifies.

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

So you query this field and it gives you some dates that look about right. Then you render them in your frontend and everything looks great on the **development server**. Even when do a real build on your local machine (`gatsby build` & `gatsby serve`).

The surprise comes when you involve CI/CD. Let's say you deploy with Netlify. Once your site is build by Netlify based on your Git repository, you will see **different dates** - namely: **The time it is right now**!

Why is that? Remember that we said earlier that `birthTime` is referring to the date when the file was first created on a hard drive/file system. Now, if you have a CI/CD service like Netlify building your site, it first fetches your repository from Github and creates all those files **again on its own filesystem**. Those are entirely new files! That's why their `birthTime` is different.

So how can you add a creation date to your blog entries?
1. Hardcode a date string into the frontmatter of your markdown files
2. Use a CMS (like Netlify CMS) that offers a UI for these things, or adds dates to the data layer automatically

Just like @pentacular said: "If it's a meaningful part of the file content, it better be part of the file content."
Add your website's pagespeed score to README
Tags: github, pagespeed, readme, javascript
Published: 2020-08-10 12:51:34

I created an API to generate PageSpeed score of a website in animated svg format with multiple options like strategy and category. This svg can be added to your README (of website)

Try this here: https://github.com/ankurparihar/readme-pagespeed-insights

Example for github.com: https://pagespeed-insights.herokuapp.com/?url=https://github.com
An Easy Trick to Stop Apologising
Tags: career, psychology, selfimprovement
Published: 2020-08-10 12:17:50

*[Follow Me On Twitter @AnnaJMcDougall](http://www.twitter.com/AnnaJMcDougall)*

Have you ever met someone who kept apologising for every question or favour they asked? Perhaps you are that person and you can hear yourself saying "sorry" over and over again for basic and normal requests which really don't need an apology. It is annoying for everyone involved and usually, the person apologising is just in *such* a habit of doing it that a gentle "No need to apologise" or even "Please stop apologising" won't actually lead to any change.

I heard a great tip a few years ago which could help you escape this annoying habit, and lead to better relationships with colleagues, friends, and superiors. This tip helps avoid a **weird power dynamic** where you put yourself in the position of someone begging or being needy, and changes it into a collaborative, positive space. In my opinion, it not only helps others respect you more, but leads to you respecting yourself more.

## Replace 'sorry' with 'thank you'

We know that replacing bad habits is easier than removing them completely, so every time you feel the urge to apologise for something unnecessarily, try to rephrase it as a thank you. This puts you in a better headspace, but people also feel a lot more comfortable accepting thanks than accepting unnecessary apologies. As said, it also turns a generally negative feeling and frames it positively. You're still showing gratitude without begging forgiveness for an everyday request.


{% twitter 1292793533829648385 %}

Here are some examples:

| Instead of | Try  |
|---|---|
|Sorry for the inconvenience|Thank you for your time|
|Sorry you had to wait so long|Thank you for your patience|
|Sorry to ask, but...|Thanks for seeing me, would you mind telling me...|
|You helped me so much, sorry|Thank you for helping me so much|

These are just a few examples. For me, "thank you for your time" was the most valuable and easy to implement in a variety of situations. 

**If you try to utilise this technique in your everyday life, you'll see that not only do people respond a lot better to your requests and explanations, but you'll also walk away feeling more like you collaborated, rather than grovelled.**


*Disclaimer:* This advice does not apply for when you truly should apologise. If you hurt someone (even accidentally) or do someone wrong, you should apologise. The above is only applicable when you are in the unfortunate habit of apologising for normal requests.
5 Docker most useful commands
Tags: docker, kubernetes, containers, devops
Published: 2020-08-10 12:15:45

Docker is widely used containerization system. Moreover Docker can be easily name a necessary tool in software development. This post shows you some of the most useful Docker commands in your daily workflow.

## 1. Execute command inside container

When working with containers you might find a need to run some command inside it, to adjust some configuration and what not. For this use the following command:

    docker exec -it $container_id $command

So let’s say I want to execute sh command inside my container. I do that with:

    docker exec -it 9e5017aef3f9 sh

Read more [here](https://docs.docker.com/engine/reference/commandline/exec/).

## 2. Publishing container’s ports

The simple and easy to understand command that can be useful when having fun with lots of different containers.

    docker build -p $local_port:$container_port $container_id

If you are building a container with let’s say a web app, that is served at port 80, by default this port is only accessible from inside the container. If you want to expose this, and open the web app in your local browser, you can do this:

    docker build -p 80:80 9e5017aef3f9

Read more [here](https://docs.docker.com/engine/reference/builder/#expose).

## 3. Stop all running containers

This one is required if you want to access the container inner service, from your network — either local or public.

    docker stop $(docker ps -a -q)

Read more [here](https://docs.docker.com/engine/reference/commandline/stop/).

## 4. Attach volume to the container

Volumes in Docker environment is a mechanism of persisting data generated by the containers. If there is a data used by container, that you want to keep even after container is restarted, you have to use this. The command looks like this:

    docker run -d -v $local_path:$container_path $container_id

So if you would like to attach a local folder into the container, you do this using following command:

    docker run -d -v /db_dump:/app/data 9e5017aef3f9

Read more [here](https://docs.docker.com/engine/reference/commandline/run/#mount-volume--v---read-only).

## 5. Display container’s logs

Very useful when debugging or if you just want to know what is happening inside of the container. To see them, use the following command:

    docker logs -f $container_id

So the fetch logs of our test container, I would use the following:

    docker logs -f 9e5017aef3f9

Read more [here](https://docs.docker.com/engine/reference/commandline/logs/).

## Summary

I hope you have found this post useful. If so, don’t hesitate to like or share this post. Additionally you can follow me on my social media if you fancy so 🙂
Setting up IntelliJ IDEA for Apache Spark and Scala development
Tags: spark, scala, intellij, tutorial
Published: 2020-08-10 12:11:23

[IntelliJ](https://www.jetbrains.com/idea/) and [Spark](https://spark.apache.org/) is the best combination for doing the real Big Data development. [IntelliJ IDEA](https://www.jetbrains.com/idea/) is the best IDE for Spark, whether your are using Scala, Java or Python. In this guide we will be setting up [IntelliJ](https://www.jetbrains.com/idea/), [Spark](https://spark.apache.org/) and [Scala](https://www.scala-lang.org/) to support the development of Apache Spark application in [Scala ](https://www.scala-lang.org/)language.

## Install IntelliJ Scala plugins

First of all we need to install the required plugins into our IntelliJ. Go to File -> Settings -> Plugins and look for both Scala and Sbt.

![](https://cdn-images-1.medium.com/max/2016/0*EK37BZeCQpB3fzab.png)

![](https://cdn-images-1.medium.com/max/2016/0*gXcAjeCn-whzjuNk.png)

After installing them, you might need to restart your IDE. Do that if prompted.

## Create Spark with Scala project

No we can start creating our first, sample Scala project. Go to File -> New -> Project and then Select Scala / Sbt

![](https://cdn-images-1.medium.com/max/2000/0*aZKElOnsE9Jdycos.png)

On the next screen choose the right version of Scala. Your chosen version should be compatible with the version of Spark you will be using. In my case it was Scala 2.12

![](https://cdn-images-1.medium.com/max/2000/0*PbHahaAvgl9GXBeJ.png)

## Add Spark libraries to Sbt

Now in our newly created project, find build.sbt file, and add the following lines:

    name := "SparkTest"

    version := "0.1"

    scalaVersion := "2.12.8"

    libraryDependencies ++= Seq(
      "org.apache.spark" %% "spark-core" % "2.3.3",
      "org.apache.spark" %% "spark-sql" % "2.3.3"
    )

After that, IntelliJ should ask if you want to download new dependencies. If prompted, click yes. In a situation when IDE is not asking you about that, you might have automatic downloading of dependencies turned on, which is totally fine. These two libraries will add support for Spark code we will be writing in a moment.

## Run the Spark Scala application in IntelliJ

Let’s create a basic application and test if everything runs properly. Create an object named FirstSparkApplication and paste in the code below:

    import org.apache.spark.sql.SparkSession

    object FirstSparkApplication extends App {
      val spark = SparkSession.builder
        .master("local[*]")
        .appName("Sample App")
        .getOrCreate()
      val data = spark.sparkContext.parallelize(
        Seq("I like Spark", "Spark is awesome", "My first Spark job is working now and is counting down these words")
      )
      val filtered = data.filter(line => line.contains("awesome"))
      filtered.collect().foreach(print)
    }

Now just execute it, and in the run console, you should see a string *Spark is awesome*.

## Summary

I hope you have found this post useful. If so, don’t hesitate to like or share this post. Additionally you can follow me on my social media if you fancy so :)

{% twitter 1225512519575445506 %}
Strict Types in PHP
Tags: php, programming, software, cleancode
Published: 2020-08-10 12:02:25

In December 2015, PHP 7 introduced scalar type declarations and with it the strict types flag.

> To enable the strict mode, a single declare directive must be placed at the top of the file. This means that the strictness of typing for scalars is configured on a per-file basis. This directive not only affects the type declarations of parameters, but also a function’s return type.

The good thing about declaring a PHP file as strict is that it actually applies to **ONLY the current file**. It ensures that this file has strict types, but it doesn’t apply to any other file in the whole project. It allows you to do, step by step, this migration from non-strict code to strict code, especially for new files or projects.

## Strict types affect coercion types

Using hint type without strict_types may lead to subtle bugs.

Without this, `int $x` meant `$x must have a value coercible to an int`. Any value that could be coerced to an int would pass the hint type, including:

- a proper `int` (example: 42 -> 42)
- a `float` (example: 13.1459 -> 13)
- a `bool` (example: true -> 1)
- a `null` (example: null -> 0)
- a `string` with leading digits (example: “15 Trees” -> 15)

By setting `strict_types=1`, you tell the engine that int $x means $x must only be an int proper, no type coercion allowed. You have the great assurance you're getting exactly and only what was given, without any conversion or potential loss.

## Who should care about this “strict type” line?

Actually, declare(strict_types=1); is more for the reader than for the writer. Why? Because it will explicitly tell the reader:

- The types in this current scope (file/class) are treated strictly.

## 'strict_types=1' is more for the reader than for the writer

The writer just needs to maintain such strictness while writing the expected behavior. That said, as a writer, you should care about your readers, which also includes your future self. Because you are going to be one of them.

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

------

## References
- [PHP Best Practices](https://php.chemaclass.com/technical-skills/strict-types.html)
- [Scalar type declarations](https://www.php.net/manual/en/migration70.new-features.php#migration70.new-features.scalar-type-declarations)
- [What do strict types do in PHP](https://stackoverflow.com/questions/48723637/what-do-strict-types-do-in-php/48723830#48723830)

> Originally published on https://chemaclass.es/blog/strict-types/
Daily Developer Jokes - Monday, Aug 10, 2020
Tags: jokes, dailydeveloperjokes
Published: 2020-08-10 12:00:02

---
title: "Daily Developer Jokes - Monday, Aug 10, 2020"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Monday%2C%20Aug%2010%2C%202020"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1259316ab83.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
___Q:___ What are the three hardest problems in computer science?

___A:___ Naming things and off-by-one errors
 -->
How to design amazing resumes?
Tags: resume, design, tips, tutorial
Published: 2020-08-10 11:51:55

*If you want your resume to stand out to recruiters from other’s candidates, you need to make it look different. Using Google Docs or Microsoft Office templates is the worst thing you can do.*

Do you have a **good resume**?

If we want to succeed in our career, we need to stand out as much as possible from others. If 99% of people use the same pattern, will they get a job?

**Well, rather not.**

You want to be the 1% that does everything better than the others. To get a job in a company, you need to send them your CV. But, the chances are, your resume looks just like the other's resume, who didn't get that job.

That's why I took the effort to design and create my resume, and you should do it as well.

**Which resume looks better?**

![Resume comparison](https://dev-to-uploads.s3.amazonaws.com/i/wzrjt40h7mxx1pwhjerh.png)

In this post, I will give you my tips on **how to create and design amazing resumes**.

# 1\. Get inspired

You have to know how the best resumes look like to make sure you don't do too much or too little (too much meaning looking bad, and little meaning looking standard).

### How to get inspired?

Search for web developer modern resume, and you will see some pretty solid resumes that you can get the inspiration.

# 2\. Use design tools

Don't create your resumes on Google Docs or Microsoft Office templates, because it will look like 99% CV's out there.

If you want to stand out from the others, you need to create it from scratch on your own.

I've created mine using **Figma**. Adobe Xd is also my recommendation.

# 3\. Optimize the file

When you will implement the design, export your work as a PDF file. Many job list websites accept max 2MB file size, so you have to optimize it to be able to send it everywhere.

The best website for optimizing the PDF files is ilovepdf.com/compress\_pdf.

My resume's size before & after optimizing:

*18MB* --> **800KB**

# 4\. Add links

You want to make it as easy as possible for your resume viewer to access your project repository, project live URL, GitHub, and website. Include also a get in touch with you.

To do that, go to this website: **[pdfescape.com](pdfescape.com)**.

Then, add your PDF and add links.

# 5\. Rename it properly

Recruiters get hundreds of CVs daily, so to help them identify yourself, you have to name it correctly. I would suggest renaming it to your full name.

### Good:

**Bart-Zalewski-Frontend-Developer.pdf**

### Bad:

*myresume.pdf*

# It's worth it!

I know it takes time. It's not like with Google Docs CV templates when it just takes a couple of minutes to create a resume that looks like every resume out there.

*Be a professional and improve your resume now!*

Thank you so much for reading, **have an awesome day**!
Can someone experienced in writing tests expand on the mental models of unit tests?
Tags: discuss, tdd, test, rails
Published: 2020-08-10 11:45:31

---
title: Can someone experienced in writing tests expand on the mental models of unit tests?
published: true
description: 
tags: discuss, tdd, test, rubyonrails
//cover_image: https://direct_url_to_image.jpg
---

Hey all, recently I've been trying to introduce tests to an app I'm working on in Rails 6 which uses MiniTest.

After going through a few guides I was still struggling and I think it's not because or the syntax of the methods available for testing but because I don't quite get the reasoning behind figuring out what to test and what is the best to way to do it.

Could someone give me an example of their thinking when they need to write tests for a method/something else? I would be very grateful! 🙇🏻‍♂️
How to make a GIF?
Tags: discuss, help
Published: 2020-08-10 11:39:55

I want to make some gif for my project tutorial. Generally, I make gif from the recorded video, which looks terrible.
Here is an example that I make:

![mygif](https://raw.githubusercontent.com/kmhmubin/Face-Recognition-Attendance-System/master/Document%20Metarial/Project%20demo%20images/pip%20install_edit_0.gif)

But recently, I encountered the website called [create react app](https://create-react-app.dev/). In this website, the gif looks more clean and crisp. Here is an example of create react app gif file.

![create react app](https://camo.githubusercontent.com/29765c4a32f03bd01d44edef1cd674225e3c906b/68747470733a2f2f63646e2e7261776769742e636f6d2f66616365626f6f6b2f6372656174652d72656163742d6170702f323762343261632f73637265656e636173742e737667)

Can anyone suggest me how to make gif like this and which software should I use to make this kind of gif file?


Advance Thank you.

[note: please forgive my grammar mistake]
How to add a contact form to a Static Website
Tags: javascript, webdev, serverless
Published: 2020-08-10 11:29:17

**Static sites aren’t static anymore.** With the rise of modern web technologies, you can build dynamic functionality to your sites. They are fast, reliable, scalable, secure and we don’t even have to deal with database errors.

> *Did you know that Static websites are 10 times faster than a dynamic site built with a CMS?*

What good is a website without a contact form? The traditional way of building a data collection functionality in this case — a contact form, would require you to bother with server-side code, web frameworks, etc., It requires you to write up your own form submission backend, which contradicts your motive to go static.

Enter form backend solutions! There are many services out there like netlify forms, getform….but in this case, we are going to use [formX](https://formX.stream).

* Create a **new workspace** for your domain and a **new form**, from the formX dashboard.
* You will get a code snippet. Add that **formX snippet** to your HTML code. It is a one-time process.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/4xvu772e3u60mk4aaand.png)
* Create your **HTML form** (obviously!). **“HTML element id”** is the only mandatory attribute in the form tag. Attributes like “method” and “post” are not needed.
* Replace **“form_id”** with your own **“HTML element id”**.

> [*Fun fact: If you add this snippet to all the pages of your website, you can track insights like the list of pages the user visits before submitting the form, No of website visits, time spent on websites, UTM parameters, activity score, etc.,*]

Now sit back and see your submissions on the dashboard as they arrive. Stay updated with submissions through **email, slack,** or any other channel of your choice. You also can set **Auto redirect URL** and **Autoresponder emails** to let your submitters know you are listening. They have **Google reCaptcha** and **Honeypot algorithms** to weed out spam entries.

#### Why formX?
I’ve tried many form backend solutions before, but the reasons I prefer formX to others are;
* They don’t cap on the number of submissions you receive or the number of forms you can create.
* They have a nifty little CRM like feature that I use to process leads for my own convenience.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/gj0bjf66bd5ksn8vgsg2.png)
* We can add multiple users to the account so that I can keep my entire team on loop.

#### Conclusion
Thus creating form backends is just as easy as **copy and pasting**. It generally takes me **less than 2 mins** to set up my forms. They are not limited to contact forms alone, you can create forms for feedback, newsletter signups, marketing signups, lead gen materials, mailing list subscribers, etc., Hope you get an idea on how to leverage form backend solutions while still using static sites and saving yourself time & money.
100DaysOfCode | Day 15, 16
Tags: 100daysofcode, python, challenge, codenewbie
Published: 2020-08-10 11:07:30

▄█ █▀█ █▀█ █▀▄ ▄▀█ █▄█ █▀ █▀█ █▀▀ █▀▀ █▀█ █▀▄ █▀▀
░█ █▄█ █▄█ █▄▀ █▀█ ░█░ ▄█ █▄█ █▀░ █▄▄ █▄█ █▄▀ ██▄
Hey everyone this is my day 15 and 16 of __100DaysOfCode__ challenge, still working on snake game, I'm so excited to share my codes and experiences here, I was busy yesterday due to one of my friend!!!
Today I have to find a bug in my codes, after eating the first food of snake it will not grow and the snake will die!
I don't know which part of my code is wrong and where's the bug, I should find that bug to fix my game so after that I'll write a post about it.

Keep Moving Forward __ツ__

Enjoy Your Journey 👊

Code with __💛__

__🅑🅐🅝🅙🅘__
🥇 Screpy SEO Tool  - #1 in Trends on Betalist.
Tags: betalist, seo, developer
Published: 2020-08-10 11:07:25

![Screpy Betalist](https://dev-to-uploads.s3.amazonaws.com/i/u0rps12mmjjcmaj7zdq4.png)

About two weeks ago, we applied to be on the Betalist.com

Our sales started to accelerate from yesterday.

Because, as of yesterday, we were launched on [Betalist](https://betalist.com/startups/screpy).

You can now a membership of Screpy with 20% discount on Betalist.

Don't forget to try our free [demo](https://screpy.app/login?demo) before purchasing.

By the way, if you have a startup, I advise you to apply for the Betalist.