teleren/devto huggingface dataset:
Stellar Quests Level 1: Payment
Tags: stellar, xlm, blockchain, tutorial
Published: 2022-10-19 20:06:00

## What is a Payment?

Payments are the transfers of value from one party/person/thing to another, and they're the corner stone of all blockchains. Payments on the Stellar blockchain are theoretically no different from payments on any other blockchain.

A payment, on the Stellar blockchain, is an operation type that must be selected when building a transaction. **NOTE:** Don't confuse transactions with operations- a single transaction can perform many different types of operations, and can also bundle many operations into the single transaction.

## How are Payments created?

Payments are created by building a transaction of operation type "Payment". This operation asks for four inputs: destination, asset, amount, and source account. The *Destination* is the public key of the account that will receive the payment. The *Asset* is the form of value one will send to the destination; this can be the native asset Lumen ($XLM), or a custom asset. **NOTE:** In order for a destination to receive a custom asset, they must've established a trustline for it. The *Amount* is the total of an asset one will send to the destination; the ratio is 1:1. The *Source Account* is the public key of the account that'll be making the payment; this input is optional because if the amount won't be sent by the account which has built the transaction, then the public key entered here will refer to the account that will send the amount. **NOTE:** All transactions **MUST** be signed off by all source accounts mentioned; in this case, the account which built the transaction and the account which is actually making the payment.

> I plan on writing corresponding blog posts with relevant code examples. For now, I'm simply learning the basics of the Stellar blockchain and utilizing the Stellar Laboratory in order to interact with the test net. If you wish to learn about the Stellar blockchain, and earn while doing it, then please visit: https://quest.stellar.org/
Looking for a job opportunity or team or client!!!
Published: 2022-10-19 18:56:50

Hello dear!
I am Dennis from Canada and full stack & Blockchain Developer having 6 years of experience.

This is my [website](https://dennis-stephens.vercel.app).

Now I am looking for a new job opportunity or team or client.
Regards!
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e4kxdgaulbp797njqv02.gif)
Laravel - Serve API requests with translated validation rules
Tags: laravel, php, webdev
Published: 2022-10-19 18:49:32

Consider building a mobile app (or a website) which connects to a Laravel CMS over API for dynamic content. Now, the app can be a multi-language app which expects to receive a translated content from the CMS.
Usually, in our company, we instruct our frontend developers to send a `lang` query param on every request in order to deliver the correct translated content back.

E.g.:
```
GET /api/blogs?lang=en
```

However, Laravel validation is not aware of this and it always returns validation error messages according to app locale (or fallback locale).

Therefore we created a route middleware which groups all API routes and sets app locale based on the `lang` query param:

```php
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class ChangeLocale
{
	/**
	 * Handle an incoming request.
	 */
	public function handle(Request $request, Closure $next): Response
	{
		$locale = $request->query('lang');

		if ($locale) {
			app()->setLocale($locale);
		}

		return $next($request);
	}
}

```

And in routes file:

```php
// routes/api.php

use App\Http\Middleware\ChangeLocale;
use Illuminate\Support\Facades\Route;

Route::middleware(ChangeLocale::class)->group(function (): void {
	// ROUTES
});
```

Now your validation messages will be in the requested locale. If you don't like handling this over query param you can always use a header or something else, e.g.:

```php
$locale = $request->header('Accept-Language');
```

Thank you for reading this! If you've found this interesting, consider leaving a :heart:, :unicorn: , and of course, share and comment on your thoughts!

Lloyds is available for partnerships and open for new projects. If you want to know more about us, [check us out](https://lloyds-digital.com).

Also, don’t forget to follow us on [Instagram](https://instagram.com/lloyds.digital) and [Facebook](https://facebook.com/lloydsdigital)!
Day-17 of Machine Learning:
Tags: beginners, machinelearning, tensorflow, neuralnetwork
Published: 2022-10-19 18:36:10

Day-17 of Machine Learning:
Got a brief intuition on **TensorFlow** where I learnt about 
- how **tensor** stores data in matrix, about **dense** function which is used to create fully connected **layers** and about **Sequential model**.
- how **neural networks handle complex decisions** by dividing the decisions between **hidden layers** and again each layers in to  **multiple units or neurons**.
- Implemented small neural network in TensorFlow binary classification model to recognise **handwritten digit** that works for only 1 and 0.
Process hiding in Linux
Tags: redteam, cybersecurity, defenseevasion, processhiding
Published: 2022-10-19 18:31:54

# Why?

You want to evade detection post compromise of a host, and hide your process as something innocuous when someone inspects `/proc` or `ps`. 

# When?

You're host is Linux, and your executable is in C, or a language with FFI support.

# How?

There are two classes of data to spoof:

1. The contents of `/proc/pid/cmdline`. This is what shows up with `ps -f`.
2. The contents of `/proc/pid/comm` and the first line of `/proc/pid/status`. This is what shows up with `ps` without `-f`.

## In `nim`

```nim
import os

proc NimMain() {.cdecl, importc.}

proc syscall(number: clong): clong
    {.importc, varargs, header: "sys/syscall.h".}
var NR_PRCTL
    {.importc: "__NR_prctl", header: "unistd.h".}: int
var PR_SET_NAME
    {.importc: "PR_SET_NAME", header: "sys/prctl.h".}: int

proc main(argc: int, argv: cstringArray, envp: cstringArray): int
        {.cdecl, exportc.} =
    NimMain()

    const FAKE_COMMAND = "spoofed"

    # handles /proc/pid/comm and /proc/pid/status
    discard syscall(NR_PRCTL, PR_SET_NAME, cstring(FAKE_COMMAND))

    # handles /proc/pid/cmdline
    let totalLength = len(argv[0])
    var i = 0
    for ch in FAKE_COMMAND:
        argv[0][i] = FAKE_COMMAND[i]
        i += 1
    argv[0][i] = '\x00'
    for j in i .. totalLength:
        argv[0][j] = '\x00'

    sleep(60000)
```

* Note that you'll need to compile this with `--nomain`.
* Note that as argc and envp is consecutive in memory this means that a longer `FAKE_COMMAND` than the actual `argv[0]` means we overwrite the contents of `/proc/pid/environ`. To work around this, ensure your executable has a longer name than the what you want to spoof as.
In One Minute : PostgreSQL
Tags: postgres, beginners, programming, oneminute
Published: 2022-10-19 18:23:24

PostgreSQL also known as Postgres, is a free and open-source relational database management system (RDBMS) emphasizing extensibility and SQL compliance. 

{% embed https://youtu.be/KQoitdbAVDc %}

PostgreSQL features transactions with ACID properties, automatically updatable views, materialized views, triggers, foreign keys, and stored procedures.
It is designed to handle a range of workloads, from single machines to data warehouses or Web services with many concurrent users.

PostgreSQL manages concurrency through multiversion concurrency control (MVCC), which gives each transaction a "snapshot" of the database, allowing changes to be made without affecting other transactions. 

PostgreSQL provides an asynchronous messaging system that is accessed through the NOTIFY, LISTEN and UNLISTEN commands.

PostgreSQL includes built-in support for regular B-tree and hash table indexes, and four index access methods: generalized search trees (GiST), generalized inverted indexes (GIN), Space-Partitioned GiST (SP-GiST) and Block Range Indexes (BRIN).


Official website : https://www.postgresql.org/
Learn Automation in Python with 7 Projects
Tags: python, programming, codenewbie, tutorial
Published: 2022-10-19 18:17:10

Automation in Python.
Something you need to be aware of if you're a Python developer, at least the basics.
Wanted to share this video with you, it might be helpful to practice with 7 different projects automating boring repetitive tasks with Python.

{% youtube eh0zzK_aMFY %}
Inferir Tipado de Objetos
Tags: typescript
Published: 2022-10-19 18:08:03

No le han pasado que han declarado un objecto y luego ir agregando mas campo con el pasar del tiempo (ya sea por nuevo requerimientos, no era necesarios al comienzo o no sabian que iban a ser necesarios) y asi mismo ir actualizando tambien el tipado o dejar que Ts infiera, pero si necesitan la key del objecto? o el value?.

En mi dia a dia uso Ts y bastante objecto una de las ventajas que me gusta es el autocompletado/sugerencias en el editor de codigo que te da el tipado, si no te sale una opcion de elegir o no esperabas en el autocompletado/sugerencias sabes que no existe en ese objecto (al menos que la lib q usas por alguna razón no la incluyo en su propio tipado).

Una de las tecnicas que uso de Ts es typeof, keyof, combinacion de ambas aveces, veremos unos ejemplos de como se usa cada uno.

## typeof, keyof

En el caso de los objectos una de las formas mas basica que hacemos es crear el tipado y luego tiparlo a la variable que vamos a crear.
![create Types and var](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xhoro5u7f4261h9zxco5.png)
 
este es otra alternativa que uso de vez en cuando, ya que el objecto es dinamico.

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

normalmente lo uso mucho en react cuando declaramos un estado inicial


![initial state use case](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j5o0q9gwsmxw0zr3zdx3.png)

Cool con el autocompletado verdad!! 😎.
ahora si tenemos una funcion que lo que hace es devolvernos el valor dependiendo de la llave que la pasamos, podriamos crear la funcion asi

![fn that return the obj value by key](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fxk0nkxyee8q5u81atxw.png)

No hay ningun problema crearlo asi, pero si queremos el autocompletado/sugerencias que nos diga que puede recibir como argumento a la hora de llamar la funcion no la tendriamos 😢 (aunque podriamos mentalmente saber que key pasar y recibir el valor, pero eso es cognitivamente estresante 🫠, para eso esta la tecnologia de nuestro lado!).

![no autocomplete](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tk9xxurrwdmlz36n6ktb.png)

para tener el autocompletado/sugerencias y evitar pasar campos que no exista (una forma de protegernos y ahorrar tiempo y ver los errores en el editor, todo eso antes del runtime!!🫠) podemos usar la combinacion de typeof y keyof

![with autocomplete](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d37m9fsxdmj9xtztzv4r.png)

Yayyyy!!! 🙌 tenemos autocompletado/sugerencias de nuevo!

Espero que esto le ayude en su dia a dia como desarrollador en Typescript y disculpa por la imagenes y calidad de redacció 👀.

aqui las documentacion: 
- [typeof](https://www.typescriptlang.org/docs/handbook/2/typeof-types.html)
- [keyof](https://www.typescriptlang.org/docs/handbook/2/keyof-types.html)
You've been structuring files in projects wrong
Tags: react, javascript, webdev, tutorial
Published: 2022-10-19 15:14:58

_Originally posted here https://medium.com/octopus-labs-london/how-to-structure-files-in-large-react-projects-48ee3dc424ed_

Okay I admit, I've got your attention with a somewhat catchy title but hear me out.

When you tend to have large React, Svelte, Vue, any frontend framework (or library) project, it's easy to put all the components in a components folder, containers in the containers folder and so on. Well I have a different approach for really large projects. Something that looks a bit like this

```
public/
package.json
index.ts
src/
│
├── components/
│   ├── Button/
│   │   ├── Button.tsx
│   │   ├── Button.tests.tsx
│   │   └── Button.css
│   ├── Dropdown/
│   ├── Toaster/
│   ├── Header/
│   └── Footer/
│ 
├── layouts/
│   └── StoreLayout/
│       ├── components/
│       │   ├── SearchDropdown/
│       └── StoreLayout.tsx
│ 
└── pages/
    ├── StoreProductPage/
    │   ├── components/
    │   │   ├── Carousel/
    │   │   └── ProductCard/
    │   └── StoreProductPage.tsx
    │
    └── StoreCheckoutPage/
        ├── components/
        │   └── ProductCheckoutCard/
        └── StoreCheckoutPage.tsx
```

This way it's easy to remove pages without other parts of the site. All the general components go in the components folder. But Page specific components go in a sub-folder.

### Not quite convinced?

Check out my video explanation on YouTube.

{% embed https://www.youtube.com/watch?v=1uQ9j8ynQlM %}


### Let's talk
It would be good to hear your thoughts on this approach, if you like or dislike it, and if you have any ideas for improvements. You can find me on [the socials](linktr.ee/richardobray), or you can just write a comment below and I promise I'll respond 🙏
The Vibration API in JavaScript
Tags: javascript, webdev, beginners, codenewbie
Published: 2022-10-19 17:53:58

Vibrations are the best way to provide physical feedback to users for any action mostly for mobile users. For example, while showing a warning message or alert, while receiving a message or notification etc.

The Vibration API allows web apps to access the vibration hardware of the device (if exists) to create vibrations. It provides a method `navigator.vibrate()` for the same purpose.

## The navigator.vibrate() method
This method takes a value of vibration duration in milliseconds and vibrates the device for that long.

```javascript
navigator.vibrate(500); 
// device will vibrate for 500ms
```
The Vibration API doesn’t support in few of the browsers like IE, Opera, Safari, etc., so it will be better to check the browser support before using it.

```javascript
if (navigator.vibrate) {
   navigator.vibrate(500);
}
```

## Vibrating in a pattern
The `vibrate()` method can also accept an array of values as an argument. We can provide different values for how much time it will vibrate and how much time it won’t. It will vibrate for values at even index and pause for values at odd index.

```javascript
navigator.vibrate([320, 200, 320, 1000, 320, 200, 320]);
```
Here it will first vibrate for 320ms and pause for 200ms, then again vibrate for 320ms and pause for 1000ms, and so on.

To cancel a running vibration, we can call `vibrate()` method by passing 0 or an empty array as an argument.

```javascript
navigator.vibrate(0);
// OR
navigator.vibrate([]);
```
---
##You may also like
* [Send push notifications with the Notification API in JavaScript](https://jscurious.com/the-notification-api-in-javascript/)
* [Play audio with HTMLAudioElement API in JavaScript](https://jscurious.com/play-audio-with-htmlaudioelement-api-in-javascript/)
* [The URLSearchParams API in JavaScript](https://jscurious.com/the-urlsearchparams-api/)
* [JavaScript Fetch API to make HTTP requests](https://jscurious.com/javascript-fetch-api-to-make-http-requests/)
* [Map in JavaScript and when it's a better choice than Object](https://jscurious.com/map-in-javascript-and-how-it-is-better-than-object/)
* [JavaScript Set object to store unique values](https://jscurious.com/javascript-set-object-to-store-unique-values/)
* [Generator functions in JavaScript](https://jscurious.com/generator-functions-in-javascript/)
* [A brief guide to Object.defineProperty() method](https://jscurious.com/object-defineproperty-method-in-javascript/)
* [A brief guide to Promises in JavaScript](https://jscurious.com/a-brief-guide-to-promises-in-javascript/)
* [20+ JavaScript shorthand coding tricks](https://jscurious.com/20-javascript-shorthand-techniques-that-will-save-your-time/)

___

**Thanks for your time ❤️**
Find more of my writings on web development at [jscurious.com](https://jscurious.com)
I Created an 🤯 Online Multiplayer Game 🎮 in ReactJS and Python
Tags: webdev, javascript, react, python
Published: 2022-10-19 17:49:47

So, recently I created an Android Game called [MathMind](https://play.google.com/store/apps/details?id=com.rajeshj3.MathMind) 🎮. But, that was an offline single player game.

Based on feedbacks, I choose to create an **Online Multiplayer** Version of it. So, here you go.

---

Presenting 🌟 **MathMind - online** 🌟

![Math Mind, Screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kjlfr58oqyhjmo0tk7u4.png)


![Math Mind online results](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pnfppuaeyzb04r7qbcii.png)

---

Try the multiplayer game 🎮 -> [https://mathmind.netlify.app](https://mathmind.netlify.app)

Try the offline app 🎮 -> [MathMind](https://play.google.com/store/apps/details?id=com.rajeshj3.MathMind)

---

### Tech Stack

- ReactJS (JavaScript)
- FastAPI (Python)
- Redis (Database)

### Why Redis?

Because I learnt a lot from the 🤩 **[Redis x Dev Hackathon](https://dev.to/devteam/announcing-the-redis-hackathon-on-dev-3248)**, in which I was one of the 🏆 **[Grand Prize Winner](https://dev.to/devteam/redis-hackathon-winners-announced-524d)**.

---

Drop a Like, and share your thoughts in the comments.

---

Thank you

cheers

Happy Coding 🤓
SpeedFactor moves to WP Lighthouse!
Tags: wordpress, performance, pagespeed, saas
Published: 2022-10-19 17:05:48

SpeedFactor, as initially developed 3 years ago, is no more. But 90% of the code has been transferred to my WP Lighthouse plugin (due to the fact that 90% of the existing websites were powered by WordPress).

The code has been simplified, open-sourced and integrated into the plugin. The business model has also changed, and it's now easier to pay for updates and support (or not). The plugin is automatically kept up-to-date from a private GitHub organization.

From a business point of view, I feel like this is a good change. Less code maintenance gives me more time for feature updates and client support.

## Why less maintenance?

Because WP Lighthouse uses the #WordPress infrastructure - WPaaF (WordPress As A framework).

If you are interested in migrating to WP Lighthouse or giving the plugin a test-drive, check out the link below:

https://getbutterfly.com/
React Optimizing Compiler (without memo)
Tags: react, performance, programming, javascript
Published: 2022-10-19 16:58:34

It’s a compiler that automatically generates the equivalent of useMemo and useCallback calls to minimize the cost of re-rendering, while retaining React’s programming model.




Recently, React core Team finished a rewrite of the compiler to make it more reliable and capable after an early preview of React Forget at React Conf 2021. This new architecture allows us to analyze and memoize more complex patterns such as the use of local mutations, and opens up many new compile-time optimization opportunities beyond just being on par with memoization hooks.





![Compiled code in React Forget sneak peek video](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/htkloj2wulpyfzb2bzmb.png)
       Compiled code in React Forget sneak peek video

According to Dan Abramov, this could eliminate the need to use React.memo() as well. This is because the compiler apparently memoizes not just the calculation of useMemo() results, but also the resulting React element objects returned by the component.


Watch the [original video](https://www.youtube.com/watch?v=lGEMwh32soc) as it showcases a more in-depth and hands-on experience of using React Forget.
How run & use DynamoDB locally
Tags: aws, dynamodb, beginners, tutorial
Published: 2022-10-19 16:58:21

This post intent to be simple and direct.

We are going to run [DynamoDB](https://aws.amazon.com/pt/dynamodb/) locally and connect with him using [NoSQL Workbench](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/workbench.html).

Before we start, check if you have [Docker](https://www.docker.com/) running on your machine. Else not, install [here](https://docs.docker.com/engine/install/)

Choose an folder or create a new one, inside this folder create a file `docker-compose.yml`: 
```
version: '3.8'
services:
  dynamodb-local:
    command: "-jar DynamoDBLocal.jar -sharedDb -dbPath ./data"
    image: "amazon/dynamodb-local:latest"
    container_name: dynamodb-local
    ports:
      - "8000:8000"
    volumes:
      - "./docker/dynamodb:/home/dynamodblocal/data"
    working_dir: /home/dynamodblocal
```

In your terminal, inside the folder you created the file run following command:
`docker-compose up `

If everything is well, this should be the result of your terminal:
![Command Finished](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/35omhp6nyquwh43emx8o.png)

Lets connect with DynamoDB using NoSQL Workbench.

Download and install using [AWS NoSQL Workbench](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/workbench.settingup.html)

Open the NoSQL Workbench Software.

Choose **Amazon DynamoDB**:
![Amazon DynamoDB ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/adym2sv35zqvpgf525hs.png)

Click in Operation Builder and **Add Connection**:

![Add Connection](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cx6t1swtotncusxb3nnz.png)

Setup your connection:

![Fill all fields](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7gj1k3tx9szgn45kng14.png)

And everything should be okay if you see this screen:

![Connection Estabilished](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dbo8s2ryrxzn357nm1xj.png)

Hope this article helped you.
Hacktoberfest
Tags: hacktoberfest, programming
Published: 2022-10-19 16:46:26

I currently contributed to Hacktoberfest, and I can say it feels good knowing you may have made a change to someones knowledge/repository. Of course when they accept it. I got a reward for it! Actually many, but one of them is which I can show off, here. 

[![@dhotspot's Holopin board](https://holopin.me/dhotspot)](https://holopin.io/@dhotspot)
Hello!
Tags: introduction
Published: 2022-10-19 16:36:12


### Who are you?
 - I am Dmitriy, a Computer Science Student from Boston, MA.

### What do you do? 
 - Currently, I am in college part time, but love to get on my IDE and work on my projects + website.

### Where can I see?
 - Well, I posted some projects on here, but Github is where they're all located. also my website: https://www.dhotspot.dev
Failed pre-install: timed out waiting for the condition. Helm install error
Published: 2022-10-19 16:32:53

Today I was trying to install ingress controller using helm3 and got an error like below.

_Error: INSTALLATION FAILED: failed pre-install: timed out waiting for the condition._

I felt the above error was not giving a proper indication of what went wrong, but this could be identified by collecting the event logs and see what is actually failing under the hood.

`kubectl -n <your-namespace> get events --sort-by='{.lastTimestamp}'`


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


Which showed me there was missing images in my azure container registry which was causing ErrImagePull.