teleren/devto huggingface dataset:
Free watermarks in your photos?
Published: 2022-10-15 18:50:25

Hi there,
I was picturing Airsoft game and since I'm in a Airsoft team I wanted to add some free ad of our tiny sweet team.
I was browsing for **totally** free website tool to add some watermarks on these pictures. But none of them were actually free. Some of them allow only 10 per task and while I've got 650+ pictures it's kind useless. Or some of them can do every picture by once, but on the end the asked me for money to download it.
So, I texted to my dear friend @Meldiron and he found a solution to my little problem called [ImageMagick](https://imagemagick.org/index.php).
### By owners of CLI
"ImageMagick is free software delivered as a ready-to-run binary distribution or as source code that you may use, copy, modify, and distribute in both open and proprietary applications. It is distributed under a derived Apache 2.0 license."
### Final solution
I've downloaded ImageMagick CLI and just type command to loop all sub files in folder and add watermark by command
```
for /f %a IN ('dir /b /s "C:\Users\<user>\Desktop\foto\*.jpg"') do magick composite -gravity SouthWest F:\Graphics\THO\flag_www.png %a %a
```
I hope this might help some nerds here.
Love,
NiX3r

PS: some example of two watermarks in one picture
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c39i1huxbd1ca3kq1qry.JPG)
Back-To-CP: day 3
Published: 2022-10-15 17:58:25

15-10-2022

[Remove Nth Node From End of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list/)



Another problem that can be solved using two pointers technique.
It can be easily solved if we run a loop and hold all the addresses in an array then just find out the middle point, remove the link between nodes.
But it can be done efficiently using two pointers. Firstly, the fast node is advanced n times, so that the slow pointer will be at the n-1'th position when fast pointer reaches the end.

This however gives an error if the length of the list is equal to n. In which case answer would be null pointer. So, an edge case for checking for list length equal 1 is necessary.

```
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
public:
    ListNode* removeNthFromEnd(ListNode* head, int n) {
        ListNode *f = head;
        ListNode *s = head;
        for(int i = 0; i < n ; i++){
            f = f->next;
        }
        if(f == nullptr) {
            return head->next;
        }
        while(f->next != nullptr && f != nullptr) {
            s = s->next;
            f = f->next;
        }

        s->next = s->next->next;
        return head;
    }
};
```
PrivEsc with LD_PRELOAD
Tags: ethicalhacking, redteam, cybersecurity, privesc
Published: 2022-10-15 17:55:22

# Why?

You need root access on a Linux host.

# When?

You have write access to the file-system, can set environment variables for root, and root runs processes.

# How?

1. Craft a C program with an `init` function registered with `.init_array`.
2. Compile the C program as an .so binary for the matching architecture.
3. Write the binary to the target host's filesystem.
4. Set the LD_PRELOAD environment variable.
5. Wait for or trigger the root process execution.

# Example

```c
#include <unistd.h>

void init(int argc, char **argv, char **envp) {
    // PrivEsc hook
}

__attribute__((section(".init_array"))) typeof(init) *__init = init;
```
Prepping for ReInvent: Getting my Dev Associate Cert
Tags: aws, reinvent, certification
Published: 2022-10-15 17:46:57

---
title: Prepping for ReInvent: Getting my Dev Associate Cert
published: true
description: Tracking my prep for ReInvent
tags: aws, reinvent, certification
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---

My Pre-ReInvent goal for this year is to upgrade from the AWS Certified Cloud Practitioner to the Developer Associate.  I started working towards this way back in the spring but got caught up with work and life and it got left behind.

However I'm picking this work back up now in hopes that I can get level up my certification prior to attending ReInvent this year in November.

I started out doing Stephane Maarek's developer associate course. He does a fantastic job of not just covering the services and their configuration options. But also including useful advice and implementation patterns to go with it. It is fantastic and I 100% would recommend going through it regardless of if you want to get certified. Sadly personally I've only managed to get through ~65% of the course due to life 🤷‍ But have learned quite a bit from what I have completed.
![Course progress.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jfcfmxkjxzeyot5a98s3.png)

Now that ReInvent is closing in (5ish weeks from writing), I'm pivoting my strategy away from coursework and into practice tests. I'm using @jonbonso's practice tests and they live up to the hype. Feels very much like the previous exam I took.

Today's results from the 1st practice test aren't the greatest. 64%. 3 questions from passing. So not miles off the mark. I've got 4 more tests to use, but likely at min I'll do two more over the next couple of weeks just to get in the practice.
![Practice test resutls](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5vaxbhbu035nnr8tf2vq.png)

Next step is to review my wrong answers. Then for the next test (next weekend) the goal is to slow down. There's 130 minutes allotted and I used 50. Admittedly I spent 0 mins reviewing before submitting. So next one will take a second go round to double check and take more time with my answers.

---
Best of luck and hope this helps.

Find me on [Twitter](https://twitter.com/therealdakotal) | [LinkedIn](https://www.linkedin.com/in/dakota-lewallen/) | [Github](https://github.com/IamFlowZ) | [Substack](https://dakotalewallen.substack.com)
Github Goodies
Tags: github, keys
Published: 2022-10-15 17:40:15

---
title: Github Goodies
published: true
description: A list of Github goodies
tags: github, keys
# cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gxigydho5yxzgms34gbj.jpg
# Use a ratio of 100:42 for best results.
---

There are several less known goodies from Github.

1. Public SSH key `github[.]com/[username].keys`
For example, https://github.com/dpaluy.keys

__Usage__: You are presenting at the conference or making a tutorial and want automatically give an access to attendees. Just ask for their Github username and you can add the public SSH key.

2. Make it pretty with Github Avatar `github[.]com/[username].png`. Example: https://github.com/dpaluy.png

3. Making secured conversation using (gpg)[https://gpgtools.org/] `github[.]com/[username].gpg`
For example: https://github.com/dpaluy.gpg

Happy hacking
When Promise.race() wasn't racing
Tags: javascript, webdev, programming
Published: 2022-10-15 17:16:08

## The Problem

A week ago we encountered this weird bug in one of our core APIs. The issue was that it was not returning any response whatsoever. 

Luckily we’d found this issue during staging. My senior and I immediately got to work. For almost an hour we scratched our heads checking all the edge cases, connections, environments and queries. Everything looked perfectly fine on the command line, so why wasn’t this working?

Annoyed beyond repair, we just decided to take the age old route and decipher each piece of code piece by piece on blocks and queries in the API, until the culprit revealed itself.

### Promise.race()

We had initialised a simple check to return a response as soon as the validation service found at least one error in the data that we were validating. Pretty simple use case. We used `Promise.race()` to achieve this. `Promise.race()` works perfectly fine when validating lot of data. Again, pretty straightforward answer. 

EXCEPT! The function only works on certain conditions.

### The BUG 

The data that we needed to be validated was being fetched from another query. Apparently when we were passing this data, it was empty and we were unknowingly passing an empty array into the `Promise.race([])` function.

This will result in something called a `foreverPendingPromise`. It’s clearly mentioned in the [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race#examples) about this case, and we’d overlooked it.

To understand this situation better, let's dig a little deeper on how the function actually works.


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

This results in  

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

As we see `callPromise()` took exactly 5 seconds to execute - the fastest `getValue()` promise to resolve. Works totally fine.

The whole fiasco starts when we pass an empty array. [ Code pen to Cry ](https://codepen.io/karan_fp/pen/bGMZKWq) - where the console logs `start' and wait forever for the race to finish.

### The fix

The simple fix we patched is to run the race only if something in the validation array. It’s a simple problem and a simple solution, but it’s the simplest things that are often neglected. The devil is in the details.

--- 

Editing courtesy [ah__sho](https://twitter.com/ah__sho)
Code Snippets by [Carbon](https://carbon.now.sh)
Cover pic by <a href="https://unsplash.com/@austris_a?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Austris Augusts</a> on <a href="https://unsplash.com/s/photos/race?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
Can't get Axios requests to PHP API
Tags: vue, laravel, nginx, axios
Published: 2022-10-14 16:19:53

Not sure where to start here. I have inherited a Laravel 7.4/ Vue 2.x application. Everyone who knew how to start it up (in theory: successfully) is long gone. I've got everything up and listening without errors until you try to do anything. It's supposed to be setup with the Laravel app listening for `/api` calls. And in the Vue app an `Api` object is created by Axios.

The problem I am struggling with is that all requests to this `Api` return with a 401 Unauthorized. But the PHP server isn't even getting a request.

```
import axios from "axios";

let baseURL = "";

switch (process.env.NODE_ENV) {
	case "development":
		baseURL = window.location.protocol + "//" + window.location.hostname + "/api";
		break;

	default:
		baseURL = window.location.protocol + "//" + window.location.hostname + "/api";
}

axios.defaults.withCredentials = true;

const Api = axios.create({
	baseURL,
	withCredentials: true
});

export default Api;
```

I'm using all the sanctum csrf stuff to manage the token and I'm not getting CSRF errors anymore after fixing the config in `.env`. Now all I get are 401s, and they are coming from Nginx. Any ideas? I've been stuck on this for days and don't know where to go next.
In One Minute : Heroku
Tags: heroku, beginners, tutorial, oneminute
Published: 2022-10-15 17:11:34

Heroku is a cloud platform as a service (PaaS) supporting several programming languages. 

One of the first cloud platforms, Heroku has been in development since June 2007.

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

The Heroku network runs the customer's apps in virtual containers which execute on a reliable runtime environment.
Heroku calls these containers "Dynos". These Dynos can run code written in Node, Ruby, PHP, Go, Scala, Python, Java, or Clojure. 

Heroku Teams is a team management tool which provides collaboration and controls to bring a customer's developers, processes, and tools together in order to build better software. 

Heroku Elements provides users with Add-ons (tools and services for developing, extending, and operating the app), Buildpacks (which automate the build processes for the preferred languages and frameworks) and Buttons (a tool for the one-click provisioning, configuring, and deployment of third party components, libraries and patterns).

Heroku Redis is the customized Redis from Heroku to provide a better developer experience.

Heroku Postgres is the Cloud database (DBaaS) service for Heroku based on PostgreSQL. 

Official website :- https://heroku.com/
Features of mongodb Atlas
Tags: javascript, webdev, beginners, programming
Published: 2022-10-15 17:09:31

MongoDB Atlas is a cloud-hosted database service that offers a fully managed MongoDB experience. It is available on Amazon Web Services (AWS), Google Cloud Platform (GCP), and Microsoft Azure. 

MongoDB Atlas provides a simple, intuitive interface that makes it easy to deploy, monitor, and scale your MongoDB deployments. It also offers a number of features that make it a powerful tool for managing MongoDB deployments: 

- Fully managed: MongoDB Atlas is a fully managed service, meaning that it takes care of all the underlying infrastructure and management for you. This includes provisioning, patching, upgrades, backups, and more. 

- Scale on demand: MongoDB Atlas lets you scale your deployments on demand, so you only pay for the resources you use. You can also add or remove capacity as needed, so you can easily adjust to changing workloads. 

- Global deployments: MongoDB Atlas offers the ability to deploy MongoDB across multiple regions, so you can have low latency and high availability for your applications. 

- Secure by default: MongoDB Atlas has a number of features that help to keep your data safe, including encryption at rest and in transit, role-based access control, and more. 

- 24/7 monitoring and support: MongoDB Atlas comes with 24/7 monitoring and support from the MongoDB team, so you can always have someone to help you if you run into any problems.
Best Note taking app on your Mac
Tags: note, search, mac, tools
Published: 2022-10-15 17:07:44

I have used many note taking apps in the past and lately settled on **Notational Velocity** (NV) on a Mac. I have been using it for the past year or so and I LOVE IT!
 
_From the Notational velocity (NV) [website](https://notational.net)..._

> NOTATIONAL VELOCITY is an application that stores and retrieves notes. 
> It is an attempt to loosen the mental blockages to recording information and to scrape away the tartar of convention that handicaps its retrieval. The solution is by nature nonconformist.
> website link: https://notational.net 

Some key features:
- search is the main aspect of the app interface and is super simple and fast
- all notes content is 'encrypted' 
- no 'save' button; all notes get auto saved automatically
- it is Open Source!

You can create as many notes as you want. NV documentation says that the best way to use it is to create many notes vs having one note with a lot of text. NV says that it excels when the content is distributed. With my experience, I can relate to it and confirm that it works great to go through my hundreds of notes.  
 
Notational Velocity is pretty lightweight and has a very simple easy to use interface. The search is super fast and the highlighting of matching text makes it easy to look for/enter notes. The keyboard navigation is useful with its 'excruciatingly' simple shortcuts!

It does not offer fancy formatting features such as underlines, font size, font color/background color, font type etc. But, offers bold, italic, and strikethrough of the notes text. I have built my own system of using markdown tags, hashtags and identifiers to enter and search for notes. So, not having fancy formatting is not limiting at all. It has very useful feature to include "links" (hyperlinks) between notes within NV. 

I have used many tools such as VI editor within terminal (with grep and sed features), Notepad, Evernote, Simplenote, etc. I use NV locally on my Mac and do not use any synching with Dropbox or other cloud services. But, that feature is there for you to explore. 

In short, if you are looking for a powerful yet easy-to-use low-friction note taking native app, then check out Notational Velocity. You won't regret it.


A screenshot of the app with a list of keyboard shortcuts:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/de8jomfydu3o85hqkx22.png)
How to get the last element of an Array in Javascript
Tags: javascript, webdev, beginners, typescript
Published: 2022-10-15 16:39:11

So you have a Javascript array, and you want to get the last element. Take this example, for instance:
```javascript
let myArray = [ '🔩', '⚡️', '🔑', '🖇' ]
```

This array has 4 items - and as you might know, to get any element within it, we can use the square bracket notation `[]`. For example, to get the lighting bolt, we can use `myArray[1]`:
```javascript
let myArray = [ '🔩', '⚡️', '🔑', '🖇' ]
console.log(myArray[1]) // ⚡️
```

Since arrays start at an index of `0`, the first element is actually `myArray[0]`, and so on. So to get the last element of the array, we can use `myArray.length - 1`. This gets the length of the array (`4`), and subtracts 1, to take into consideration that arrays start counting at `0`. Therefore, to get the last element of an array using the square bracket notation, we can do something like this:
```javascript
let myArray = [ '🔩', '⚡️', '🔑', '🖇' ]
console.log(myArray[myArray.length-1]) // 🖇
```

This is the most common way to get the last element of an array. However, you can also use the `at` method to do the same thing:
```javascript
let myArray = [ '🔩', '⚡️', '🔑', '🖇' ]
console.log(myArray.at(myArray.length-1)) // 🖇
```

And even better, you can simply write `myArray.at(-1)`! This greatly simplifies getting the last element of an array to a simple expression:
```javascript
let myArray = [ '🔩', '⚡️', '🔑', '🖇' ]
console.log(myArray.at(-1)) // 🖇
```

As you might expect, `at` starts counting backwards, so `at(-2)` will return the key:
```javascript
let myArray = [ '🔩', '⚡️', '🔑', '🖇' ]
console.log(myArray.at(-2)) // 🔑
```
Updating Object Key Values with Javascript
Tags: webdev, javascript, typescript, beginners
Published: 2022-10-15 16:34:50

[Javascript objects](https://fjolt.com/article/javascript-objects-introduction) consist of key value pairs and are one of the most common data structures in Javascript. 

To update all values in an object, the easiest way is to:
1. Use `Object.keys` to get all keys of the object.
2. Apply any logic, to decide which values should be updated.
3. Update the value of each using a loop like `forEach` or `for`.

For example:
```javascript
let myObject = {
    name: "John", 
    skillItem1: 4,
    skillItem2: 7,
    skillItem3: 2,
    skillItem4: 1
}

// Updates any numerical values that are more than or equal to 4, and changes them to 10:
Object.keys(myObject).forEach((item) => {
    if(typeof myObject[item] == "number" && myObject[item] >= 4) {
        myObject[item] = 10
    }
})

console.log(myObject)
// Returns:
// let myObject = {
//     name: "John", 
//     skillItem1: 10,
//     skillItem2: 10,
//     skillItem3: 2,
//     skillItem4: 1
```

You don't have to apply logic - but it's usually useful. You can also achieve this with a `for` loop - which is slightly faster than using `forEach`:
```javascript

let myObject = {
    name: "John", 
    skillItem1: 4,
    skillItem2: 7,
    skillItem3: 2,
    skillItem4: 1
}

// Updates any numerical values that are more than or equal to 4, and changes them to 10:
for(let item of Object.keys(myObject)) {
    if(typeof myObject[item] == "number" && myObject[item] >= 4) {
        myObject[item] = 10
    }
}

console.log(myObject)
// Returns:
// let myObject = {
//     name: "John", 
//     skillItem1: 10,
//     skillItem2: 10,
//     skillItem3: 2,
//     skillItem4: 1
```

To update only one value in an object, use the square bracket notation `[]` to select which key you want to update. For example:
```javascript
let myObject = {
    name: "John", 
    skillItem1: 4,
    skillItem2: 7,
    skillItem3: 2,
    skillItem4: 1
}

// Updates `skillItem2` to 15
myObject['skillItem2'] = 15;
```

[Javascript objects are created by reference](https://fjolt.com/article/javascript-by-reference-by-value), which is a fancy way of saying that when we make the changes above, we are mutating the original object. That also means that `Object.values()` does not allow us to update the values of the object, which is why we have to use `Object.keys()`.
Waiting for the DOM to be ready in Javascript
Tags: webdev, javascript, typescript, beginners
Published: 2022-10-15 16:29:27

When you're working with Javascript, you're likely to have run into a pretty common problem: if your Javascript appears before your HTML, then trying to do things like attach events to your HTML is not possible. For example, consider this code:
```html
<!DOCTYPE HTML>
<html>
    <head>
        <script type="text/javascript">
            document.querySelector('#button').addEventListener('click', () => {
                console.log('You clicked me!')
            });
        </script>
    </head>
    <body>
        <button id="button">Click Me</button>
    </body>
</html>
```

Even though there is a button with the ID `#button`, this code actually throws an error. The reason why is because the Javascript is loading **before** the DOM. Therefore trying to query select for `#button` returns null:
```javascript
Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')
    at file.html:5:46
```

This is a pretty common problem related to DOM readiness - your HTML DOM has not loaded - so it is not ready to have Javascript applied to it.

## Waiting for the DOM to be ready in Javascript

If you want to wait for the HTML to load, before your Javascript runs - then try using `DOMContentLoaded`. We can wrap our entire Javascript in this event listener like so:
```javascript
window.addEventListener('DOMContentLoaded', () => {
    document.querySelector('#button').addEventListener('click', () => {
        console.log('You clicked me!')
    });
});
```

Now, no error will be produced in your code, since the code within the `DOMContentLoaded` event listener will only fire once the HTML is fired. That means you can continue to have your Javascript before your HTML, and encounter no issues. Of course, you can also solve this problem by putting your Javascript **after** your HTML - but this is not always possible.

I hope you've enjoyed this quick guide to DOM Readiness and `DOMContentLoaded` in Javascript.