teleren/devto huggingface dataset:
CS Podcast - Swift and SwiftUI Testing with Gio Lodi
Tags: testing, podcast, swift
Published: 2021-06-28 06:13:29

---
title: CS Podcast - Swift and SwiftUI Testing with Gio Lodi
published: true
date: 2021-06-28 00:32:19 UTC
tags: testing, podcast, swift,
canonical_url: https://www.compileswift.com/podcast/s03-e03/
---

{% spotify spotify:episode:36UpJyswbhAX923lhq85QD %}

I talk with Gio Lodi about his new book on testing Swift, SwiftUI, and Combine code in this episode.

Gio is a writer of software and words, a testing and productivity enthusiast, and a geek. He loves to play and build LEGOs with his little children and read books with a warm cup of coffee.

Gio is a mobile infrastructure engineer at Automattic, where he helps the teams working on the WordPress mobile apps to ship quality code on a schedule. He’s a testing, automation, and productivity enthusiast and the author of [Test Driven Development in Swift with SwiftUI and Combine.](https://tddinswift.com/)

Topics include Why testing is important. How writing tests for your code can help you. The challenges of SwiftUI with your testing process. It would be best if you were writing tests before writing code.

You can find the book at [https://tddinswift.com](https://tddinswift.com)

You can reach Gio on Twitter @mokagio and at his Web site [https://mokacoding.com/.](https://mokacoding.com/)
How do Functions work in JS?
Tags: javascript, beginners
Published: 2021-06-28 00:07:22

####What happens when a function is invoked?
Let's start off with a simple problem. There are three variables named x in the following code. Which values do you think will be returned when the functions are invoked and the variable is printed in the console? The answer is provided below as comments.
```js
var x = 1;
one(); // 10
two(); // 20
console.log(x); // 1

function one() {
  var x = 10;
  console.log(x);
}
function two() {
  var x = 20;
  console.log(x);
}
```
The most important thing we have to remember here is that when functions look for variables they check their local memory environment first before checking their parents' memory environment. That is the reason why one() prints 10 and two() prints 20 although there is an x variable in their parent's environment with a value of 1.

####How does the call stack work?
The reason why we jump to the call stack after talking about functions in the previous paragraph is because every time a function is invoked a local execution environment is created which means that the local execution environment is pushed into the call stack.

The snapshot below shows how the call stack works. The local and global memory is highlighted in orange and the call stack is highlighted in yellow. As you can see variable x is in the local variable which is where JS looks first before going on to check the global scope(its parent).

The *anonymous* highlighted in yellow is the global execution environment and *one* is the local execution environment which was created because *function one* was invoked in line 2. Once function one prints 10, it is popped off the call stack and function *two* will be pushed into the call stack. 

If this does not make sense reviewing part 2 (JS Execution Context) of this series should help.
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/75s7b3xcmvgo40lkw23y.png)
Forest Cuties tournament
Tags: gamedev, nft, tournament, near
Published: 2021-06-28 18:14:28

---
title: Forest Cuties tournament
published: true
date: 2021-06-28 00:00:00 UTC
tags: gamedev, nft, tournament, near
canonical_url: https://enclavegames.com/blog/forest-cuties-tournament/
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h3bk9l0ef9gg11df6yxv.jpg
---

Wait, what? Yes, you read that right: there’s [going to be](https://twitter.com/Outplay_Games/status/1409315613605044231) a one-day **Forest Cuties tournament** where the main prize is **50 NEAR**.

It starts today / tomorrow depending on the time zone: June 28th 9:00 PM EST is June 29th 1:00 AM UTC or 3:00 AM CEST (GMT+2). The tournament will run **online** during the following **24 hours** , so make sure to visit [alpha.outplay.games](https://alpha.outplay.games/) if you’d like to **join**. There’s no buy-in needed when the tournament starts.

![Enclave Games - Forest Cuties tournament](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/upwhgqvuz9pss85rkesm.jpg)

This is the effort of [OPGames](https://outplay.games/) and [Enclave Games](https://enclavegames.com/) where we explore the intersection between HTML5 games and Web 3 ones utilizing blockchain technologies. We already published [Forest Cuties NFT in the Paras Marketplace](https://paras.id/token/bafybeiam65l23gf7fcgusugepomljnvctu4d2asczk3r5c6nrq3zxnhvpu) as part of [The Pioneers NFT collection](https://paras.id/publication/editorial/paras-x-op-games-nft-drops-the-pioneers-60b240873ddf5f3a052f1d61), where [Flip Flop](https://featurekreep.itch.io/flip-flop), the winner of the [Gamedev.js Jam 2021](https://gamedevjs.com/jam/2021/), is also offered.

We’re going to explore this even further, so expect more [Decentralized](https://enclavegames.com/blog/tag/decentralized/) content coming from Enclave Games in the next months.
Grant for the Web community call #1
Tags: gamedev, webmonetization, grantfortheweb, community
Published: 2021-06-28 14:46:05

---
title: Grant for the Web community call #1
published: true
date: 2021-06-28 00:00:00 UTC
tags: gamedev, webmonetization, grantfortheweb, community
canonical_url: https://end3r.com/blog/grant-for-the-web-community-call-1/
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hnz5q6hr3jf2n8tj20hi.jpg
---

The very first **Grant for the Web program community call** was happening last week, on Thursday June 24th, and I was lucky enough to be presenting about our very own project that we [completed recently](https://community.webmonetization.org/enclavegames/web-monetized-html5-game-development-final-grant-report-3je).

This is the beginning of the [Community Next](https://community.webmonetization.org/grantfortheweb/community-next-3ldo) approach - connecting grantees with each other and turning a buch of random people into a living community. That include community calls, demo parties, skill shares, and more. The [first event](https://community.webmonetization.org/grantfortheweb/recording-of-first-community-call-29kf) focused on introducing the upcoming events, and presenting some of the projects.

The **5x5 Project Share-Outs** are about having 5 slides and 5 minutes total (so 1 minute per slide) for presenting about a specific topic. The first one was [Cecilia Krum](https://community.webmonetization.org/ckrum) from **Permanent** talking about the [Storage to the People](https://community.webmonetization.org/storagetothepeople) project.

![End3r's Corner - Grant for the Web 5x5](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6dujf7c61uoz04w7f4n9.jpg)

I was talking right after, and went through the whole story of how our project [Web Monetized HTML5 Game Development](https://enclavegames.com/blog/final-grant-report/) started, what we finally built, and some lessons learned from the process, since there were many new grantees during the call.

Third talk had to be skipped, but we had extra few minutes to do the round of quick updates from other participants, and close the call on time. Check the [meeting notes](https://pad.staging.permanent.org/p/Grant_for_the_Web_Community_Call_June_21) and the [recording](https://drive.google.com/file/d/1t1PBm2SozuYc2tVEDdFNlyb_mp2WElBJ/view) for more details of what we talked about, and make sure to follow [Grant for the Web](https://community.webmonetization.org/grantfortheweb) if you’re interested in the next events.
How do I convince my team to do it…?
Tags: devops, culture, tools
Published: 2021-06-30 15:14:20

---
title: How do I convince my team to do it…?
published: true
date: 2021-06-28 00:00:00 UTC
tags: devops,culture,tools
canonical_url: https://jhall.io/archive/2021/06/28/how-do-i-convince-my-team-to-do-it/
---

If there’s one question I get asked more than any other, it’s “How do I convince my team to do X?” where X is some DevOps-ish thing, such as continuous deployment, TDD, git rebase, or a thousand other things.

If you’ve ever asked a question like this (to me or anyone else), unfortunately I don’t have a silver bullet answer for you.

Rather, I have an observation:

_DevOps is about a cultural change, not a technical change._

The technical practices, tools, and changes associated with DevOps exist to serve the cultural change, not the other way around.

I believe this is at the core of the frustration many people feel (including myself at times) when a team or individual seems to “not get it” with regard to some technique or tool.

Which tools any given team chooses from the DevOps toolset (or any other toolset) are incidental, and are useful only insofar as they help the team work toward a culture of **cooperation** and **collaboration**.

Focus on these, and the right tools will naturally start to fall into place.

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
How to restart an Nginx server or service in Linux?
Tags: resource
Published: 2021-06-28 00:00:00

---
  title: How to restart an Nginx server or service in Linux?
  published: true
  tags: Resource
  date: Mon Jun 28 2021 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/restart-reload-nginx-server-service-linux
  cover_image: https://melvingeorge.me/_next/static/images/main-513a89c53935d573a68965ed76c15d1a.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/restart-reload-nginx-server-service-linux)
  
To restart an Nginx server or service, we can use the `systemctl` command-line utility followed by the `reload nginx` command in Linux.

```bash
# Restarts Nginx service
sudo systemctl reload nginx
```

### What is `systemctl`?

- The `systemctl` is a command-line utility that is used to control and manage the `systemd` services.
- It is widely used with web server services like Nginx, Apache, etc.

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

---
Binary search tree in data structure
Tags: algorithms, computerscience, beginners, python
Published: 2021-06-27 23:24:22

Hi, in this is part 3 of the tree data structure, we're going to discuss the Binary search tree, and in the next post, we will cover in detail its implementation (insertion, searching, and deletion).

## Binary search tree (BST)

+ **Binary search tree**: or (*sorted binary tree*) is a **binary tree** invented in (1960) which all nodes that exist in the *right sub-tree* are greater than the nodes that exist in the *left sub-tree* and there *parent node*.
and Both the left and right subtrees must be binary search trees as well.

![Aya Bouchiha binary search tree in data structure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u97xgilz9xiq2cc6o75u.jpg)

## Space complexity of binary search tree

+ The space complexity of the binary search tree is **O(n)** where n is the number of elements.

## Time complexity of binary search tree

|  | insert | search | delete | 
|--|--------|--------|--------|
| best case | O(log n) | O(log n) | O(log n) | 
| worst case | O(n) | O(n) | O(n) | 

The time complexity of the Binary search tree becomes **O(n)** if the binary tree is a skewed binary tree.

## Advantages of using a binary search tree

+ Faster than array and Linked list in insertion and deletion.
+ It is so Efficient in searching
+ getting The minimum and the Maximum easily

## Disadvantages of using a binary search tree

+ More stack space due to the recursion 
+ The run time mat increases because of the comparisons.

## References and useful resources

+ [https://www.geeksforgeeks.org/binary-search-tree-set-1-search-and-insertion/](https://www.geeksforgeeks.org/binary-search-tree-set-1-search-and-insertion/)
+ [https://afteracademy.com/blog/binary-search-tree-introduc
tion-operations-and-applications](https://afteracademy.com/blog/binary-search-tree-introduction-operations-and-applications)
+ [https://www.quora.com/What-are-some-practical-applications-of-binary-search-trees](https://www.quora.com/What-are-some-practical-applications-of-binary-search-trees)
+ [https://www.upgrad.com/blog/binary-tree-in-data-structure/](https://www.upgrad.com/blog/binary-tree-in-data-structure/)
+ [https://www.coursehero.com/file/p1fldsp9/Disadvantages-of-Binary-Search-Trees-The-shape-of-the-tree-depends-on-the-order/](https://www.coursehero.com/file/p1fldsp9/Disadvantages-of-Binary-Search-Trees-The-shape-of-the-tree-depends-on-the-order/)
+ [https://www.javatpoint.com/binary-search-tree](https://www.javatpoint.com/binary-search-tree)

See you in the next post, on which we will cover the binary search tree implementation in detail, Happy Coding:) 

\#day_15
A Tiny URL design and code ✔️
Tags: systems, tutorial, java, architecture
Published: 2021-06-27 19:46:35

This is a simple `encode()` and `decode()` function.

> Note that we haven't created the MD5 hashing approach here as this only deals with the concept.

## Step:
### encode()
 - save the long url in db, get a unique long id from db for that url
 - pass that long id to the `encode(id)` function
 - so for a long value we keep diving it by 62 and pick a value from the allowed chars array and keep adding it
 - make sure to reverse the created string

```java
    private static final String allowedString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    private final char[] allowedCharacters = allowedString.toCharArray();
    private final int base = allowedCharacters.length; // 62

    public String encode(long input){
        var encodedString = new StringBuilder();

        if(input == 0) {
            return String.valueOf(allowedCharacters[0]);
        }

        while (input > 0) {
            encodedString.append(allowedCharacters[(int) (input % base)]);
            input = input / base;
        }

        return encodedString.reverse().toString();
    }
```

### decode()
 - send the last part of the url - which is the encoded string
 - convert the string to array
 - from first value we pick index of value and multiply it with  `62^remaining characters`
 - the number is the decoded id

```java
    public long decode(String input) {
        var characters = input.toCharArray();
        var length = characters.length;

        var decoded = 0;

        //counter is used to avoid reversing input string
        var counter = 1;
        for (char character : characters) {
            decoded += allowedString.indexOf(character) * Math.pow(base, length - counter);
            counter++;
        }
        return decoded;
    }
```

So if we have the decoded url, we could simply return it as a header location - with the response code of `302 (FOUND)`
```java
@GetMapping(value = "{shortUrl}")
public ResponseEntity<Void> getAndRedirect(@PathVariable String shortUrl) {
        var url = urlService.getOriginalUrl(shortUrl);
        return ResponseEntity.status(HttpStatus.FOUND)
                .location(URI.create(url))
                .build();
    }
}
```


### The problems: 
1. we are relaying on a single db table id to generate the ids
2. not scalable, how do we handle a fixed size return url
3. how do we allow customised URLs
4. can we reuse a short-url which is removed/expired?


I will be working on a more distributed solutions in coming posts, Thanks you for reaching here.
Here's a 🍪
Pre-Post Script en npm
Tags: javascript, npm, node
Published: 2021-06-27 23:05:36

https://docs.npmjs.com/cli/v7/using-npm/scripts

La propiedad script de nuestro package.json admite varios scripts integrados y sus eventos de ciclo de vida preestablecidos, así como scripts creados por nosotros. Todos estos se pueden ejecutar ejecutando npm run \<nombreComando\>. Pero ademas de estos comandos podemos agregar comandos que se ejecuten antes y después de ellos con solo agregar pre o post antes del nombre del comando por ejemplo:

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kuqt4ywdarpdtkzy463w.png)
 
 
aquí esta el resultado:

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x97py3svh7xgnsebhzus.png)
Go programming project tutorial series: Build a Slack Bot with Go


Tags: go, devops
Published: 2021-06-27 23:01:06

Hello!

I wanted to share a YouTube series I developed on Go. The intended audience is primarily people in DevOps roles, but I think it will also be beneficial for those who are just starting to learn Go and are looking for a practical project to help them get started. Below is a detailed outline of the series so you know exactly what you will learn:

++++[YouTube Playlist Link](https://youtube.com/playlist?list=PLrSqqHFS8XPaeJ71OKLoEkoBsAVUOQduP)++++

Series Outline:

Video 1: Creating a Slack App - This video doesn't include any coding but covers the pre-requisite steps you must complete in order for the Go program that you write in later videos to work properly

Video 2: How to Publish a Message - Now you get to write some code, and I introduce you to the https://github.com/slack-go/slack library. Using the slack-go library, I show you how to send messages to a channel in your Slack workspace

Video 3: Command-line arguments and Block Kit - I walk you through modifying the Go program to accept command-line arguments and I introduce you to Slack's Block Kit.

Video 4 : Run our Slack Bot as a Jenkins Post-Build Action - This video focuses more on integrating the program with Jenkins so most of it is optional if you're more interested in learning Go. I walk you through the development of a Jenkins pipeline that runs the Go program as a post-build action (and sends a notification to your designated Slack channel on whether the Jenkins pipeline build passed or failed).

Video 5: Convert Bot to Microservice and add API Endpoint - I walk you through re-architecting the Go program as a microservice with a single API endpoint, rather than having Jenkins run the program on the Jenkins node.

Video 6: Add JSON processing to our API endpoint - I introduce you to JSON processing in Go using "encoding/json" so that the API endpoint in the microservice accepts JSON arguments.

I hope that you find the series valuable and moreover that you enjoy it!
Connect Four Terminal Game
Tags: python, beginners
Published: 2021-06-27 22:58:22

After several months of learning python on Codecademy, I have built a basic Connect Four game on the terminal. I started learning python five years ago, but was not consistent throughout those years. Thankfully, I had the opportunity to continue learning on Codecademy. After reviewing the basic syntax of python, I was able to create a game on the terminal. This is my first project, so the code is not perfect. Here is the [link](https://github.com/SARdude54/ConnectFourTerminal) the source code.
How to style markdown code blocks in VS Code
Tags: vscode, markdown
Published: 2021-06-27 21:55:25

---
title: How to style markdown code blocks in VS Code
published: true
description: It's possible to style code blocks in a rich way in VS Code with a little help of Highlights extension
tags: vscode, markdown
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3brfyv3x7sap166xbqao.jpg
canonical_url: https://www.chodorowicz.com/blog/styling-markdown-code-fenced-blocks-in-vscode
---

Here's a quick tip for everybody using VS Code for viewing markdown files with code blocks. It might be handy for all of you to use VS Code as a note-taking app.

The problem is that by default, in VS Code markdown edit mode (not the preview mode, that's an entirely different story), code blocks are not very clearly styled. They don't look much different than other types of text, and VS Code doesn't offer an easy way to achieve that. The main problem is that VS Code theming doesn't allow setting the background color for different types of parsed syntax. Ideally, I'd like to set background color code blocks so they'd be easily distinguishable from the rest of the text.

![VS Code lack of code blocks styling](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3brfyv3x7sap166xbqao.jpg)
Fortunately, there's a [Highlight](https://marketplace.visualstudio.com/items?itemName=fabiospampinato.vscode-highlight)  extension, which allows you to set much more advanced styling (background color 🎉) by defining regex patterns and styling rules. Of course, ideally, I'd prefer to use theme tokens from the `tmTheme` parser, but it seems it's the best we can have 🤷.

So, first, of course, install the extension. Then to define to enable code blocks highlighting for a particular repo, create a settings file `.vscode/settings.json`.

```json
{
  "highlight.regexes": {
    "([^`])(`[^`]+?`)": {
      "filterLanguageRegex": "markdown",
      "regexFlags": "g",
      "filterFileRegex": ".*\\.md",
      "decorations": [{}, {
        "backgroundColor": "rgba(0, 0, 0, 0.05)",
        "border": "1px dashed rgba(0, 0, 0, 0.1)",
        "borderRadius": "3px"
      }, {}]
    },
    "(```.+?```)": {
      "regexFlags": "gs",
      "decorations": {
        "backgroundColor": "rgba(0, 0, 0, 0.05)",
        "isWholeLine": true,
      },
      "filterLanguageRegex": "markdown",
      "filterFileRegex": ".*\\.md"
    }
  }
}
```
And now, after applying the settings  (drums 🥁🥁🥁).

![VS Code with code blocks styling](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h0ayrz7cgdqdyvc8al14.jpg)

There's a little bit of regex trickery here around selecting single backticks `` ([^`])(`[^`]+?`) `` and triple backticks group ```` (```.+?```) ````. After that, there's only styling left. I'm using backgrounds and a bit of border color and radius in case of inline code blocks, but you [can do a little bit more with this API](https://code.visualstudio.com/api/references/vscode-api#DecorationRenderOptions).
9 changes that made me a proud CTO
Tags: leadership, management, productivity, operations
Published: 2021-06-27 21:55:22

A lot of people ask me my mantra of leading teams and how I do what I do so that people love working with me. 

Here are some of the things that I did which made huge impact on my business especially when pandemic started in 2020, and that made me a proud CTO.

1. Treat everyone as linchpins not employees 

2. Understand their personal challenges: Every individual has own share of personal challenges today, your team members are not different. In the age of pandemic where people are losing their loved ones, focusing on projects, handling personal and professional life is challenging. So, try to understand that, give personal space, and help them.

3. Respect opinions - Everyone has a different opinion on project. Sometimes, one bad project can ruin things and time for you and the team. While taking a project, consultation with your peers won’t hurt. Ask if they like the project, what challenges we might face while working with this project, do they like client or he is going to be terrible to deal with. These kind of 1-1 with team really helped me in the past years.

4. Help them when they need you the most

5. Stop micro management

6. Spend time aside from the daily tasks/projects 

7. Listen more 

8. Encourage personal growth 

9. Embrace mistakes

Let me know what are your thoughts on dealing with team and projects over the comments below. This is my first micro post, I hope you like it :)