teleren/devto huggingface dataset:
How To Post Articles on Dev.to Using Ruby From The CLI
Tags: devjournal, begginer, scripting, cli
Published: 2021-02-28 04:22:22

---
title: How To Post Articles on Dev.to Using Ruby From The CLI  
published: true
tags: ["devjournal", "begginer", "scripting", "CLI"]
---

## Requirements: 
* `ruby` -v ~< 2.50 
* `json` -> (`gem install json`)


## Steps

**Generate an API key**
Goto: settings -> account -> DEV Community API Keys
**Click Generate**

<br>
**Copy the `<api_key>` to your buffer**
<br>
**Add this line at the end of your `~/.bashrc` file**
<br>
**`export DEVTO_KEY="<paste_api_key_here>"`**
<br>
**Copy this gist into `/usr/local/bin/` as: `publish`**
<br>
<script src="https://gist.github.com/munazhe/c3924c95c2cd4dd7a49c674316cdc33a.js"></script>
<br>

**`sudo cp publish /usr/local/bin/`**
<br>
**Modify permissions: `sudo chmod +x /usr/local/bin/publish`**

<br>
**Do a test run: `publish hello_world.md DEVTO_KEY`**


<br>
**If it worked; Great! If it didn't, leave a comment where you got stuck.**


<br>

**NOTE:** In order to make your post public; make sure to set `published: true` so that it shows on your dashboard. You can only add maximum of 4 tags when adding tags. Titles can not have special characters otherwise you will have formatting issues. 
<br>


Here's the formatting I use: 

```markdown
 ---
  title: Hello World,
  published: true,
  tags: ["helloworld", "100daysofcode"]
 ---

  Your content goes here
```
Sync Forks to Upstream Using GitHub Actions
Tags: github, devops, githubactions
Published: 2021-02-28 02:34:42

 Most challenging and severely under-documented in open source is how to keep your fork updated with the upstream.  

There are a lot of unwritten rules in open source and inconsistencies between how projects approach contributions—your best chance for understanding that per project is the CONTRIBUTING.md. When I started contributing to open source, I always deleted my forks when my contribution merged; This can be tedious and overwhelming if you are working with many repositories. 

Below is the workflow I leverage to keep [bdougie/open-sauced-goals](https://github.com/bdougie/open-sauced-goals) repo synced with the upstream. 
```yml
// https://github.com/open-sauced/goals-template/blob/main/.github/workflows/sync-2-upstream.yml

name: Sync to Upstream

on:
  schedule:
    - cron:  '12 7 * * 1,4'
    # scheduled at 07:12 every Monday and Thursday
  workflow_dispatch:

jobs:
  sync_with_upstream:
    runs-on: ubuntu-latest
    name: Sync HEAD with upstream latest

    steps:
    # Step 1: run a standard checkout action, provided by github
    - name: Checkout HEAD
      uses: actions/checkout@v2
      with:
        ref: main
    
    # Step 2: run this sync action - specify the upstream repo, upstream branch to sync with, and target sync branch
    - name: Pull upstream changes
      id: sync
      uses: bdougie/Fork-Sync-With-Upstream-action@fork
      with:
        upstream_repository: open-sauced/goals-template
        upstream_branch: main
        target_branch: main                       # optional
        github_token: ${{ secrets.GITHUB_TOKEN }}   # optional, for accessing repos that require authentication
```

To make my action work, I forked an existing GitHub Action to add specific changes I needed. Consider checking out the original.

{% github https://github.com/aormsby/Fork-Sync-With-Upstream-action no-readme %}

Also, consider checking [opensource.guides](https://opensource.guide/) for more information on how to contribute to open source. 

_This is part of my 28 days of Actions series. To get notified of more GitHub Action tips, follow the GitHub organization right here on Dev. Learn how to build action with Node.js_

{% link https://dev.to/github/repository-automation-with-github-actions-5776 %}
Making Sense of Send
Published: 2021-02-28 01:12:51

`send()` is an instance method which is used to pass a message to an object. In my case, there were methods that I did not want it to pass. It is currently the end of phase 1 in my bootcamp and I spent this week creating a Pokedex CLI using the Pokeapi.
```ruby
response.each do |key, value|
    self.class.attr_accessor(key) unless key == "abilities"
    self.send("#{key}=", value) unless key == "abilities"
```
While creating my Ruby CLI project, I ran into the issue of `.send` overriding my method and storing the wrong data. 

 <img width="50%" style="width:50%" src=https://media.giphy.com/media/JrLwOBH23PUPlmhTbz/giphy.gif>

Through lots of troubleshooting, it finally occurred that the `attr_accessor`, used to create reader and writer methods, took a `key` and created a method for it, was sending the self made `abilities` method to the Pokemon object and hardcoding its own value. In order to fix this we use `unless` to prevent the method from being created so it can be written later. 

```ruby
    def abilities
        @abilities.collect do |a_hash|
            a_hash["ability"]["name"]
        end
    end
```

By preventing `attr_accessor` and `send` from creating the `abilities` method, I am able to look deeper into the hash and pick out exactly what I want, in this case, the value (ability) for `["name"]` to be returned to the user when selecting a Pokemon to learn more about. The same was done for other attributes such as the `["type"]` with the end result appearing like this.
```
NAME - Venusaur
ABILITIE(S) - overgrow, chlorophyll
TYPE(S) - grass, poison
```
to prevent other methods from being overridden we would add an `||` and repeat the `unless` process. The alternative and simpler route however, would be to manually use the `attr_accessor` rather than automating it. Who wouldve guessed it? Obviously not me.
First API project
Published: 2021-02-28 01:08:23

This had to be one of the most emotional projects I have ever done in my life. I finally finished my first API project for Flat Iron School, and let me tell you it was amazing, so let me tell you about it. The way it works is by taking in an API(Jikan), which is the API I used to pull different genres of animes depending on what the input of the user was. So far I have a total of 6 genres users can choose from it goes from Action, Cars, Adventure, Comedy, Dementia, and Demons. Once the user inputs his preferred choice, numbers 1-20 show up with the titles that output the top 20 animes trending today. This was something I thought of to later grow into an algorithm that can be implemented in a cite that grabs all of your animes watched and picks the highest percentage anime that corresponds to your liking. One of my toughest challenges in this project was building it from scratch. Just starting from a blank made me nervous in the beginning but quickly got the hang of it. Another big challenge I ran into was when the program initiated and it asked for a genre it was able to run until I asked for the synopsis and it would put out the same synopsis for each of the 20 animes therefore, I quickly debugged my code and found out I had not specified the level or synopsis in the object that I wanted to get into. Not many anime platforms do this and it does get boring if you don't have anything to watch so I'm going to later grow this project into something that can be amazing and pick the best anime for you.


project link: https://github.com/Bryanjazo/anime_project
What is Git and why you need it.
Tags: github, javascript, webdev
Published: 2021-02-28 00:08:24

As a young developer, I was always confused about what git was, and how it relates to Version Control System(VCS).
Talking of Git, we've all heard it's a Version control System.... blah blah blah and the likes of it. it even gets more confusing using terminologies like, commits, push, branch, etc. to explain what exactly Git was.

In this article, I will work you through what Git is, and why you need it as a developer. But before then let's know what a Version Control System(VCS) is.
For easy understanding, I always like to think of it as a Ctrl+Z(undo), Yeahhh.

Imagine you working on a .doc file or any text file, what do you do when you want to revert to the previous version of the file. You undo your (Ctrl+Z) changes or make a backspace, right?
Well, Version Control works Somewhat similar. A Version Control System helps you keep track of every modification(changes) made to any of your source code. it also helps you revert (undo these changes) made to your source code in case a bug or issue was introduced to the code during development.

When collaborating with other developers on a project, sharing of codes and tracking other developer's changes could be made easier with a Version Control System.

Now, What Exactly is Git?
As we have defined and known what a Version Control System is.

##What is Git?
There are lots of Version Control Technologies and Tools used by developers to track their changes and collaborate with other developers. E.g Git, Subversions, Mercurial, Aws CodeCommit, etc.
Git is the most widely used open-source distributed Version Control Tools designed to handle and manage Changes from small to very large projects.

Now as most young developers do, Oops, I meant, as I did. Don't confuse Git with Github, as they are two different things. Check out my article on Git and Github(to understand better).

##Why use Git?
Every developer should learn how to use Git or any Version Control Tool in other to conveniently revert to the previous file version when there is a bug or unwanted feature in the source code, most especially when collaborating with other developers, not within the same vicinity.

To reduce the risk of codes being broken, Git can be in handy when having different developers working on different features on a project.

Finally, Git can only be used if it's installed on your computer. Check out my article on How to install Git with ease.
How to render emojis with JavaScript
Tags: javascript, react
Published: 2021-03-05 22:49:19

---
title: How to render emojis with JavaScript
published: true
date: 2021-02-28 00:00:00 UTC
tags:
  - javascript
  - react
canonical_url: https://www.emmanuelgautier.com/blog/rendering-emojis-with-javascript
---

For the content of your posts, emojis add some fun to your pages. This short post explains how to make that possible in JavaScript.

The most conveniant is to use directly the right emoji Unicode. Here a JSX example :
```jsx
<span>{'\u{1F680}'}</span>
```

You can also use the [node-emoji package](https://www.npmjs.com/package/node-emoji) to help you manipulate them.

If you want to know what unicode emoji to add, you can find this page useful : [Full Emoji List](https://unicode.org/emoji/charts/full-emoji-list.html)
Test-Driven vs Test-First
Tags: testing, tdd
Published: 2021-02-28 15:47:13

---
title: Test-Driven vs Test-First
published: true
date: 2021-02-28 00:00:00 UTC
tags: testing, tdd
canonical_url: https://jhall.io/archive/2021/02/28/test-driven-vs-test-first/
---

I have observed a lot of confusion out there about the term Test-Driven Development (or TDD). Let me demonstrate with a paraphrased comment from a former colleague:

> I tried Test-Driven Development once, and it was a disaster, and a huge waste of time. I spent a week writing all the test cases, then when I got to writing the code, I realized most of my test cases weren’t right, and had to be rewritten anyway. And such an approach only works on a project where the end result is fully known at the outset!

What this colleague was describing certainly is an example of Test-First Development. But it is unequivocally _not_ Test-Driven Development.

When doing proper TDD, your tests drive the development process, in a way similar to driving a car. That is to say, it’s an interactive process. To stretch the analogy to the point of breaking, my colleague’s approach was treating tests like a detailed trip plan.

True Test-Driven Development takes place in very short cycles. 10-15 second cycles between writing a test and writing code is common. A few, single-digit minutes is the maximum. If you spend a week, a day, an hour, or even 10 minutes, writing a test before writing code, you’re doing TDD wrong.
How to get environment variables into the browser context in Nextjs?
Tags: nextjs
Published: 2021-02-28 00:00:00

---
  title: How to get environment variables into the browser context in Nextjs?
  published: true
  tags: Nextjs
  date: Sun Feb 28 2021 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/get-environment-variables-to-browser-nextjs
  cover_image: https://melvingeorge.me/_next/static/images/main-903e05c5182d4e33bd040df56659a61c.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/get-environment-variables-to-browser-nextjs)
  
To expose or get environment variables to the browser in Nextjs, you have to prefix the environment variables name with the `NEXT_PUBLIC_` string. By doing so Nextjs automatically binds the environment variables from the server context to the browser context.

```bash
# Expose environment variables to browser Nextjs
NEXT_PUBLIC_ENV_VAR_NAME=VALUE;
```

For example, let's say you have an environment variable called `SERVER_ID` with the value of `HELLO!` in the `.env` file in the root of your Nextjs project folder like this,

**.env file**

```js
SERVER_ID=HELLO!
```

Currently, this is available in the server-side (or Nodejs context) of the Nextjs project.

To expose it to the browser, we can add a prefix **`NEXT_PUBLIC_`** to the env variable `SERVER_ID` like this,

```js
NEXT_PUBLIC_SERVER_ID=HELLO!
```

Now the environment variable is available in the browser context too. Magic of Nextjs! 🥳

Now to access it you can use the `process.env` API just like you would normally use it in a Node.js context.

For example, to access the `NEXT_PUBLIC_SERVER_ID` env in a Nextjs page called `About.js`, you can use it like this,

**about.js file**

```jsx
export default About(){
    return(
        <p>{process.env.NEXT_PUBLIC_SERVER_ID}</p>
    )
}
```

That's it! 🌟

See the above code live in [Codesandbox](https://codesandbox.io/s/get-env-vars-in-browser-nextjs-t4sj5?file=/pages/index.js)

### Check out [How to create and use environment variables in Nextjs?](https://melvingeorge.me/blog/create-and-use-environment-variables-in-nextjs) to know more about using the same.

### Feel free to share if you found this useful 😃.

---
Software is Tetris
Tags: programming, computerscience, architecture, career
Published: 2021-02-27 23:49:34

Software and Tetris have a lot in common.
No, I am not saying that the best software was written in 1984 or by Russians.
What I am saying is that playing Tetris feels a lot similar like building software.

So far I was not able to break the metaphor.
It is so powerful that can even work at multiple levels of abstraction.

A quick example: Tetris feels like a never ending game, and so does software.
From small personal project to big budget, company powered ones. We can argue that it seems that there is always something to do.
A feature to implement, a feature to add, if we want the ball would always keep rolling.
Until eventually we give up or move onto another project.
Basically until you lose and Tetris wins.

Tetris is always easier at the starting point, with a clean slate.
This goes without much to say, you can verbatin replace Tetris with Software in the last sentence.
Sometimes you even throw the game when it gets too difficult in order for you to start a new one from the start.
We all have that git repository with that old project that we abandon in order to seek happiness elsewhere.

When you start a game of Tetris you are super focused, planning your every move optimizing every placement.
Just like building software, you start planning your folder structure, putting everything in their place, but for how long?
Sometimes you need to go fast.

Speed and perfection, don't go together.
This last one is true for Tetris, for software and for life in general.
when building software if you go too fast you start making mistakes, taking shortcuts.
Basically, you start leaving holes in your blocks.

Sometimes you cannot be perfect.
In order to move forward, you need to be able to accept less than perfect.
Done is better than perfect.
Sometimes, you need to use that L piece to close off a few lines.
If you keep waiting for that I piece, that perfect Tetris every time you might end up throwing your whole game.

What about working with others?
Just play Tetris 99 for a while and you have a pretty decent picture of what it feels like building software with other people.
You think you have the perfect blocks? Those perfect lines ready for that big Tetris? 
Baam! Now you have your bits and you need to integrate this new batch of changes from this random guy.

There is always that guy who is better than you and can make lines faster than you.
Probably is just he is doing this for far longer than you.
Practice makes perfect.

You see? Tetris and software are basically the same concept.

![Tetris gif](https://media.giphy.com/media/5Tndtit6LsZmE/giphy.gif)


First published on my [blog](https://luissilva.eu/blog/).
Day 27: Bucket Sort
Tags: 100daysofcode, java
Published: 2021-02-27 23:44:14

```java
import java.util.Random;

 

public class Bucket_Sort 

{

    static int[] sort(int[] sequence, int maxValue) 

    {

        // Bucket Sort

        int[] Bucket = new int[maxValue + 1];

        int[] sorted_sequence = new int[sequence.length];

 

        for (int i = 0; i < sequence.length; i++)

            Bucket[sequence[i]]++;

 

        int outPos = 0;

        for (int i = 0; i < Bucket.length; i++)

            for (int j = 0; j < Bucket[i]; j++)

                sorted_sequence[outPos++] = i;

 

        return sorted_sequence;

    }

 

    static void printSequence(int[] sorted_sequence) 

    {

        for (int i = 0; i < sorted_sequence.length; i++)

            System.out.print(sorted_sequence[i] + " ");

    }

 

    static int maxValue(int[] sequence) 

    {

        int maxValue = 0;

        for (int i = 0; i < sequence.length; i++)

            if (sequence[i] > maxValue)

                maxValue = sequence[i];

        return maxValue;

    }

 

    public static void main(String args[]) 

    {

        System.out

                .println("Sorting of randomly generated numbers using BUCKET SORT");

        Random random = new Random();

        int N = 20;

        int[] sequence = new int[N];

 

        for (int i = 0; i < N; i++)

            sequence[i] = Math.abs(random.nextInt(100));

 

        int maxValue = maxValue(sequence);

 

        System.out.println("\nOriginal Sequence: ");

        printSequence(sequence);

 

        System.out.println("\nSorted Sequence: ");

        printSequence(sort(sequence, maxValue));

    }

}
```
Laragon for Laravel development on windows
Tags: laravel, php, windows, beginners
Published: 2021-02-27 23:39:31

---
title: Laragon for Laravel development on windows
published: true
description: 
tags: #laravel #php #windows #beginners
//cover_image: https://direct_url_to_image.jpg
---

# Laragon for Laravel development

Hey, guys.

At this moment I want to share with you, how to work Laravel Framework in Windows.

Mexico city, March 22, 2020. When the COVID-19 pandemic started in Mexico City. I had to emigrate from the city and buy a computer with windows 10.

lol At this point I thought: how do I develop my laravel applications on windows?

So, I met [Laragon](https://laragon.org/), a tool is amazing. 
Initially I had a lot of trouble running the PHPUnit tests. 🥺

Then I managed to run the tests:

```cdm
.\vendor\bin\phpunit
```

## Laragon benefits

**Multiple php versions**: 
An important benefit is the change of PHP versions between 7.1 to 7.4, this is a headache when working with laravel valet on Mac OS.

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

**Multiple database**:
We can switch between mysql or mariadb. This depends on your projects.

## Disadvantages

When we work with Windows, there are possibly problems with the directory path.

In my experience I had problems with the jest tests. because the node_modules directory cannot be found.

Anyway, Laragon is very elegant for laravel development.
Looking to get some insights from developers interested in privacy and data handling
Tags: graphql, datascience, react, data
Published: 2021-02-27 22:10:21

Hey Dev.TO folks!

I'm a UX/UI intern at Prifina – we're building a developer platform that brings together a GraphQl personal data model and a technical environment where to utilize it. For individuals, it means they can get their own personal data clouds, combine and control their personal data there, and find and install applications that run on top of that data. Think of plotting stressors on a map using heart rate and location data objects.

We're early on in the product life cycle and are looking to do some interviews/surveys with any developers that have are interested in bringing data back to the people. If you're interested, dm me and i'll make a note of it!

Cheers,
Dave
Building the Home Lab Kubernetes Playground Blog Series
Tags: kubernetes, cloudnative, cloudskills
Published: 2021-02-27 21:37:03

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

Hi Everyone, I wanted to start sharing some of the content and learning paths I have been taking to get a better grasp on Kubernetes and Cloud Native technologies. 

First of all I am going to be putting my learning and findings on this page as I continue to navigate these new technologies. 

And then I will keep adding if possible to this post with the latest blog posts. 

[Part 1 - Choosing your platform](https://vzilla.co.uk/vzilla-blog/building-the-home-lab-kubernetes-playground-part-1)

[Part 2 - Setting up your Kubernetes cluster](https://vzilla.co.uk/vzilla-blog/building-the-home-lab-kubernetes-playground-part-2)

[Part 3 - Playing with stateless workloads](https://vzilla.co.uk/vzilla-blog/building-the-home-lab-kubernetes-playground-part-3)

[Part 4 - Setting up dynamic shared storage](https://vzilla.co.uk/vzilla-blog/building-the-home-lab-kubernetes-playground-part-4)

[Part 5 - Helm & MinIO] (https://vzilla.co.uk/vzilla-blog/building-the-home-lab-kubernetes-playground-part-5)

[Part 6 - Context is important] (https://vzilla.co.uk/vzilla-blog/building-the-home-lab-kubernetes-playground-part-6)

[Part 7 - Load Balancing your Kubernetes Home Lab with MetalLB] (https://vzilla.co.uk/vzilla-blog/building-the-home-lab-kubernetes-playground-part-7)

[Part 8 - Deploying KubeApps the visual marketplace for all your Kubernetes Apps] (https://vzilla.co.uk/vzilla-blog/building-the-home-lab-kubernetes-playground-part-8)

[Part 9 – A Mission Critial App - Pacman] (https://vzilla.co.uk/vzilla-blog/building-the-home-lab-kubernetes-playground-part-9)

[Part 10 – Backups in a Kubernetes world](https://vzilla.co.uk/vzilla-blog/building-the-home-lab-kubernetes-playground-part-10)

I have probably up to parts noted down and will try and keep this up to date as a post moving forward and if that is possible and as I continue my learning in this area. 

I would love to get your feedback useful links to add or things we should share with the community. You can also find me over on [Twitter @MichaelCade1] (www.twitter.com/michaelcade1)