teleren/devto huggingface dataset:
How to work with different versions of Java
Tags: java, cloud, aws, tooling
Published: 2022-12-14 22:31:32


**The future for Java is bright!**

If you are coding in the JVM but the system you are working on was created using Java 11 or even 8 🚨, and want to try out the new features of Java like:

- Local Variable Type Inference
-⚠️ Local Variable Type in Lambda Expressions
- Switch Expressions
- Text Blocks
- Pattern Matching of instanceof
- Records 
- Sealed Classes

Maybe it's time to use SDKMAN, it allows you to switch from different Java versions in an easy way.

## Install SDK

```bash
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
```

## Installing a specific version of Java

Then you can list all the available versions of Java

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5qtgrur8m1cz0zsx7c59.png)

SDK will download and unzip the specified version of Java into a directory on your computer. Additionally, it will update 
the environment variables. Easy peasy 

```bash
sdk install java 19-amzn
```
Ready to use ⭐️

```bash
java -version
```
## Switching Java Versions

You can check the current installations with: 

```bash
ls -l ~/.sdkman/candidates/java
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q82lm8c61eh0n4btv5f6.png)

### Happy Coding. Its time to try the new Java features while you still contributing to your legacy Application 🚀

Then you should be able to use the Java version which allows you to work with the new features or legacy ones. 

```bash
sdk use java <version>
```
Como ⚡ publico una udf para Athena ? Parte I
Tags: aws, athena, udf, etl
Published: 2022-12-14 22:30:01

Bueno esta fue la pregunta inicial que dará origen a la siguiente aventura, suponga que en su datalake implemento un complejo pipelile de datos y se dio cuenta que en medio del proceso su motor no cuenta con una funcionalidad sql 🙇, en mi caso fue st_buffer, por cierto que en Athena si esta implementada pero en grados decimales (iuhggg), por lo que necesitábamos la preciada función en metros.
Bueno luego de un corto googleo aparece el siguente Workshop de bastante utilidad y bien explicado:
[Taller de Amazon Athena :: Hands on Labs](https://catalog.us-east-1.prod.workshops.aws/workshops/9981f1a1-abdc-49b5-8387-cb01d238bb78/en-US/50-udf)

Para comenzar recomienda usar Cloud9, pero es yo utilice WSL Ubuntu 22 sin mayores problemas.
Bueno en simples pasos una vez que se configura el sam-aws-cli , credencial aws , maven y git , nos clonamos un repo el cual contiene un boilerplate con la estructura de un proyecto java 11 , que posee handler con algunos metodos a modo hello world, listo en este punto solo falta compilar el jar y ejecutar un sh para hacer un deploy de la aplicación , se necesita un permiso especial para poder hacerlo "serverlessrepo:CreateApplication" en el recurso "arn:aws:serverlessrepo:us-east-1:<acount-id>:applications/*" 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e749lln51rw50482o0vo.png)
Listo se publicó la aplicación ahora qué ?, solo seguir el paso "Configuración del conector UDF" , en ese caso seguir el enlace y buscar aplicaciones privadas seleccionar "AthenaUserDefinedFunctions" y completar los datos , luego deployar , tómese una cerveza y Prepárese para probar su función UDF


`USING EXTERNAL FUNCTION redact(col1 VARCHAR ) RETURNS VARCHAR 
LAMBDA 'customudf' SELECT redact('StringToBeCompressed');`

Excelente nuestro hello world , próximamente en la parte II detallare el proceso para manipular datos geoespaciales y hacer el buffer con java, que esta algo fuera de mi zona de confort pero con GPT3 veremos si da alguna sorpresa.
pedumper: A new tool for dumping PE files
Tags: forensics, python, security
Published: 2022-12-14 22:21:11

## Summary

I have published a new tool for dumping PE files in the target memory on Windows:tada:
The tool name is `pedumper`. Here is a link for the tool.
https://github.com/owlinux1000/pedumper

## Installation

You can easily install `pedumper` by `pip`.
```sh
pip install pedumper
```

## How to use

`pedumper` is a very simple interface as follows. You have to pass an argument which is a PID of the target process.

![how to use](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eruisv2m91zvx5a58ryj.png)

If the tool can find a valid PE file, the file is saved on the disk. The filename is used by the memory address.

## How to create `pedumper`?

When I create this tool, I have to learn **two** things.

### 1. `ctypes`

`ctypes` is a standard library of python. To use this library, we can execute Win32 API on Python like this.

```python
def read_process_memory(hProcess: int, offset: int, size: ctypes.c_size_t) -> bytes:
    buf = ctypes.create_string_buffer(size)
    ctypes.windll.kernel32.ReadProcessMemory(
        ctypes.cast(hProcess, ctypes.c_void_p),
        ctypes.cast(offset, ctypes.c_void_p),
        ctypes.cast(buf, ctypes.c_wchar_p),
        size,
        None,
    )
```

### 2. Memory Basic Information of Windows

On Windows, a memory of the process is defined by `MEMORY_BASIC_INFORMAION` structure. Here is a definition from Microsoft Official document. I have learned some fileds of the structure through implementing `pedumper`.

```c++
typedef struct _MEMORY_BASIC_INFORMATION {
  PVOID  BaseAddress;
  PVOID  AllocationBase;
  DWORD  AllocationProtect;
  WORD   PartitionId;
  SIZE_T RegionSize;
  DWORD  State;
  DWORD  Protect;
  DWORD  Type;
} MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
```

## Conclusion

I introduced `pedumper` created by myself. If you are interested in the tool, please use it and tell me feedback:smile:
Treeview Nav using React
Tags: react
Published: 2022-12-14 21:31:44

I'm trying to create a treeview navigation using React and running into some issues.

my JSON looks like this: [ this is coming from a webAPI and unable to change the format of it]

`{
    "make" : "BMW",
    "year" : "2020",
    "type" : "used"
 },
 {
    "make" : "BMW",
    "year" : "2022",
    "type" : "new"
 },
 {
   "make" : "lexus",
   "year" : "2022",
   "type" : "used"
 },
 {
   "make" : "lexus",
   "year" : "2022",
   "type" : "used"
 }`

I want the nav to look like this

   **BMW**
       2020
       2022 
   **Lexus**
       2022
       2022

Will one of the treeview components out there  work for this JSON format?
Make your search queries faster with bloom filters
Tags: database, data, datastructures
Published: 2022-12-14 21:28:50

---
title: Make your search queries faster with bloom filters
published: true
description: Use a probabilistic data structure to avoid database calls.
tags: #database #data #datastructures
cover_image: https://cdn.pixabay.com/photo/2014/05/01/17/51/flower-335662_1280.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2022-12-13 11:45 +0000
---

Let's say you're building a feature to search for available usernames. You want to make sure that the username is not already taken.

```http
GET /username?username=paul 
```

You could check the database to see if the username is already taken, but that could be slow. Instead, you can use a bloom filter to check if the username is already taken without checking the database.

## What is a bloom filter?

A bloom filter is a probabilistic data structure that can be used to test if an element is a member of a set. It is a space-efficient probabilistic data structure, that is, it uses space proportional to the number of elements inserted in the data structure, but it is not guaranteed to be 100% accurate.

The main advantage is that it is very fast. If the element is not in the set, then the bloom filter will always return false. If the element is in the set, then the bloom filter might return true, so you need to check the database to make sure. That reduces the number of database queries.

## How does it work?

A bloom filter is a bit array of length n, where the value of each bit is initially 0. As new elements are added, they are hashed multiple times and the corresponding bits are set to 1.

![Bloom filter](https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Bloom_filter.svg/800px-Bloom_filter.svg.png)

When you want to check if an element is in the filter, you hash the element and check if the corresponding bits are set to 1. If they are, then the element is probably in the filter. If they are not, then the element is definitely not in the filter.

i.e. if you want to check if the username `paul` is in the filter, you would hash `paul` and check if the corresponding bits are set to 1. If they are, then the username is probably in the filter. If they are not, then the username is definitely not in the filter.

## How to create a bloom filter

There are some packages that you can use to create a bloom filter. For example, [bloom-filters](https://www.npmjs.com/package/bloom-filters) is a JavaScript implementation of bloom filters.
I built an AI portrait app (with a twist) using Midjourney
Published: 2022-12-14 21:13:58

Hi, everybody! 👋

I'm excited to share my first launch here as an indie developer with all of you.

I've been having a lot of fun playing around with AI image generation over the last two weeks, and I wanted to combine this trend with something meaningful - so I decided to support wildlife preservation. All profits are donated to reputable conservation groups that devote at least 80 percent of the money to fieldwork.

This is a web app that can be accessed here — https://animalai.co 🦁

I'm using Midjourney to generate these images as it gives me the highest quality results (IMO), even though it requires a bit of manual work since there's no API available. I'm planning to add more animal styles each week, trying to get to 100 before next year.

I hope you like it!

P.S. If you can, please also support my PH launch at https://www.producthunt.com/products/animalai 🙏
Share localhost easy 🚀
Published: 2022-11-21 12:58:43

Tunl - the open-source developer platform for:

- Inspect incoming traffic
- Debug callback's and WebHook's
- Show localhost without deploy

Tunl allows you to share local port, IP or URL address to the internet, view incoming requests:

- **Easy publish:** your localhost to internet.
- **Traffic monitor:** easy tool for inspect incoming traffic with view of request form data and json.
- **Basic Auth:** protect your tunnel with username and password.
- **Add headers:** to your requests and responses.

[Download](https://github.com/black40x/tunl/releases) the latest release. Also, you can start your own server with [tunl-server](https://github.com/black40x/tunl-server).

![Monitor](https://github.com/black40x/tunl/blob/main/assets/monitor.png?raw=true)

### Example commands

```
tunl http 8000
```
```
tunl http 192.168.1.10:8000
```
```
tunl http dir://<path-to-directory>
```
```
tunl http -basic-auth login:pass 8000
```

### Build

Install npm and go 1.19

```
git clone git@github.com:black40x/tunl.git
cd tunl
make
go install 
```

### License

Tunl.online is distributed under [AGPL-3.0-only](LICENSE).
🎄JS Advent #7 - Destructuring 🎄
Tags: beginners, webdev, javascript, programming
Published: 2022-12-14 20:55:10



##### For the month of December I have challenged myself to write 24 articles about some JS concepts up until Xmas.
##### The seventh installment in this series is about Destructuring.


You can use the destructuring assignment in JS to unpack objects and arrays.

For example:
```javascript
var obj = {a: 10, b: 20};
const {a, b} = obj;

console.log(a); // 10
console.log(b); // 20

var arr = [10, 20, 30];
const [a,b,c] = arr;

console.log(a); // 10
console.log(b); // 20
console.log(c); // 30
```

Any properties not present on the array or object will just be undefined:
```javascript
var obj = {a: 10, b: 20};
const {c} = obj;

console.log(c); // undefined

var arr = [10, 20];
const [a,b,c] = arr;

console.log(c); // undefined
```

You can also have a default value for each variable which will be used if that property is not present:
```javascript
var obj = { a: 10, b: 20, d: null };
const { a, b, c = 30, d = 40 } = obj;

console.log(a); // 10
console.log(b); // 20
console.log(c); // 30 - as c is not on obj
console.log(d); // null - will only set to the default if undefined
```

The spread syntax can be used also when destructuring
```javascript
var obj = { a: 10, b: 20, c: 30 };
const { a, ...otherProperties } = obj;

console.log(a); // 10
console.log(otherProperties); // { b: 20, c: 30 }

var arr = [10, 20, 30, 40];
const [a, ...others] = arr;

console.log(a); // 10
console.log(others); // [20,30,40]
```
How NuvoLinQ Automated their Fulfilment and Customer Support Processes using Openscreen Track
Tags: qrcode, productivity, programming, cloud
Published: 2022-12-14 20:54:41

## The Challenge
[NuvoLinQ](https://www.nuvolinq.com/) supplies and supports routers and sim cards that provide internet services for IoT devices.  With connectivity in over 175 countries, they provide essential connections to businesses whose network access is mission critical to their operations. They needed a solution that could simplify fulfilment and digitize support for their devices in the field.

## The Solution - Openscreen Track
Leveraging [Openscreen Track's](https://openscreen.com/openscreen-track) dynamic QR Codes, and its asset and contact management capabilities, NuvoLinQ launched ScanLinQ to simplify router fulfilment and digitize customer service.  

With Openscreen Track, Nuvolinq was able to:
- Create a unique, trackable QR code for every router and sim
- Retrieve the last known status information for routers
- Easily identify offline routers and send details to their cloud management system
- Have customers submit a support ticket with only a camera scan
- Allow technicians to diagnose and report router details to the support team

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/grs4w6muhgdd6wmbenfz.png)

## Key Results
NuvoLinQ was able to transform their fulfilment and customer support experience by configuring simple yet sophisticated workflows leveraging Openscreen Track.  The resulting solution allowed NuvoLinQ to decrease response time, decrease downtime and increase customer satisfaction.

## About Openscreen Track
Openscreen Track leverages dynamic QR Codes, asset management, scan capture and contact management to track people and products as they move through your supply chain. NuvoLinQ is one of many use-cases of Openscreen Track. For more information, visit [www.openscreen.com](https://www.openscreen.com) or [contact us](https://www.openscreen.com/contact-us).
🎄JS Advent #6 - Host vs Native objects🎄
Tags: beginners, javascript, webdev, programming
Published: 2022-12-14 20:47:30

##### For the month of December I have challenged myself to write 24 articles about some JS concepts up until Xmas.
##### The sixth installment in this series is about Host and Native objects.

#### What is a native object?
- A native object is provided by Javascript itself. Their behaviour does not change based on the environment they are used in.
- Some examples of native objects are `String()` `Array` `Number()`, `true`.


#### What is a host object?
- A host object is an object provided by the environment Javascript is being executed in.
- This will vary based on where the code is run.
- Web browsers will allow you to access a `window` and `console` object, but these will not be available on a NodeJs server.
Informações gerais sobre as provas da AWS
Tags: aws, cloud, security, devops
Published: 2022-12-14 20:47:26

##**Página oficial da AWS**
O link abaixo contém todas as informações sobre as certificações da AWS.

https://aws.amazon.com/pt/certification/?nc2=sb_ce_co

---

##**Idiomas oferecidos**
Vários exames estão sendo oferecidos nos idiomas: 

- Inglês 
- Francês (França)
- Alemão
- Italiano
- Japonês
- Coreano
- Português (Brasil)
- Chinês simplificado
- Espanhol (América Latina)

---

##**Solicitação ESL +30 Minutes**
Pode ser solicitado 30 minutos a mais para a prova.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/og32dwisx6kqxujivouh.png)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/me39nybkgik3dyhxba99.png)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/asjlgymjjgkfiwa9qqub.png)
A linguagem Rust
Tags: programming, rust, functional
Published: 2022-12-14 20:18:09

Olá!

Tenho aprendido `Rust` para poder trazer performance para alguns problemas que tenho enfrentado no trabalho. Então, este é o início de algumas anotações que irei fazer para entender e utilizar rust aqui na empresa.

### Rust
A linguagem rust tem foco em eficiência e confiabilidade.
Rust traz um desempenho extremamente rápido, gerencia memória eficientemente, seu sistema de tipos e modelo de _ownership_ garantem segurança de memória e de concorrência. Além disso, possui uma ótima documentação, compilador amigável com mensagens de erros úteis e ferramental de primeira qualidade.

Rust traz uma forma interessante de apresentar seus fundamentos que é por meio do ["o livro"](https://doc.rust-lang.org/book/) que apresenta uma visão geral da linguagem a partir de princípios fundamentais.

### Instalação
A instalação do Rust é pelo rustup. No site oficial do [`rustup`](https://rustup.rs/) você pode ver como instalar no seu sistema operacional. No linux foi bem simples. Bastou rodar o comando `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` no terminal.

Após isso, pode verificar a instalação rodando o comando `rustc --version` que no meu caso, retornou `rustc 1.65.0 (897e37553 2022-11-02)`.

Além do rustc, também houve a instalação do [`cargo`](https://doc.rust-lang.org/cargo/) que é o gerenciador de pacotes do Rust. Além de ser o gerenciador de dependências, cargo compila os seus pacotes,  gera pacotes distribuídos e também realiza o upload para o [`crates`](crates.io), onde ficam as informações de pacotes para aplicações Rust.

### Hello World
Presumindo que você esteja em um sistema operacional linux como por exemplo, em um Ubuntu, abra o terminal e crie uma pasta chamada `hello_world_rust` e entre nela. Os comandos para isso são:
```bash
$ mkdir hello_world_rust
$ cd hello_world_rust
``` 
Para a edição dos códigos, aconselho você utilizar o vscode. Então, abra o vscode na pasta do projeto. Ou seja, se você tiver entrado na pasta `hello_world_rust`, basta digitar no terminal `code .` e o vscode será aberto na pasta atual.

Crie um arquivo chamado `main.rs` e adicione a função main, pois ela é sempre o primeiro código que será executádo em um programa Rust. Deixe seu `main.rs` igual ao código abaixo:
```rust
fn main() {
    println!("Hello, world!");
}
```
Para poder reproduzir o código, utilize os comandos:
```bash
$ rustc main.rs
$ ./main
Hello, world!
```
O comando `rustc main.rs` compilou o código contigo no arquivo `main.rs` e gerou um executável chamado `main`.
Com o comando `./main` você irá executar o programa compilado e ele irá retornar o "Hello, world!".

### Conclusão
Por hoje é isso. Entendemos o que é Rust, aprendemos a instalar e criamos nosso primeiro programa. Em breve venho com mais!

Deus abençoe!
Troubleshooting "Did you specify the right host or port?" Amazon EKS Error:
Tags: aws, eks, kubernetes, devops
Published: 2022-12-14 20:06:59

---
title: Troubleshooting "Did you specify the right host or port?" Amazon EKS Error:  
published: true
description: 
tags: aws, eks, kubernetes, devops
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v3ocdbra7ikywsy45oqg.png
# Use a ratio of 100:42 for best results.
# published_at: 2022-12-14 19:46 +0000
---

Let's say you're working through the [Amazon EKS tutorial](https://docs.aws.amazon.com/eks/latest/userguide/getting-started-console.html) and, when you reach step 2.2 and run `kubectl get svc`, you get the following error:
```sh 
E1214 14:39:13.139525  398989 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E1214 14:39:13.139752  398989 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E1214 14:39:13.141035  398989 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E1214 14:39:13.142235  398989 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
E1214 14:39:13.143744  398989 memcache.go:238] couldn't get current server API group list: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
The connection to the server localhost:8080 was refused - did you specify the right host or port?
```

The tutorial directs you to [this troubleshooting guide](https://docs.aws.amazon.com/eks/latest/userguide/troubleshooting.html#unauthorized), but if you don't find the answer there, try the following: 
```sh
aws eks update-kubeconfig --name <EKS_Cluster_Name> --region <Region_Name>
```
Methods to make an API request more secure
Tags: security, beginners, api
Published: 2022-12-14 19:28:32

There are several ways to make an API request more secure. Some tips include:

1) Use HTTPS instead of HTTP to encrypt communication between client and server.

2) Implement user authentication to ensure that only authorized users have access to the API. This can be done via access tokens or user credentials.

3) Implement resource authorization to ensure that users only have access to the resources they are allowed to. This can be done through authorization rules or user roles.

4) Use digital signatures to verify the integrity of API requests. This helps ensure that claims have not been altered or forged during transit.

5) Monitor and log API access to detect and investigate any unauthorized access attempts or suspicious behavior. This can help identify vulnerabilities in API security and take steps to correct them.

One way to make an API request more secure is to use token authentication. This means that instead of sending your access credentials (such as username and password) with each request, you can send a unique token that is generated using your credentials. This token is sent on every request, and the API checks that the token is valid before processing the request.

Another way to make requests more secure is to use encryption in all communications with the API. This ensures that information sent and received is secure and protected from unauthorized access. It is important to remember to always use up-to-date and reliable network security protocols.

Furthermore, it is always recommended to implement additional security measures, such as limits on login attempts and checking captchas, to protect against brute force attacks. It is also important to keep all used systems and libraries updated with the latest security patches.