teleren/devto huggingface dataset:
Happy Hacktoberfest! 🎃 - Part 3
Tags: opensource, hacktoberfest, github
Published: 2021-10-27 21:32:47

## Introduction
Continuing from my latest post about Hacktoberfest, I decided to work on another [issue](https://github.com/medusajs/medusa/issues/474) from Medusa's [repo](https://github.com/medusajs/medusa). However, the difficulty level this time far exceeded what I had expected.

## The issue and challenges
The task was to generate an API fixture for the data model returned by Medusa's API. To my surprise, setting up the dev environment was surprisingly challenging compared to the linting issue. I kept running into crashes while running the installation command and didn't know what I was missing. To make it worse, I was overwhelmed by the massive error logs and couldn't go over them to see what I was missing. 

## Requesting assistance
Realizing that I couldn't do this on my own, I hopped on Medusa Discord's channel and began asking for help. I was surprised by the friendliness of the community and how active everyone was, including the developers. I managed to get in touch with one in just a few hours and, thanks to his help, identified the missing packages and finished the installation.

Working on the code was also quite hard. Despite having the instruction, I had to also rely on other people's pull requests to understand what I should do. I spent hours reading through issues with similar tasks and studied the code very carefully, taking advantage of the Discord channel as much as I could to clear up any confusion. In the end, I managed to merged my [pull request](https://github.com/medusajs/medusa/pull/545#event-5458875103) with the help of the developers and a classmate who recently finished a similar issue.

## Conclusion
Working on such a challenging issue was quite an experience. I realized that I still have a long way to go to be more confident in JavaScript, and this issue was a great starting point. With one more issue left to do before Hacktoberfest ends this weekend, I'm excited to see where I will be next.

Cheers!🍻
357686312646216567629137
Tags: maths, dataviz, gephi, datascience
Published: 2021-10-27 21:06:42

## :point_right: Intro

As mentionned in my previous post...

{% post adriens/about-the-collatz-conjecture-neo4j-cypher-184h %}

I'm a big fan of [Numberphile](https://www.youtube.com/channel/UCoxcjq-8xIDTYp3uz647V5A), and recently I felt on this one :

{% youtube azL5ehbw_24 %}

In a few words, the question is :

> *What is the biggest prime number we can build, which has the following property : "each time we remove a digit from the left side we still get a prime number."*

Obviously, the answer is quite straightworward :

> *Yes it does exist, and it is and the biggest one is `357686312646216567629137`. That's all.*

## :grey_question: The questions

After this very appealing and funny question, I wanted to see :

- I want to compute it (and generate some additional stuff)
- What does the structure of the prime numbers ? I mean : what does it look like... as graph ?

## :computer: Compute it

Well as this stage I wanted to create a little `cli` that should

- Take a number of generations as input : the bigger the further I'm looking for such primes
- Draw the output in the console the funny way so we can see the strange thing appear :satisfied:
- Dump a [`graphml`](http://graphml.graphdrawing.org/primer/graphml-primer.html) file as output so we can play with it later

Finally, here is the [JBang!](https://www.jbang.dev/) program you can easily call this way :

```shell
jbang https://github.com/adriens/truncatable-primes/blob/main/BigTruncatablePrimes.java -s 30
```

{% github adriens/truncatable-primes %}

Which looks like that with a maximum number of generations set to `30` :

{% youtube A_LmhD4U2WA %}

At then end of the run, you get a `.graphml`. So we can now play with it.

## :art:Dealing with `Gephi`

[Gephi](https://gephi.org/) is an amazing tool to deal with graphs, for analytics purpose, or simply to produce satisfying artworks.

Then I started to play with it, and produced somes. See below some of my favorites.

## :milky_way: Artwork samples

### Twin `3` and `7` seeded galaxies

![Twin 3 and 7 seeded galaxies](https://raw.githubusercontent.com/adriens/truncatable-primes/main/img/twin-with-labels.png)

### The `3` galaxy

![The "3" galaxy](https://raw.githubusercontent.com/adriens/truncatable-primes/main/img/gephi-neural-3.png)

### Circular layout

![Circular Layout](https://raw.githubusercontent.com/adriens/truncatable-primes/main/img/gephi-circular.png)

### Do your own visualizations

You can use the [ready to use graphml](https://raw.githubusercontent.com/adriens/truncatable-primes/main/LeftTruncatablePrimes.graphml) and make your own visualizations, and contribute them to the repo.

Stay curious, experiment things and have fun.
Cards as Web Components
Published: 2021-10-27 21:03:11

**The Project**

Our group will work to build a web component version of a card. Each card will contain multiple elements: a header, banner, icon, and body, which will be grouped according to topic and displayed accordingly. 

**Considerations**

In completing this project, our group is aware that we must be able to combine and display each element found on the card while taking into account considerations such as adaptive page sizing, scrolling, customization, and correctly grouping the elements on the card. 

Having completed the CTA button from the last project, we are confident that the implementation of action events and state changes will be a strength going into this project, but we are fully prepared to take the necessary steps to familiarize ourselves with concepts that we have not yet worked with - such as accessibility, security, content flexibility and named slots. 

We are exited to begin our work on this project, and look forward to learning more about web components.
Enable API Gateway logs
Tags: aws, serverless, observability, devops
Published: 2021-10-27 20:57:55

---
title: Enable API Gateway logs
series: [Lambda Observability]
published: true
description: Enable API logs
tags: #AWS #Serverless #Observability #DevOps
cover_image: https://www.pawelpiwosz.net/assets/lambdaObservability/sherlock-holmes.jpg
---

## Recap

What did we do so far? We enabled tracing on API and Lambda and we enabled enhanced monitoring for Lambda as well. We should do one more thing in order to start collecting information in proper way

## API logs

By default logs for API Gateway are disabled.

In API service navigate to your API, then `Stages`, `Prod` (if you created the resource from the template), select `Logs/Tracing` tab (yes, you were here before). For the test enable all three settings and change level to `INFO`.

![Enable API logs](https://www.pawelpiwosz.net/assets/lambdaObservability/enableapilogs.jpg)

Trigger your API multiple times to generate logs. After this you should see API logs in CloudWatch.

![Watch API logs](https://www.pawelpiwosz.net/assets/lambdaObservability/apilogs.jpg)

### SAM template

Ok, it is time to add it to our SAM template. But wait! It is not "just add". Unfortunately, we need to rewrite almost whole template.

```yaml
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Description: simple Lambda

Resources: 
  lambdaDemoApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: Prod
      Description: 'Prod stage'
      TracingEnabled: true
      MethodSettings:
      - HttpMethod: '*'
        LoggingLevel: INFO
        ResourcePath: '/*'
        MetricsEnabled: true
        DataTraceEnabled: true

  lambdaFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: simplefunction.handler
      CodeUri: lambdafunction/
      Runtime: python3.8
      Policies:
        - CloudWatchLambdaInsightsExecutionRolePolicy
      AutoPublishAlias: live
      Description: Simple demo function
      MemorySize: 128
      Timeout: 10
      Tracing: Active
      Layers:
        - !Sub "arn:aws:lambda:${AWS::Region}:580247275435:layer:LambdaInsightsExtension:14"
      Events:
        simpleApi:
          Type: Api
          Properties:
            RestApiId: 
              !Ref lambdaDemoApi
            Path: /
            Method: get
```

I redesigned the template, removed part of the `Events` configuration and I created a new resource - `lambdaDemoApi`.

That's all, logs are enabled and all requests will be catched and stored in CloudWatch Logs. Please remember, I enabled here standard logs. There is a possibility to shape logs as you wish or need. We will come back to it. Earlier than you expect!

***

Cover image by <a href="https://pixabay.com/users/422737-422737/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=462957">Hebi B.</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=462957">Pixabay</a>
Simple Music Player With JavaScript in just 10 min.
Tags: javascript, html, webdev, beginners
Published: 2021-10-27 20:33:35



Hi folks in this tutorial you will learn basic DOM elements of 
JavaScript like eventlistner and will provide you a very good essence of JavaScript if you watch carefully you will definitely 
understand and with the use of basic functions you will learn to integrate.

If you like plz subscribe to my channel it will be great help to me. 
Code cheat-is not available only for this tutorial because I don't
saved files after making tutorial 😅. Don't mind plz enjoy above video tutorial. 
  
{% youtube hCgv1cGTUTM %}
Thankyou😊
How I sandboxed 10 students in my bathroom using Docker
Tags: docker, unix, teaching
Published: 2021-10-27 20:30:29

---
title: How I sandboxed 10 students in my bathroom using Docker
published: true
description: A real life usage of containerization.
tags: Docker, UNIX, Teaching
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3mh8i4o7p2opgqzcon4t.jpg
---

I recently had to give an introduction course to UNIX shell and we all know that **the best way to learn is to practice**.
Obviously, we all work from home so no university infrastructure available, and every student were on Windows10 without WSL installed.
Hopefully I had an unused [SBC](https://wiki.odroid.com/odroid-c2/odroid-c2) that a plugged into my bathroom hair dryer socket, wifi-configured, port-forwarded, and made my students connect to it using [putty](https://www.chiark.greenend.org.uk/~sgtatham/putty/) (you can see the beast on this article banner).

## How to sandbox your student

### Build the sandbox

We will use an ubuntu image packed with some extra binaries.

```
FROM ubuntu:latest
RUN apt update && apt install -y curl tree jq
WORKDIR /root
ENTRYPOINT ["/bin/bash"]
```

Build this `Dockerfile` into an `univ/sandbox` image:

```sh
docker build -t univ/sandbox .
```

### Start the sandbox

As soon as the students arrive we shall start a temporary sandbox for them. To do so, we create this `/usr/bin/sandbox` wrapper:

```sh
#!/usr/bin/sh
[ $# -eq 0 ] && mode=it || mode=i; # no argument = open a TTY
/usr/bin/docker run -$mode -v /home/$USER:/root --rm univ/sandbox:latest "$@"
```

This will also mount the incoming `/home/$USER` directory into the container `/root/` directory. This way, they personal files are safe and I can grade every homework they have.

### Create students accounts (spoiler: it's boring)

I had to spawn a bunch of `adduser --shell /usr/bin/sandbox` commands in my tmux, and student connected to my account to put their password.
Because once created they won't be able to change it, as `passwd` would have changed they volatile sandbox password, not they real account one.

## Conclusion

### Pros:
- both `ssh bob@sbc`, `ssh bob@sbc env` and `scp file bob@sbc:` works
- root: every student can either `apt install openarena` or `rm -rf /*`
- reproducibility: just reconnect to get a fresh container back
- persistence: personal files are kept across sessions

### Cons:
- barebone: the ubuntu image may not come with the usual distro binaries like ping, ssh ... so be prepared to rebuild your sandbox image.
- `/root/`: every sandboxed student will find they `/home/` in `/root/` which might be misleading for newcomers
- security: Docker is not isolation-proof, so if any student use a 0 day to escape the sandbox, they will own my SBC (in which case I'll gladly offer them as a reward)
- `ssh-copy-id` won't work for because of permission mismatch between the root writing, and the user reading.
Level up your observability skills at Data Nerd Days 2.0
Tags: conferences, observability, newrelic, kubernetes
Published: 2021-10-27 20:23:43

New Relic is hosting [Data Nerd Days](https://newrelic.com/events/data-nerd-days?utm_source=devto&utm_medium=event) on November 3, the second installment of our user conference where observability experts show you how to monitor every part of your application stack. Tickets are free and you can register right [here](https://hopin.com/events/data-nerd-days-2-0?utm_source=Dev.to&utm_campaign=Community).

Here’s some of the talks I’m most excited about:

**Upgrade your k8s observability with Pixie (for beginners)**
By Brad Schmitt and Drew Decker

For those new to observing their Kubernetes clusters, Pixie can seem like magic: giving you a breakdown of individual code execution without even installing a monitoring agent. You'll deploy New Relic's Pixie integration, analyze Service, DNS, and Network flow graphs to understand intra-cluster communication and latency, and traverse Flamegraphs to understand where code is running slowly.

**Uncover security anomalies with Lacework**
By Adam Larson

With security on everyone’s mind this year, monitoring is a key part of the solution. Lacework is a cloud security platform that delivers automated security and compliance across multi-cloud environments, workloads, containers, and Kubernetes. Learn how you can significantly reduce alert noise and get to the security events that matter with Lacework.

**Better customer experience with real user monitoring**
By Phil Weber

Real User Monitoring and Synthetics can let you know you have a problem on your front end before a single user notices. Learn how to use New Relic's Real User Monitoring capabilities to ensure your front-end experiences are always working. In this hands-on session you'll learn how to collect custom data from your application.

To read more about all the sessions, visit our [Data Nerd Days 2.0 sessions page](https://newrelic.com/events/data-nerd-days/sessions?utm_source=Dev.to&utm_campaign=Community). 

# Join us on November 3

Data Nerd Days is completely free to attend, and offers New Relic users a chance to become a bona fide data nerd™. [Registration is easy and open now](https://hopin.com/events/data-nerd-days-2-0?utm_source=Dev.to&utm_campaign=Community).  The first five hundred people who register will be entered into a drawing for a Nintendo Switch. See you there! 

Can’t join us on November 3? We’ll be hosting two more Data Nerd Days 2.0 on November 11 for Asian-Pacific time zones and December 1 for European, Middle Eastern, and African time zones.
Kubernetes & Docker -> Deploy a Flask Application - Manually (Simple Steps)
Tags: python, aws, kubernetes, docker
Published: 2021-10-27 20:16:34

## 1. Create a named Kubernetes cluster

```
eksctl create cluster --name [cluster-name]  --profile [profile-name]
```

## 2. Image registry (get or create)
Create/Build a Docker Image and push it to their Docker Hub repository.

> Docker images are loaded from the container registry into Kubernetes pods. Access to the pods are exposed to consumers through a service.

## 3. Deployment
The manual **deployment needs a YAML file** that will describe things like number of replicas, deployment strategy, Docker image name, and port on which the application can be accessed.

#### 1. Deployment mockup yaml file

```
apiVersion: apps/v1
kind: Deployment
metadata:
  name: simple-flask-deployment
  labels:
    app: simple-flask
spec:
  replicas: 3
  selector:
    matchLabels:
      app: simple-flask
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 2
      maxSurge: 2
  template:
    metadata:
      labels:
        app: simple-flask
    spec:
      containers:
      - name: simple-flask
        image: [docker-username]/[image-name]
        securityContext:
          privileged: false
          readOnlyRootFilesystem: false
          allowPrivilegeEscalation: false
        ports:
          - containerPort: 8080
```

#### 2. In your terminal 
Navigate to [deployment-mockup-yaml-file] (deployment.yaml for short), and run:

```
kubectl apply -f deployment.yml

# It will show the message as :
# deployment.apps/simple-flask-deployment created
```

#### 3. Other useful commands are:

```
# Verify the deployment
kubectl get deployments

# Check the rollout status
kubectl rollout status deployment/simple-flask-deployment

# Show the pods in the cluster
kubectl get pods

# Show the services in the cluster
kubectl describe services

# Display information about the cluster
kubectl cluster-info
```

#### 4. Troubleshoot: 
If your pods do not show up as "Ready" while running the `kubectl get nodes1` command, use the following troubleshooting tips:

```
# List all namespaces, all pods
kubectl get all -A

# Show all events
kubectl get events -w

# Show component status
kubectl get componentstatuses
```

#### 5. Clean up
Let's delete the deployment as well the Kubernetes cluster:

```
# Delete your deployment
kubectl delete deployments/simple-flask-deployment

# Tear down your cluster
eksctl delete cluster eksctl-demo --profile <profile-name>
```


[Kubernetes Cheatsheet](https://kubernetes.io/docs/reference/kubectl/cheatsheet/)
1 line of code: How to get lowest numeric element of an Array
Tags: javascript, webdev, productivity, codequality
Published: 2021-10-27 20:05:49

```javascript
const lowestNumber = arr => Math.min(...arr); 
```
Returns the lowest numerical item of the array.

---

## The repository & npm package

You can find the all the utility functions from this series at [github.com/martinkr/onelinecode](https://github.com/martinkr/onelinecode)
The library is also published to [npm as @onelinecode](https://www.npmjs.com/package/@onelinecode/onelinecode) for your convenience.

The code and the npm package will be updated every time I publish a new article.

---

Follow me on [Twitter: @martinkr](http://twitter.com/_martinkr) and consider to [buy me a coffee](https://www.buymeacoffee.com/martinkr)

Photo by [zoo_monkey](https://unsplash.com/@zoo_monkey) on [Unsplash](https://unsplash.com/s/photos/fuji)

---
Atajos de Teclado (Shortcuts) en VSCode.
Tags: javascript, webdev, beginners, vscode
Published: 2021-10-27 19:40:08

Visual Studio Code actualmente en uno de los editores de código más utilizado, sobre todo entre los desarrolladores Web, nos permite programar en casi cualquier lenguaje. Tiene muchas características que lo hacen el editor de código favorito de muchos, ya que es muy personalizable, esto quiere decir que podemos adaptarlo a los gustos personales de cada uno.

Algo que puede ayudarte a ser mas rápido y ahorrar mas tiempo a la hora de moverte o escribir código en VSCode sin duda son los atajos de teclado. Ahora veremos en detalle algunos de ellos.


### General

| Acción | Atajo |
| :---: | :--- |
| Abrir paleta de comandos | `Ctrl + Shift + P` 
| Abrir archivo | `Ctrl + P`
| Nueva ventana | `Ctrl + Shift + N` 
| Cerrar ventana | `Ctrl + Shift + W` 
| Ajustes del perfil | `Ctrl + ,` 

### Usabilidad 

| Acción | Atajo |
| :---: | :--- |
| Crear un nuevo archivo | `Ctrl + N`
| Abrir archivo | `Ctrl + O`
| Guardar archivo | `Ctrl + S`
| Cerrar | `Ctrl + F4` 
| Abrir Terminal | `Ctrl + '`
|  Panel de problemas | `Ctrl + Shift + M` 

### Edición básica

| Acción | Atajo |
| :---: | :--- |
| Cortar linea | `Ctrl + X`
| Copiar linea | `Ctrl + C`
| Borrar linea | `Ctrl + Shift + K`
| Insertar linea abajo | `Enter` 
| Insertar linea arriba | `Ctrl + Shift + Enter`
| Buscar en archivo abierto| `Ctrl + F` 
| Reemplazar | `Ctrl + H` 
| Linea de comentario | `Ctrl + /`
| Bloque de comentario | `Shift + Alt + A`
| Salto de linea | `Alt + Z`
| Seleccionar lineas | `Alt + Click Mouse`
| Tabular linea  | `Tab` 
| Destabular linea | `Shift + Tab`

### Pantalla

| Acción | Atajo |
| :---: | :--- |
| Acercar Zoom | `Ctrl + +`
| Alejar Zoom | `Ctrl + -`
| Barra lateral | `Ctrl + B`
| Abrir debug | `Ctrl + Shift + D`
| Panel de salida | `Ctrl + Shift + U`
| Control de source | `Ctrl + Shift + G`
| Acceder a extensiones | `Ctrl + Shift + X`
| Abrir terminal integrado | `Ctrl + Shift + Ñ`

Mas sobre Visual Studio Code: https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf

---

📌 Mis Redes: 🔵[Facebook](https://www.facebook.com/gdcode7) | 💼[LinkedIn](https://www.linkedin.com/in/gastondanielsen/) | 💻[Github](https://github.com/gdcodev)
Writing an Assembler in Rust, and How I'm Reworking the Lexer (again)
Tags: rust, assemblers
Published: 2021-10-27 19:29:52

Hello people! It's been a bit. Two months or so, to be specific. But I'm back, and I'm still working on this project. Obligatory Github reference:

{% github AshtonSnapp/chasm %}

And now for something you've probably heard before: I'm reworking the lexer. I'm not switching away from the `logos` crate, don't worry. I just realized that there's a better way to implement some of the token variants and their callbacks, and also I need to figure out how to handle in-assembly operators.

First, let's have an example - addresses. The way addresses used to work in the lexer is that there was an AddressInfo struct that contained the address type, the number base, and the value as a signed 32-bit integer. However, I realized two things: first, we don't need to remember what base the number was in, and second, we can pair the number type with the address type. So relative addresses can use an i16 while absolute addresses can use a u32 (because there's no u24 type).

This has resulted in the creation of the AddressType enum, which has each variant take an integer argument that varies in size depending on the address type. This is what it looks like in the code:

```rust
pub enum AddressType {
    Absolute(u32),
    IndirectAbsolute(u32),
    ZeroBank(u16),
    IndirectZeroBank(u16),
    DirectPage(u8),
    Port(u16),
    Relative(i16),
    StackRelative(i16)
}
```

Next we have the work-in-progress that is the address callback. After learning that logos only returns the text that triggered the callback, the code can be a lot simpler. Also, strip_prefix and strip_suffix are now in Rust Stable. So I don't have to use replacen. Yay!

The callback works quite simply. It takes the token slice and checks it for certain starting or ending characters. A pair of parentheses indicates an indirect address, for example. If it starts with either IP or SP, that's a relative address with the letter before the P indicating what pointer it's relative to. An ending p indicates a port address, and an ending d indicates a direct page address. Then, a $ indicates hexadecimal and a % indicates decimal. Simple.

This code is still majorly a work in progress, but I plan to commit to the GitHub repo once I get it to a certain point. Until then, y'all have an awesome day!