teleren/devto huggingface dataset:
Working with Go Embed
Tags: go, react
Published: 2021-05-09 07:26:53

With the release of Go-1.16, Go released a core package called _embed_. This post will cover the various ways we can use Go Embed and build applications with ease.

**Building a Web Application**

Golang being a versatile language, it is very much capable of being used to write server for web applications.
We would be using React as the front-end for this and expose the full scale web application from a single Golang binary.

_App Structure_
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r6z9ozfev5nauk58klr5.png)
 
In the Project root, we maintain the server in the root and expose the client from within the client folder.

`main.go` --> main driver of the application from which the server is started and the client is exposed statically

`main.go`
```
//go:embed client/build
var content embed.FS
```
Golang 1.16 comes with the go:embed directive.
We just specify the target folder which we want to map to our server.

Exposing the app on the root of your running server
```
mux.HandleFunc("/", rootHandler)
```
Create a function called `rootHandler`.
`rootHandler` exposes the static content onto the `/` endpoint.
```
func rootHandler(w http.ResponseWriter, req *http.Request) {
	upath := req.URL.Path
	if !strings.HasPrefix(upath, "/") {
		upath = "/" + upath
		req.URL.Path = upath
	}
	upath = path.Clean(upath)
	fsys := fs.FS(content)
	contentStatic, _ := fs.Sub(fsys, "client/build")
	if _, err := contentStatic.Open(strings.TrimLeft(upath, "/")); err != nil {
		req.URL.Path = "/"
	}
	http.FileServer(http.FS(contentStatic)).ServeHTTP(w, req)
}
```

This is enough for exposing the static build of the react app via a Golang server.

Building the Golang Binary
```
GOOS=linux go build -o server main.go
```
Running the server binary
```
./server
```

Now once this is tested on a localhost, we can build a Docker Image for this WebApp.

_Dockerfile_
```
FROM alpine:latest

ADD server /opt/app/

WORKDIR /opt/app/

RUN ls -lrt

EXPOSE 9191

CMD ["./server"]
```

`Docker Build and Run Command`
```
docker build -t server:v1.0 .
docker run -d -p 9000:9191 server:v1.0
```


Overall we can say that introduction of go:embed has made some previous complicated tasks much simpler. We can now expose a full fledged web application with a single golang binary and expose it on any platform.

To read more about go:emebed use the following references:

* [Golang Docs](https://golang.org/doc/go1.16#library-embed)
* [Go-Embed](https://golang.org/doc/go1.16#embed)
Day 56 of 100 Days of SwiftUI
Tags: swift, 100daysofcode
Published: 2021-05-09 07:18:36

I just completed day 56 of 100 days of SwiftUI. Today I worked on the challenges for the BookWorm app. I added a default selected genre to the app when adding a book. I added a date attribute to the book model and  I also changed the book title colour to red for books with a one-star rating

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6japryy2ypw1q3bc4u9p.png)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1362ubdtj3f9n4vhstsb.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6l55q6ikt94magicfyif.png)
Appending Data in Pandas (+Numpy) When Working with Two Data Sets That Have the Same Attributes (Columns)
Tags: python, datascience
Published: 2021-05-09 06:34:55

#Explanation
>>>Let's assume we have 2 sets of data in 2 different csv files. For example, data that includes petal length, width, thickness, etc. for a certain kind of flower that can be found in 2 colors. 

>>>Let's assume that these 2 colors are red and white.

>>>While they're of different colors, any given flower would have the same attributes, except for the color. So, we can make that distinction in the data set that combines both.

##Importing and Parsing
>>>import numpy as np
import pandas as pd

>>>red_df = pd.read_csv('red_flowers.csv')
white_df = pd.read_csv('white_flowers.csv')

##We'll create a dataframe for both color arrays
>>>color_red = np.repeat('red', red_df.shape[0])
color_white = np.repeat('white', white_df.shape[0])

##Then, we'll add arrays to boh dataframes by setting a new column named "color" to the corresponding array.
>>>red_df['color'] = color_red
white_df['color'] = color_white

##Then, we'll append the dataframes and view the file to make sure we've done it successfully.
>>>flowers_df = red_df.append(white_df)
flowers_df.head()

##Then, we'll save the new combined dataframe to a .csv file.
flowers_df.to_csv('flowers_edited.csv', index=False)

##Finally, we can check the file to make sure the two datasets were combined successfully by making sure that the rows are the sum of the two sets and that the columns are the initial number of columns in each data set + 1.

>>>flowers_df.shape


_I.e: If each data set had 12 columns, and the red flowers set had 55, while the white flowers set had 45 rows, then the flowers_df.shape attribute should result in:

>>>(100, 13)
Promises in Javascript
Tags: javascript, webdev, programming
Published: 2021-05-09 06:28:32

A **Promise** represents the state of an asynchronous operation. This asynchronous operation can be anything i.e fetching data from an API, reading contents from a file, etc. 

Before promises we had callbacks, but they had fewer capabilities and lead to a sloppy code. When dealing with multiple callbacks, our code will become a callback hell which becomes difficult to manage.  

A Javascript Promise consists of four states:
1. Fulfilled: The operation was completed successfully.
2. Pending: The operation isn't completed, it's still in process.
3. Rejected: The operation is failed.
4. Settled: The operation is either fulfilled or rejected.


A promise can be created by using 
`Promise` constructor.

```javascript
const isNumEven = (num) => new Promise((resolve, reject)=> {
  if(num % 2 === 0) {
    resolve(true)
  } else {
    reject(false)
  }
})
```


Now the above-created promise can be used as

```javascript
isNumEven(5)
  .then(res => console.log(res))
  .catch(err => console.log(err))          
```


The `then` handler is invoked when the promise is fulfilled while the `catch` handler is invoked when the promise is rejected.

Here in this case the `catch` handler is invoked as the number we have passed to the function is not even.

**Chaining Promises**

When the result of a promise is another promise, we have to chain them to get the results.

```javascript
isNumPrime(5)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.log(err))           
```

This method of handling asynchronous operations looks fine when we have 2 to 3 promises but it gets unmanageable when there are more than that. Then `async await` comes into the picture. They help you to handle multiple promises very easily.

That's it for now. Thanks for making it to the last. Let me know any feedback or suggestions you have for this article. Also, let me know if you want me to write on `async await`.
Add open with Neovide Option in Windows 10
Tags: neovide, neovim, windows
Published: 2021-05-09 06:01:04

---
title: Add open with Neovide Option in Windows 10
published: true
description: Add open with Neovide Option in Windows 10
tags: neovide, neovim, windows
//cover_image: https://direct_url_to_image.jpg
---

1. Open Notepad or your preferred text editor

2. Copy the script below
```
Windows Registry Editor Version 5.00
; Open files
[HKEY_CLASSES_ROOT\*\shell\Open with Neovim]
@="Edit with Neovim"
"Icon"="C:\\Program Files\\neovide\\neovide.exe,0"
[HKEY_CLASSES_ROOT\*\shell\Open with Neovim\command]
@="\"C:\\Program Files\\neovide\\neovide.exe\" \"%1\""

; This will make it appear when you right click ON a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\shell\neovide]
@="Open Folder as Neovim Project"
"Icon"="\"C:\\Program Files\\neovide\\neovide.exe\",0"
[HKEY_CLASSES_ROOT\Directory\shell\neovide\command]
@="\"C:\\Program Files\\neovide\\neovide.exe\" \"%1\""

; This will make it appear when you right click INSIDE a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\Background\shell\neovide]
@="Open Folder as Neovim Project"
"Icon"="\"C:\\Program Files\\neovide\\neovide.exe\",0"
[HKEY_CLASSES_ROOT\Directory\Background\shell\neovide\command]
@="\"C:\\Program Files\\neovide\\neovide.exe\" \"%V\""
```

3. Paste it in the text editor

4. Save the file as `neovideOpenFolder.reg`

5. Run the file.

Now you can have a nice open with Neovim option.

If it doesn't work check the paths of Neovide in the script.
You can also change Neovim to Neovide if you like.
Patch me up.
Tags: javascript, async, patch
Published: 2021-05-09 05:57:08

Let's talk about Lilo & stitch, we'll get to code later. First of all did you know lilo is Hawaiian for lost, so the title of most peoples beloved childhood show means lost and put together.

There are 5 main methods to use when dealing with javascripts fetch API's GET, POST, PATCH, PUT & DELETE. But today we are just focusing on the PATCH method. But first what even is a fetch API, since you asked I guess I can give you a brief rundown. Well .fetch() is a JS method that allows us to retrieve data from servers and reconfigure it for our own uses. API's on the other hand are Application Programming Interfaces. 

The different method like GET and POST are ways to retrieve and send data to the server. PATCH is not so different it modifies an existing resource not unlike PUT. But PATCH can send back specific changes back to the resource. To go deeper it shares a set of instructions on how the resource should be changed.
Starship, because it's too damn cool 
Tags: rust, cli, productivity, programming
Published: 2021-05-09 05:31:27

This is more of an appreciative post for [starship](https://starship.rs/), an amazingly cool and customizable prompt for any shell. And the reason why it is so amazing is because even by default it has too many cool features while being super fast.

Just to show how it looks by default for rust and python:
![Default](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lnwrb9f19g7k07jvnwcu.png)

We can see that it identifies what kind of project it is while giving information about which branch we are on, and which version of toolchain we are using.

It is not just limited to what comes by default, and its extensibility and ease of use is what is amazing about it. I use it for my personal projects as well as in my office system to inject information into prompt (like getting to know which versionset I am using).

And special thanks to Chris Rose for introducing me to this.
Renaming a Specific Column in Pandas
Tags: python, datascience
Published: 2021-05-09 05:23:33

##Importing and Parsing
>>>import pandas as pd
>>>df = pd.read_csv('file_name.csv')
>>>df.head()

##Check the column's name you want to change, and then:
>>>df.rename(columns={'old_name':'new_name'}, inplace=True)
49 Days of Ruby: Day 43 -- A Detour Into Version Control
Tags: ruby
Published: 2021-05-09 04:34:39

---
title: 49 Days of Ruby: Day 43 -- A Detour Into Version Control
published: true
description: Join us on a 49 day learning journey through Ruby!
series: 49 Days of Ruby
tags: #ruby
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/9m73qaetuse3nm3y3it8.png
---

**Welcome to day 43 of the 49 Days of Ruby! 🎉**

Today's topic is not strictly Ruby-related, but it is important when you start working with software development.

Have you noticed that there are often versions attached to applications? Sometimes it is version 1.0.0, othertimes it is version 2.1.4. What do those numbers mean?

Those numbers come from a concept called [Semantic Versioning](https://semver.org/).

It is a way to let other people know about the *kind* of changes in a new release of an application.

The way it works is like the following:

> MAJOR.MINOR.PATCH

The first number is the **major** version. This number increments when something changes that breaks the compatibility with existing earlier versions.

The second number is the **minor** version. This number increments when something is added or changed to the software, but it does not break compatibility with earlier versions.

The last number is the **patch** version. This number increments when a minor bug fix is released, for example, or something else that does not impact the way the software is used by the user.

Ruby in December of 2020 release version 3.0.0 of the language. That was a **major** release. The incrementing of the first number in the version is a warning to developers that, while they may enjoy the new features added, their old code may no longer work.

The latest stable release of Ruby as of this writing is 3.0.1. That means that recently a **patch** version was released. A developer can assume that, if the language follows semantic versioning, nothing about the way they use the language changed, and only a bug fix or security vulnerability was addressed.

Today, as you explore software, pay attention to those three numbers, and try and figure out what it is telling you about the software. Not every software maintainer follows semantic versioning, but for those that do, it offers a quick way for other people to know what is going on with a glance.

**Come back tomorrow for the next installment of 49 Days of Ruby! You can join the conversation on Twitter with the hashtag [#49daysofruby](https://twitter.com/hashtag/49daysofruby).**
Diving into DevOps
Tags: aws, devops
Published: 2021-05-09 02:44:33

Tomorrow is the beginning of a deep dive into DevOps.

My career is pivoting into DevSecOps. I am strong and certified on the "Sec" (AWS Security Specialty; Azure Security Engineer; CISSP).  I wish to be just the same for DevOps.

The plan:-
- AWS DevOps Engineer Professional - Q2
- Azure Developer Associate - Q3
- Node.js - Q4 or Q1 2022

To kick of AWS DevOps Engineer Professional Certification:-
- AWS free tier plus AWS credits compliments of AWS Community Builders
- AWS DevOps Professional Course by Stephane Maarek
- Practice Exams by Jon Bonso
- Cloud9 IDE on AWS

May 9 - 14 - The first 5 hours of Stephane's course.

I will update as I proceed.

Exam is scheduled for early July - exam voucher compliments of AWS Community Builders
Website Accessibility: How can I make sure screenreaders interpret the text in the way I intend?
Tags: html, webdev, a11y, watercooler
Published: 2021-05-09 02:37:30

How can I make sure screenreaders always read the right thing?

As example, if I have:
```html
<p>I want a cheeseburger w/ tomato and lettuce.</p>
```
the screenreader may say `"I want a cheeseburger W slash tomato and lettuce."`.
On a bigger scale, you might wright some text as a bunch of symbols, but a screenreader may be confused, and read the symbols, instead of what the intended meaning is.

Such as, if I head this JSON:
```json
{
  "code": "tLk5902cqC1583r",
  "expiration": "03/03/2022"
}
```
How could I have it read off `"JSON that reads a code of T capital L k 5 9 0 2 c q capital C 1 5 8 3 r, and an expiration date of March third, twenty twenty-two."` instead of the possibility of reading `"Opening brace, code, colon, tLk5902cqC1583r, expiration, ..."`?


Going back to earlier, how can I do something in this fashion?:
```html
<p>I want a cheeseburger <annotation readas="with">w/</annotation> tomato and lettuce.</p>
```
<br/>
<br/>
...I know, the realistic thing to do would be to design a the webpage better, use `"with"` instead of `"w/"`, etc... and same for the other example.
Though, there may be cases where this isn't possible, which is when I'm thinking of using this.
<br/>
I know `<img/>` has `alt`, but what do other elements have, in terms of capabilities for helping screenreaders? Can `alt` be used on anything to help screenreaders read it? If not, how do I do what I said I wanted to achieve? ${Etc...}?
<br/>
<br/>
<b><h1><b>
<center>Thanks!<br/>Cheers!</center>
</b></h1></b>
My javascript / tech / web development newsletter for 2021-05-08 is out!
Tags: javascript, tech, webdev, discuss
Published: 2021-05-09 02:08:13

---
title: My javascript / tech / web development newsletter for 2021-05-08 is out!
published: true
description: A roundup of all the best javascript, tech and web development links posted to my linkblog in the past week
tags: javascript, tech, webdev, discuss
---
In this week’s edition:

Audacity, Intel & TSMC, RSS, Apple anti-trust, Linux bad patches, Privacy & AdTech, Neuralink, Apple podcasts, Twitter Spaces & TipJar, Deno, celebrities, ESM, crypto all the things & a cool tutorial

https://markjgsmith.substack.com/p/mark-smiths-newsletter-08-05-2021

Would love to hear any comments and feedback you have.

[@markjgsmith](https://twitter.com/markjgsmith)
Redis Nativo no Windows e Windows Server
Tags: redis, windows, windowsserver, braziliandevs
Published: 2021-05-09 01:55:14

É bem provável que você já conheça o [Redis](https://redis.io) e todas as suas possibilidades, se não conhece,  vale a pena dar uma olhada na documentação.
Você pode instalar em linux, usando docker ou usar em algum serviço da nuvem, mas sabia que existem opções de instalar nativamente como um serviço em um servidor windows ?

Acredito que a maioria não vai precisar usar em um servidor windows, mas uma vez precisei usar em um ambiente em que linux não era uma opção (acontece rs) e o Docker EE para windows server não suporta imagens baseadas em linux (somente de forma experimental).

A microsoft possuía um port do redis para windows, mas ele foi descontinuado na versão 3 https://github.com/microsoftarchive/redis

Porém encontrei dois projetos: um open source e outro pago.

O primeiro deles é um [fork](https://github.com/tporadowski/redis/) desta versão da Microsoft, https://github.com/tporadowski/redis, que oferece compatibilidade com a versão 5, e a versão 6 está em desenvolvimento.

O segundo é o [Memurai](https://www.memurai.com), uma versão paga com direito a suporte, que oferece uma versão gratuita para desenvolvimento.

Como eu disse acima, acredito que será raro a necessidade de usar em um server windows, ainda mais com Docker, nuvem etc...
Mas eu precisei e usei por mais de dois anos, e confesso que atendeu bem, em um cenário tranqüilo no qual a aplicação tinha cerca de 2 mil acessos simultâneos.

Mas como tudo na área de TI "depende" cabe uma avaliação e testes do seu cenário, escolher o que melhor atende.

E você já testou alguma destas opções? Deixe aqui nos comentários...

E obrigado pela leitura =)
picoCTF 2021 -The Numbers writeup-
Tags: security, ctf, showdev, linux
Published: 2021-05-09 00:07:54


# Description
The numbers... what do they mean?

# Solution
When the image is opened, the following image is displayed.
<!--画像を開くと下記のような画像が表示される．-->

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

Since { appears in the seventh character of the image, we can a find out that the flag format is picoctf{***}. This means that 16→P, 9→I, 3→C, 15→O, 3→C, 20→T, and 6→F are used.
And from this rule, we can assume that Letter Number Cypher (A1Z26), which converts numbers directly into alphabets, is used.
<!--画像を見たところ{が7文字目にあらわれているため，フラグのフォーマットであるpicoctf{***}になっていると考えられる．そう考えると，16→P, 9→I, 3→C, 15→O, 3→C, 20→T, 6→Fであると考えられ，この規則から数字をそのままアルファベットに変換するLetter Number Cypher(A1Z26)が使用されているとわかる．-->

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

All you need to do is decode A1Z26 with Cyberchef or convert it manually to get the flag.
But don't forget to add {} and type the flag in uppercase.
<!--あとはCyberchefでA1Z26 decodeするか，手動で変換するだけでフラグが手に入る．ただし，{}と大文字でフラグを打ち込むことをお忘れなく．-->

Flag: PICOCTF{THENUMBERSMASON}
My job red flags
Tags: interview, career
Published: 2021-05-11 07:42:32

---
title: My job red flags
published: true
date: 2021-05-09 00:00:00 UTC
tags: interviews,career
canonical_url: https://jhall.io/archive/2021/05/09/my-job-red-flags/
---

As a follow-up from [yesterday’s mail about job interview preparation](https://jhall.io/archive/2021/05/08/reader-question-what-do-you-do-for-interview-prep/), I thought I might share my personal list of red flags and deal-breakers when it comes to applying for jobs. I don’t want to suggest that your list should be the same. I only offer this as food for thought, and to encourage you to think about your own list. Your list is likely to change over time, too, and that’s completely appropriate. If you’re looking for your first job out of school, or if you’ve been laid off and simply need to pay the bills, it can be completely appropriate to take the first job that comes along. So take this with a grain of salt!

1. **[HackerRank](https://www.hackerrank.com/)-style challenges.**

I have nothing against HackerRank or any of its many clones, for fun, for educational purposes, or even for competitive programming. But I believe this type of test has no place in the screening process for engineers for the simple reason that it doesn’t test the skills that matter.

2. **No choice of development environment.**

Most of us have a particular development environment we’re comfortable with. This usually includes an operating system, an editor or IDE, and maybe even a monitor, keyboard, and pointing device. I’m very wary of companies that try to force their choices on these matters upon me. Most frequently this is a company requiring me to use their operating system of choice. Sometimes it’s a rule against bringing your own keyboard into the office.

3. **“Gotcha” interview questions.**

Once while interviewing for a Site Reliability Engineer role for a managed infrastructure company, the CEO asked me the RGB value for yellow, the difference between XHTML and HTML 5, and how long it would take light to travel from my location, through the center of the earth to my [antipode](https://en.wikipedia.org/wiki/Antipodes) and back again. During the interview, I repeatedly said “I don’t see how this relates to the role, but…” I withdrew my application from consideration.

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._