teleren/devto huggingface dataset:
Stuff in my Lab, it Evolves
Published: 2022-05-27 20:51:10

I realized recently I haven't written much.  Subject matter came to mind about specific situations, or recent experiments, but then I thought why not just talk about the Lab.  It's constantly changing and evolving, and besides, it will be a fun thing to drone on about.

One of my main philosophies is keeping things as simple as possible, to the lowest common denominator.  Considering I work with Kubernetes, with its massive amounts of abstractions, you'd think this is a paradox. These philosophies, or tenets, or principals, whatever you'd like to call them, will sometimes pop in my head as simple sentences.  "Keep it simple".  "Follow the convention".  You get the idea.

Years ago my lab was a mess. For a living, I build stuff. Sometimes it was building Linux servers, or network services. Sometimes building networks themselves.  Sometimes it was building cloud architecture.  So I had to decide, what did I want out of my lab?

I wanted a quick way to test VMs.  New version of Debian released?  Ok, spin up a small vm and test it out.  I wrote some scripts to call qemu-kvm on the commandline, made a dedicated routed vm-only network and connected it with a virtual switch, namely OpenVSwitch.  These scripts were normally ansible and/or bash.  There is not much these scripts do that one cannot get out of libvirt tools these days.  My tooling was just born before libvirt was popular and matured.

This worked for a great while, but again, introduce Kubernetes.  It is by it's very nature an affront to my minimalist habits!

So the next great step? K3s.  I could run the very same guest VMs I have always, pop k3s on them and now, BOOM, they're a single-node cluster. This also works well, because one can create automation that spins up the vms, installs k3s and then applies manifests or other api-like behavior.  The whole stack can spin up onsite, and with a bit of tweaking, under your favorite cloud provider.

Recently it's evolved even further.  Sometimes I need not only a minimal cluster of 1-2 nodes, but an ephemeral one, something that will not live long.  Spin up a cluster, run some experiment, or QA-like operation, capture result data, then destroy everything.  This may just be peak-minimalism.

So now I use k3d and skip the guest VM middle man. OR get this, maybe run k3d inside the VM, if for some reason the single-node-lab-in-a-box needs to be fungible.  

Some people run clusters of huge boxes, or massive datacenters filled with physical machines, or even clusters with thousands of nodes.  Not me, I'll have dozens of optimized clusters and guest VMs in my lab, along with their resulting data, configs, backups, and the automation to create it all over again if needed.
Becoming a JavaScript Code Warrior
Tags: javascript, challenge, webdev, codewars
Published: 2022-05-27 20:46:54

Today I'm starting my journey to becoming a JavaScript Code Warrior on [CodeWars](https://www.codewars.com/).

For the next 30 days I will be solving 3 coding challenges, or _kata_, a day, as well as writing 3 possible solutions for each _kata_ solved. The first solution will be the simplest and most readable, followed by an intermediate one and ending with the most complex or advanced solution, which will often be a one-liner. It should go without saying, but all solutions will be written in JavaScript. 

Each day, I'll write a post discussing the _kata_ of the day where I break down the problems using the P.R.E.P. technique. P.R.E.P. stands for **P**arameters, **R**eturns, **E**xamples and **P**seudo Code and is an effective technique to use when solving coding challenges, especially for beginners who struggle with this. Of course I will also provide the 3 solutions mentioned above, with details on each of the implementations. 

---
**Important note:**
I debated very heavily on the ethics of writing these posts, since I am aware they can be used for cheating purposes, which is against CodeWars' Code of Conduct - rightfully so. In fact, the Code of Conduct also discourages sharing solutions on GitHub, since it makes it easier for Code Warriors to look for a solution rather than putting in the work to complete the challenge themselves.

However, while I understand their very valid concern, my posts will be focusing more on the process of solving the challenges and different approaches that can be taken, instead of just simply providing the solutions. These posts are for those of you that get stuck when trying to solve a challenge, have no idea how to go about breaking down the problem and/or are having issues understanding some of the (more complicated) alternative solutions that are provided after solving a challenge. 

That said, I do HIGHLY encourage you to try to solve/understand the challenge yourself first and if you get really stuck, these resources are here to help you get unstuck. 

---
Connect with me on ...
[Twitter](https://twitter.com/Nat_A_Number) 
[GitHub](https://github.com/NatGeyzenTech)
Secure your go REST Api in Docker using Letsencrypt
Tags: go, docker, letsencrypt
Published: 2022-05-27 20:44:29

I recently had to figure this out and could not find a good resource, I hope this is the first one then.
<br>
<br>

## How to set up HTTPS for a Go (Gin) REST API using Docker and Letsencrypt
 
### What is used (what you need to install):
1. [Go](https://go.dev/)
2. [Gin](https://gin-gonic.com/)
3. [Docker](https://www.docker.com/)

### Source code for the demo Go REST API:
```go
package main

import (
	"net/http"
	"github.com/gin-gonic/gin"
)

func setupRouter() *gin.Engine {
	r := gin.Default()
	r.GET("/ping", func(c *gin.Context) {
		c.JSON(http.StatusOK, "pong")
	})
	return r
}

func main() {
	r := setupRouter()
	r.Run(":80")
}
```
## How to encrypt it using letsencrypt
1. Add `"github.com/gin-gonic/autotls"` to your imports.
2. Open a goroutine for the run on port 80 to prevent blocking the thread while still enabling access via http:
Change:
```go
r.Run(":80")
```
To:
```go
go r.Run(":80")
```
3. Add the option to access the service via ssl:
```go
m := autocert.Manager{
	Prompt:     autocert.AcceptTOS,
	HostPolicy: autocert.HostWhitelist("domain.com"),
	Cache:      autocert.DirCache("/var/www/.cache"),
}
autotls.RunWithManager(r, &m)
```
You have to enter your domain instead of "domain.com"

## Dockerize it
### Dockerfile:
```dockerfile
FROM golang:latest

WORKDIR /

COPY . .

EXPOSE 80

EXPOSE 443

ENV GIN_MODE=release

VOLUME ["/var/www/.cache"]

CMD [ "go","run", "main.go" ]
```
### You should also add a volume to docker-compose because you will be rate limited by letsencrypt if you request to many certificates
```docker-compose
go-backend:
  build:
    context: ./go-backend
    dockerfile: Dockerfile
  ports:
    - 80:80
    - 443:443
  container_name: go-backend
  volumes:
    - certcache:/var/www/.cache
```
Here the gin project is located in `./go-backend` which might be different for your project. The important part is that the volume is created at `/var/www/.cache` to prevent to many requests to letsencrypt.

## Final notes:
If you want to encrypt your api and make it accessible using https, it might be a good idea to prevent using http. This would be especially important if you send passwords or other sensitive data to or from the server via your api. In this case you should remove this from your go code:
```go
go r.Run(":80")
```
You also should close (not open) port 80 in your Dockerfile and in docker-compose because they are not needed.

### Full go code:
```go
package main

import (
	"github.com/gin-gonic/autotls"
	"github.com/gin-gonic/gin"
	"golang.org/x/crypto/acme/autocert"
	"net/http"
)

func setupRouter() *gin.Engine {
	r := gin.Default()

	r.GET("/ping", func(c *gin.Context) {
		c.JSON(http.StatusOK, "pong")
	})
	return r
}

func main() {
	r := setupRouter()
	go r.Run(":80")
	m := autocert.Manager{
		Prompt:     autocert.AcceptTOS,
		HostPolicy: autocert.HostWhitelist("domain.com"),
		Cache:      autocert.DirCache("/var/www/.cache"),
	}
	autotls.RunWithManager(r, &m)
}
```
My coding journey
Published: 2022-05-27 20:32:26

I have been doing the Odin project for a little over two months. It is challenging, but I expected no less. 
My interest in programming started in 2004/5. I was on an electronics course and we were programming a basic counter. I was intrigued. I thought nothing of it for a few years , and then decided I want to learn. I tried Java, but had difficulty setting up the programming environment. I didn't know of online help forums - this was about 2008. I bought a book on Python, but didn't get very far.
Fast forward to 2022, and I started googling on how to learn, and Freecodecamp and the Odin Project kept coming up. 
I decided to try Freecodecamp, and then Odin Project. The latter felt like a better fit, so I pursued that .
I am currently in the Javascript section of Foundations, and progress is slow, but still moving forward . I am planning on going down the Ruby on Rails path . I hope to make a career of programming.
Unlock | Made with Next JS
Published: 2022-05-27 20:22:45

![Unlock | Made with Javascript | Next JS](https://res.cloudinary.com/madewithjavascript/image/upload/v1652960551/large_unlock_made_with_next_js_f6e62ffbbe.png "Unlock | Made with Javascript | Next JS")


### Unlock is a protocol which enables creators to monetize their content with a few lines of code.

> Unlock has created the first-ever mechanism for recurring subscriptions using membership NFTs. This upgrade to Unlock Protocol paves the way to replace legacy subscription systems that use centralized payments with a decentralized Web3 model.
> 
> ### Connect with your 1000 true fans
> - For creative communities and the humans who build them
> 
> - Create memberships and sell access NFTs in minutes
> 
> - Token-gating, memberships, ticketing, and more
> 
> - Open-source, community governed

## Check out more such amazing projects on our website

[Made with Javascript](https://madewithjavascript.club)

## Want us to feature your project

[Submit your Project to Made with Javascript](https://madewithjavascript.club/submit-project)


You can also write to us for any of your queries at:

[Email Made with Javascript](mailto:madewithjavascript@gmail.com)

## Project already shared on our social media handles.

| SocialMedia | SharedLink |
| ----------- | ---------- |
| Twitter | [Unlock on Twitter](https://twitter.com/withjavascript/status/1530282141141061634?s=20&t=RqOciePpU4urqJZNMR7iKA)
 |
| Medium | [Unlock on Medium](https://medium.com/@madewithjavascript/unlock-made-with-next-js-602c10cd1f7c)
 |
| Facebook | [Unlock on Facebook](https://www.facebook.com/madewithjavascript/posts/pfbid036726fWoPirXbdsoLmaX9DTtgEicKazZuyQ2rFQBHNnp17pXMmYgc6bdwbtGzMb7gl)
 |
| Tumblr | [Unlock on Tumblr](https://madewithjavascript.tumblr.com/post/685436089163481088/unlock-made-with-next-js-unlock-is-a-protocol)
 |
| LinkedIn | [Unlock on LinkedIn](https://www.linkedin.com/feed/update/urn:li:activity:6936048569057501184)
 |


Filled Under:

 - [Made with Javascript](https://madewithjavascript.club)    
 - [Made with Next JS](https://madewithjavascript.club/categories/next-js)

Make sure to give this post ❤ 50 ❤ hearts, click the 🦄 unicorns 🦄 and follow 👉 @madewithjavascript 👈 for more such awesome showcases. Show you love for the people who have worked so hard!
What is Amazon EKS Connector ?.
Tags: aws, kubernetes, eks, connector
Published: 2022-05-27 20:20:54

You can use `Amazon EKS Connector` to register and be a part of any conformant Kubernetes cluster to AWS and visualize it in the Amazon EKS console. You can see the status, configuration, and workload in the Amazon EKS console after a cluster is connected. You can use this feature to view connected clusters, but you can't control them.


![EKS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jc01ym98i81b5a9c2z0w.jpg)

The Amazon EKS Connector can connect the following kinds of Kubernetes clusters to Amazon EKS. The Amazon EKS Connector is also an open supply project on Github. 

- The clusters are on-premises.
- There are clusters on Amazon Elastic Compute Cloud.
- Other cloud providers have managed clusters.



## Amazon EKS Connector considerations

Understand the following before using Amazon EKS Connector:


- You should have `administrative privileges` to the Kubernetes cluster to join the cluster to Amazon EKS.
- Before connecting, the cluster must have Linux worker nodes present. ARM worker nodes aren't supported.
- Outbound access to the `ssm.` and `ssmmessages` is required for you to have worker nodes in your cluster.
- Up to 10 clusters can be connected by default. The service quota console can be used to request an increase. 
- Only the Amazon EKS `RegisterCluster`, `ListClusters`, `DescribeCluster`, and `DeregisterCluster` are supported by external Kubernetes clusters.
- Permissions are needed to register a cluster.

1. eks:RegisterCluster
2. ssm:CreateActivation
3. ssm:DeleteActivation
4. iam:PassRole

- Permissions are needed to deregister a cluster.

1. eks:DeregisterCluster
2. ssm:DeleteActivation
3. ssm:DeregisterManagedInstance

## Required IAM roles for Amazon EKS Connector

The following two roles are required for using the Amazon EKS Connector.

- The service-linked role of amazon EKS connector is created when you register the cluster.
- The agent IAM role of Amazon EKS Connector have to be created manually.

To enable cluster and workload view permission for another user, you must apply the `eks-connector` and Amazon EKS Connector cluster roles to your cluster. 


Thanks for reading my article till end. I hope you learned something special today. If you enjoyed this article then please share to your friends and if you have suggestions or thoughts to share with me then please write in the comment box.

Above blog is submitted as part of 'Devtron Blogathon 2022' - https://devtron.ai/
Check out Devtron's GitHub repo - https://github.com/devtron-labs/devtron/ and give a ⭐ to show your love & support.
Follow Devtron on LinkedIn - https://www.linkedin.com/company/devtron-labs/ and Twitter - https://twitter.com/DevtronL/, to keep yourself updated on this Open Source project.
School Morning Routine | Made with Next JS
Published: 2022-05-27 20:13:47

![School Morning Routine | Made with Javascript | Next JS](https://res.cloudinary.com/madewithjavascript/image/upload/v1652960262/large_school_morning_routine_made_with_next_js_93eddc29d6.png "School Morning Routine | Made with Javascript | Next JS")


### Get ready for the day without all the chaos

> An app to help parents get their kids ready for school without all the chaos. It's a todo list crossed with a game and kids love it. It makes mornings peaceful, easy and even a little bit fun. So you can enjoy your family mornings together.
> 
> 

## Check out more such amazing projects on our website

[Made with Javascript](https://madewithjavascript.club)

## Want us to feature your project

[Submit your Project to Made with Javascript](https://madewithjavascript.club/submit-project)


You can also write to us for any of your queries at:

[Email Made with Javascript](mailto:madewithjavascript@gmail.com)

## Project already shared on our social media handles.

| SocialMedia | SharedLink |
| ----------- | ---------- |
| Twitter | [School Morning Routine on Twitter](https://twitter.com/withjavascript/status/1530280085332402181?s=20&t=gUCILObg5KLyDY1NGh21jw)
 |
| Medium | [School Morning Routine on Medium](https://medium.com/@madewithjavascript/school-morning-routine-made-with-next-js-56cb4f8fc3e5)
 |
| Facebook | [School Morning Routine on Facebook](https://www.facebook.com/madewithjavascript/posts/pfbid02fxBVRtpFXL2yf4Pm9EafTqbcZHTnh4uQx9fzFzfsxWe4ekLKMzaozizvKVaH1WUxl)
 |
| Tumblr | [School Morning Routine on Tumblr](https://madewithjavascript.tumblr.com/post/685435649985298432/school-morning-routine-made-with-next-js-get)
 |
| LinkedIn | [School Morning Routine on LinkedIn](https://www.linkedin.com/feed/update/urn:li:activity:6936046056216412160)
 |


Filled Under:

 - [Made with Javascript](https://madewithjavascript.club)    
 - [Made with Next JS](https://madewithjavascript.club/categories/next-js)

Make sure to give this post ❤ 50 ❤ hearts, click the 🦄 unicorns 🦄 and follow 👉 @madewithjavascript 👈 for more such awesome showcases. Show you love for the people who have worked so hard!
Going Back to the Basics
Tags: beginners, discuss, career, watercooler
Published: 2022-05-27 19:52:04

I recently attended my daughter's middle school band concert.  Since the kids are very early in their journey of learning an instrument, the school had requested that some senior high school band members sit in with them.  This gave me a flashback to my high school band days as the first chair trumpet player that thought I was better than I really was.  I was that person that got to sit in with the middle school band playing Hot Cross Buns.  It reminded me how fun it was to play very basic music and concentrate on playing beginner music as well as I possibly could.

Thinking about how fun it is to go back to basics made me realize something interesting that I have done during my tech career.  I have presented "Intro to Docker" in multiple talks, presentations and conferences.  The slides and demos have changed some over the years but the basic material is the same.  It has been recorded multiple times and people can go back and watch the recordings versus me doing the talk again in a live setting.  I have also attended multiple conference presentations that are centered around Docker or Container basics.

Why would I attend a talk that is very similar to material I have presented multiple times?  Well, to be the person in the back of the room that can't wait to ask a question that I already know the answer.  That is why.  There is always one of those people in every conference audience.  It might as well be me.  I am just kidding.  The real reason I go to conference talks that I think I am an expert about the subject is to show me that I can always learn something new.  I have picked up little nuggets of wisdom from every session that I have attended.

It might be as simple as how the presenter organizes the slides.  In one talk I learned that you don't have to include the entire id of a running container when issuing commands.  I watched the presenter doing a demo clean up his running containers by issuing a stop command using the first three characters of the id.  In the middle of the presentation I blurted out a question without waiting my turn "wait, you can do that?", which I admit makes me that person at the conference as well.

Too many times I think as technologists we constantly strive to work on or build something using the latest, greatest bleeding-edge technology.  There is something satisfying about seeing if you can make a java app as clean and simple as possible even if you have created hundreds of them in the past.  Take some time to review something that you think you are an expert.  Think of it as a coder therapy session.  Odds are you are going to enjoy it and probably learn something along the way.

<a href="https://dev.to/leading-edje">
  ![Smart EDJE Image](https://dev-to-uploads.s3.amazonaws.com/i/5uo60qforg9yqdpgzncq.png)
<a/>
Running Docker without Docker Desktop
Tags: docker
Published: 2022-05-27 19:51:36

---
title: Running Docker without Docker Desktop
published: true
description: The good parts of Docker without the terrible UI
tags: docker
canonical_url: https://www.swyx.io/running-docker-without-docker-desktop
---

## TL;DR

1. `brew install colima` ([colima](https://github.com/abiosoft/colima/) replaces the docker/dockerd binary)
2. Install the right `docker-compose` binary for your chipset from [the releases page](https://github.com/docker/compose/releases)
	- `sudo curl -L https://github.com/docker/compose/releases/download/v2.5.1/docker-compose-darwin-aarch64 -o /usr/local/bin/docker-compose` for M1 Macs
	- `chmod +x /usr/local/bin/docker-compose` to let it execute

You should now be able to run `docker-compose up` as per normal but without needing Docker Desktop.

## Context

Although I am [known](https://twitter.com/swyx/status/1330900941747277826) for loving Docker (the containerization technology), I am also known for being a critic of Docker Desktop (the desktop UI client for Docker) for its poor performance:

{% twitter 1523368365728837633 %}

Docker Desktop is Docker (the company)'s first wedge into getting you to run proprietary software, so Docker strongly guides you to download it as the only way to get started:

<a href="https://www.docker.com/get-started/"><img src="https://user-images.githubusercontent.com/6764957/170769916-89b00431-4f4b-4c5a-85b7-5c73fd07a127.png" width=200 /></a>

In fact, new users can go pretty far without even realizing that you don't need Docker Desktop to run the Docker daemon. I've asked multiple people how to do it and nobody had a good answer, or at least, nobody had an answer that worked on M1 Macs, until now.

For my [2022 New Mac Setup guide](https://www.swyx.io/new-mac-setup/) I resolved to figure it out once and for all, and what you see here is what I ended up with!
Where can I find regex to prevent code injection?
Tags: help, discuss, security
Published: 2022-05-27 19:46:22

Recently, I discuss a lot about security, especially about code injection. And in these discussions, we talked a lot about regex are the only way to check if a string contains malicious code.

Curious as I am, I tried during hours to find some regex which can check if the string contains *(one of them, not a big regex which can check all the cases)* : 
- SQL
- HTML 
- Javascript

I only find for SQL, but it was on a random comment online, not even a post.

So, do you know where can I find these kind of regex? 

Thanks a lot for your help!
Feedback Form Template Feedback
Tags: python, html, template, discuss
Published: 2022-05-27 19:35:27

So [repl.it](https://replit.com) is hosting a template jam, and I decided to post a feedback form in Python where you automatically get the filled in responses in your email, and it also has a cooldown for each device (so nobody can spam it).

Here is the link for the template:
https://replit.com/@VulcanWM/feedback-form#README.md

How much would you rate this from 1-10? Does it have any chance of winning?
How can I improve the template?
Do you have any other template ideas?