teleren/devto huggingface dataset:
Most Commonly Used JavaScript Methods in 2023
Tags: javascript, webdev, codenewbie, programming
Published: 2022-09-28 23:47:29

Here is my list of the most commonly used JavaScript methods. If I missed something please comment.

**LENGTH** 
The Length method is use for get the numbers of characters in a string including white space.

```javascript
const str = "Thisis my code";
console.log(str.length);

Output: 14
```

You can use also this method to get the [length of any array in Javascript](https://devhubby.com/thread/how-to-get-length-of-array-in-javascript).

**SLICE**
slice() method is use for extracts a part of a string from a string and returns the extracted part in new string.

```javascript
const str1 = 'Thisismycode';
var output = str1.slice(6 , 12);

console.log(output);
// Output: code
```

**REPLACE**
The replace() method is use for replace a specific value with another value in a string.

```javascript
// replace method
const str2 = 'Thisismycode';
var output1 = str2.replace('my' , 'our');

console.log(output1);
// output: Thisisourcode
```

**UPPER AND LOWER CASE**
toLowerCase() method is use to convert the all character of a string into lower case and toUpperCase() method is use to convert the all character of a string into upper case.

```javascript
// upper and lower case method
const str3 = 'ThisismyCode';
var output2 = str3.toLowerCase();
var output3 = str3.toUpperCase();

console.log(output2);
console.log(output3);

// Output: 
thisismycode
THISISMYCODE
```

**CONCAT**
The method concat() is use for join two or more string.

```javascript
// concat method
const str4 = 'Thisismy';
var output4 = str4.concat('code');

console.log(output4);

// output: Thisismycode
```

Here is another great example of how to [concatenate two strings in javascript](https://devhubby.com/thread/how-to-concatenate-two-strings-in-javascript).

**TRIM**
The trim() method removes the white space from both side in a string.

```javascript
// trim method
const str5 = '     i love my code      ';
var output5 = str5.trim();

console.log(output5);

// output: 
i love my code
```

**CHARAT**
The charAt() method is use for get a character at a specific index from a string.

```javascript
// charat method
const str6 = 'ILoveMyCode';
var output6 = str6.charAt(5);

console.log(output6);

//outout: M
```

**SPLIT**
The split() method is use to [converts a string into an array](https://devhubby.com/thread/how-to-split-a-string-with-delimiter-in-javascript).

```javascript
// split method
const str7 = 'I ,Love ,My ,Code';
var output7 = str7.split(',');

console.log(output7);

//output: 
[ 'I ', 'Love ', 'My ', 'Code' ]
```

Please comment your thoughts about it or just like it :)
Code Smell 166 - Low-Level Errors on User Interface
Tags: webdev, beginners, programming, php
Published: 2022-09-28 23:35:17

*Fatal error: Uncaught Error: Class 'logs_queries_web' not found in /var/www/html/query-line.php:78 Stack trace: #0 {main} thrown in /var/www/html/query-line.php on line 718*

> TL;DR: Catch your errors. Even the ones you don't expect.

# Problems

- Security

- Error Handling

- Error Logging

- Bad UX Experience

# Solutions

1. Use a top-level handler

2. Avoid languages favoring [return codes](https://dev.to/mcsee/code-smell-72-return-codes-19p7)

3. Expect database and low-level errors

# Context

Even in 2022, we can see "serious" websites showing casual users a stack or debugging message.

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/8d71bdae68fc52a1b6d1c65e8ce944af)

```php

<?



Fatal error: Uncaught Error: Class 'MyClass' 

  not found in /nstest/src/Container.php:9

```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/3d16a49a680234811e19a56fd3d5be17)

```php

<?



// A user-defined exception handler function

function myException($exception) {

    logError($exception->description())

    // We don't show Exception to final users      

}



// Set user-defined exception handler function

set_exception_handler("myException");

```

# Detection

[X] Automatic 

We can use mutation testing to simulate problems and see if they are handled correctly.

# Tags

- Security

# Conclusion

We need to keep maturing. 

Our solutions shouldn't be sloppy.

We need to improve our reputation as serious software engineers.

# Relations

{% post https://dev.to/mcsee/code-smell-72-return-codes-19p7 %}

# More Info

{% post https://dev.to/mcsee/fail-fast-48dm %}

# Disclaimer

Code Smells are just my [opinion](https://dev.to/mcsee/i-wrote-more-than-90-articles-on-2021-here-is-what-i-learned-1n3a).

# Credits

Photo by [jesse orrico](https://unsplash.com/@jessedo81) on [Unsplash](https://unsplash.com/s/photos/dirty)  

* * *

> 80 percent of my problems are simple logic errors. 80 percent of the remaining problems are pointer errors. The remaining problems are hard.

_Mark Donner_
 
{% post https://dev.to/mcsee/software-engineering-great-quotes-26ci %}

* * *

This article is part of the CodeSmell Series.

{% post https://dev.to/mcsee/how-to-find-the-stinky-parts-of-your-code-1dbc %}
.NET MAUI
Published: 2022-09-28 23:01:42

[Tutorial: Create a web API with ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-6.0&tabs=visual-studio)

[Announcing the .NET MAUI Beautiful UI Challenge](https://devblogs.microsoft.com/dotnet/announcing-dotnet-maui-beautiful-ui-challenge/)

[Snppts is a community-run website helping aggregate beautiful .NET MAUI UI snippets for and from the community. ](https://snppts.dev/)

[.NET Architecture Guides](https://dotnet.microsoft.com/en-us/learn/dotnet/architecture-guides)

[Tutorial: Create a .NET MAUI app using the Microsoft Graph SDK](https://docs.microsoft.com/en-us/windows/apps/windows-dotnet-maui/tutorial-graph-api)

[Use Postman with the Microsoft Graph API](https://docs.microsoft.com/en-us/graph/use-postman)

[Tutorial: Create a .NET class library using Visual Studio for Mac](https://docs.microsoft.com/en-us/dotnet/core/tutorials/library-with-visual-studio-mac)

[.NET MAUI eBook Now Available – Enterprise Application Patterns](https://devblogs.microsoft.com/dotnet/dotnet-maui-ebook-released/)

[.NET Multi-platform App UI documentation](https://docs.microsoft.com/en-us/dotnet/maui/)

[Tutorial - Enable your Web Apps to sign-in users and call APIs with the Microsoft identity platform for developers](https://learn.microsoft.com/en-us/samples/azure-samples/active-directory-aspnetcore-webapp-openidconnect-v2/enable-webapp-signin/)
How to trim a video using FFMPEG
Tags: audiovideo
Published: 2023-01-06 02:59:26

---
title: How to trim a video using FFMPEG
published: true
date: 2022-09-28 22:46:32 UTC
tags: AudioVideo
canonical_url: https://brandonrozek.com/blog/trim-video-ffmpeg/
---

Recently I came across a video that I wanted to split up into multiple files. Given my love for `ffmpeg` the video/audio swiss army knife, I knew there had to be a solution for cutting a video on the terminal. Luckily on [AskUbuntu](https://askubuntu.com/a/56044), Luis Alvarado provides a command snippet. This post will go into slightly more detail on the flags used in the command

```
ffmpeg -ss 00:00:00 \
	-t 00:30:00 \
	-i input.mp4 \
	-vcodec copy \
	-acodec copy \
	output.mp4

```

| Command | Description |
| --- | --- |
| `-ss` | Position within the input file. Most file formats do not allow exact seeking, so ffmpeg will pick the closest seek point. Format is in _time duration_ notation. |
| `-t` | Limits the duration of data read from the input file. Format is in _time duration_ notation. |
| `-vcodec` | Format used to transcribe the video. Use `copy` to not transcribe to a different format. |
| `-acodec` | Format used to transcribe the audio. Use `copy` to not transcribe to a different format. |

Time duration notation follows the format `<HH>:<MM>:<SS>` where `HH` is the number of hours, `MM` is the number of minutes, and `SS` is the number of seconds.

For this command in general, the output video length would be the same time duration as specified in the `-t` flag.
Creating Ephemeral Environments for CI/CD (GitOps) Pipelines with Kubernetes
Tags: kubernetes, github, git, cicd
Published: 2022-09-28 21:50:01


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ddfnhgftp30w8i8kpmvt.png)
🌐 [Upcoming Webinar] Testing your application in a production-like environment can help you catch bugs early in the development life cycle and increase the overall quality of the shipped product. However, setting up your CI/CD pipeline in a way that allows you to set up ephemeral production-like environments is not a trivial undertaking.

But... Kubernetes can help. Join [Sorin Dumitrescu](https://www.linkedin.com/in/sorin-dumitrescu/), VP of Engineering, and [Cristian Blanaru](https://www.linkedin.com/in/cristian-blanaru-614ba559/), SRE team lead as they explore 🔍:

☑️ How to use Kubernetes to create cost-effective, ephemeral environments that look like production
☑️ How to easily integrate GitLab and GitHub pipeline testing with Bunnyshell using ephemeral environments
☑️ How to run tests automatically for every PR to accelerate code quality and see all changes in real-time before each merge

#development #testing #engineering #kubernetes #environment

https://hubs.la/Q01n8VXN0
Nx the Smart, Fast and Extensible Build System
Tags: webdev, javascript, beginners, podcast
Published: 2022-09-28 22:33:04


Original: https://codingcat.dev/podcast/2-41-Nx-the-Smart-Fast-and-Extensible-Build-System

{% youtube https://youtu.be/hW3Nt6cOj_c %}

## Questions

1. Can you tell us more about yourself?
2. Monorepos - What, Why, How
3. Packaged-based vs Integrated Monorepos
4. Importance of Dx when it comes to monorepo tooling
5. How do you make sure your CI times don’t explode
6. Can you compare Nx to Turbo Repo?
DAY 08: Combine two tables
Tags: java, codereview, codepen
Published: 2022-09-28 22:23:26

Hey! it's day 8 of 10 days coding challenge with I4G. Today's task was to write an SQL code to combine two tables.

**Thought process:**

- **Understanding of problem:** The task here requires combine two tables in an SQL. The first table Person contains the first and last name while the second table contains the address of the person. So, it is required that the two tables be combined such that a single table with the person's name and address is obtained.
- **Solution:** To be able to access a single person's data in both table, a personal id assigned to each table must be the same. To fetch the detail, we simply select the names from the first table and use LEFT JOIN to combine it with the address in the second table where both personal id is the same. If no matching details is found a null is returned.

Algorithm:

- Select first and last name from the Person table
- Select city and state from the Address table
- Condition: personal id in both table must be same
- use left join to combine the address with the names

Checkout the full code here: Combine Two Tables - LeetCode https://leetcode.com/problems/combine-two-tables/submissions/
Dynamically Using mailto:
Tags: javascript, webdev, tutorial, html
Published: 2022-09-28 22:21:08

If you want to use `mailto:` tag when you're handling emails you can do this simple trick to make life easier for the consumers.

Been using `mailto:` the normal way until I found out you can actually customize it way more.

Here's what I use for my site (Slightly edited to not advertise)

```js
`mailto:${contact}?subject=Application for ${title}&body=Hi ${username}, I am interested in your listing for ${title} that I found listed on [R E D A C T E D]. I would like to know more about it.`
```

The queries you're able to use are:
- mailto: (to set the recipent, you can separate this with commas)
- &subject= (this will set the subject for the email, use URL encoding if you're sending long messages)
- &body= (Same as subject but instead you're setting the actual email message)
- &cc= (Setting CC recipents)
- &bcc (Setting BCC recipents)

Hope this helped!
✨ Most rated crypto related GitHub libraries
Tags: crypto, javascript, python, github
Published: 2022-09-28 22:16:15

There are a lot of GitHub open source crypto libraries
Here is a list of most rated crypto-related libraries:

## [Bitcoin Core integration/staging tree - 66.3k stars](https://github.com/bitcoin/bitcoin)

![Bitcoin generated image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4hrqmizqo309m1tra5f9.png)

Bitcoin Core connects to the Bitcoin peer-to-peer network to download and fully validate blocks and transactions. It also includes a wallet and graphical user interface, which can be optionally built.

## [Go Etherum - 39.5k stars](https://github.com/ethereum/go-ethereum)

![Etherum generated library](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u9pu1hzu9mr214h1yxn0.png)
Official Go implementation of the Ethereum protocol

## [CCXT – CryptoCurrency eXchange Trading Library - 25.8k stars](https://github.com/ccxt/ccxt)

![Javascript php python library for trading](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jnqrs2lf1n67f8d4qp1p.png)
A JavaScript / Python / PHP library for cryptocurrency trading and e-commerce with support for many bitcoin/ether/altcoin exchange markets and merchant APIs.

## [Mastering Bitcoin 2nd Edition - Programming the Open Blockchain - 20.4k stars](https://github.com/bitcoinbook/bitcoinbook)

![Mastering bitcoin](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/08lb68c27x4fmj1i9r5g.png)
Mastering Bitcoin is a book for developers, although the first two chapters cover bitcoin at a level that is also approachable to non-programmers. Anyone with a basic understanding of technology can read the first two chapters to get a great understanding of bitcoin.

## [Freqtrade - 19.3k stars](https://github.com/freqtrade/freqtrade)

![Freqtrade](https://bestcryptolibs.com/media/freqtrade.png)
Freqtrade is a free and open source crypto trading bot written in Python. It is designed to support all major exchanges and be controlled via Telegram or webUI. It contains backtesting, plotting and money management tools as well as strategy optimization by machine learning.

Source:
[Best Crypto Libraries](https://bestcryptolibs.com/)
HacktoberFest 2022 | Repositories
Tags: hacktoberfest, opensource, javascript, python
Published: 2022-09-28 21:40:24

**HacoberFest 2022 is starting.**

[Github link](https://github.com/kavyanshpandey)

Do Your Pull Requests on above github acocunst pinned repositories, All will be count towards completion 🚀🙂❤️

#Hacktoberfest #Hacktoberfest2022
Welcome Thread - v193
Tags: welcome
Published: 2022-09-28 21:34:28

---
title: Welcome Thread - v193
published: true
description: Welcome to DEV! A thread of hellos and intros.
tags: welcome
canonical_url: 
---

![Baby Groot waving hey in an endless loop](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x9hx48ylnxd8w71crsqz.gif)

### Welcome to DEV!

1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋 

**Great to have you in the community!**
Closure + Arrow function = extremely short
Tags: javascript, beginners
Published: 2022-09-28 21:33:38

▼ If you don't know about Closure, I've already written about it
{% link https://dev.to/kaziusan/javascript-closure-i-think-you-can-get-what-it-is-finally-after-reading-this-14d6 %}

There is this closure function
```javascript
function addCountFactory(num) {
    function addCount(value) {
        return num + value;
    }
    return addCount;
}

const addOne = addCountFactory(1);
const result = addOne(10);
console.log(result); // 11
```

If I change it to arrow function, it would be like this

### 1
```javascript
const addCountFactory = num => { // ⭐ here
    function addCount(value) {
        return num + value;
    }
    return addCount;
}
```

### 2
remove unnecessary **return**
```javascript
const addCountFactory = num => {
    return function addCount(value) { // ⭐ here
        return num + value;
    }
    // ⭐ delete "return addCount"
}
```

### 3
name of function is not necessary
```javascript
const addCountFactory = num => {
    return function(value) { // ⭐ here
        return num + value;
    }
}
```

### 4
just delete { } block
```javascript
const addCountFactory = num => function(value) {
        return num + value;
}
```

### 5
change to arrow function
```javascript
const addCountFactory = num => value => num + value;
```

When you see it at first time, you would react like "wtf???", but actually it's just closure. Function in function
#10daysofcodechallenge by Ingressive for Good (#Day 8)
Tags: mysql
Published: 2022-09-28 21:21:26

I am close to the end of a 10-day coding challenge organized by Ingressive for Good and I'll be sharing my thoughts on Day 8 of the challenge.

Let me briefly describe how the challenge works before I share my experience with you. From September 21 through October 30, 2022, the challenge is to solve one common algorithm problem every day for ten days.

Today's algorithm problem was "Combine Two Tables" It is the 175th algorithm challenge on "Leetcode.com".

Here is the question:
Table: Person
+-------------+---------+
| Column Name | Type    |
+-------------+---------+
| personId    | int     |
| lastName    | varchar |
| firstName   | varchar |
+-------------+---------+
personId is the primary key column for this table.
This table contains information about the ID of some persons and their first and last names.
 
Table: Address
+-------------+---------+
| Column Name | Type    |
+-------------+---------+
| addressId   | int     |
| personId    | int     |
| city        | varchar |
| state       | varchar |
+-------------+---------+
addressId is the primary key column for this table.
Each row of this table contains information about the city and state of one person with ID = PersonId.
 
Write an SQL query to report the first name, last name, city, and state of each person in the Person table. If the address of a personId is not present in the Address table, report null instead.
Return the result table in any order.

I visited w3schools.com to learn more about MySQL because I had never used it to resolve issue. As a result, I used the SELECT command to retrieve fields from the person table and the LEFT JOIN command to join the address table to the person table.

This task was completed in MySQL, took 525 milliseconds to execute, and consumed 0B of memory.
Hashicorp Vault Key Value I (KV) Secrets Engine
Tags: vault, devops, cicd, cloud
Published: 2022-09-28 21:20:29

## Introduction

This tutorial assumes you have a work Vault server and are logged in with the root token.

https://dev.to/frederickollinger/production-hashicorp-vault-minimal-configuration-485a

## What is a Secrets Engine

"Secrets engines are components which store, generate, or encrypt data."

## What is the KV Engine

This engine allows you to store key/value pairs.

A KV2 engine also exists which introduces more complexity. This tutorial will confine itself to the KV1 secrets engine.

## Turn on KV Engine

The KV engine is not on my default.

Switch it on:

```sh
vault secrets enable -path=kv kv
```

## Create First Secret

```sh
vault kv put kv/my-secret my-value=bluedragon
```

## Get First Secret

```sh
vault kv put kv/my-secret my-value=bluedragon
```

## Get First Secret


## Links

1. Minimal Vault Server Setup

https://dev.to/frederickollinger/production-hashicorp-vault-minimal-configuration-485a

2. Vault Secrets

 https://www.vaultproject.io/docs/secrets
Virtual Threads In Java
Tags: java, kotlin, concurrency, programming
Published: 2022-09-28 21:08:17

## Virtual threads deliver what they promise: making concurrency easy to use. 


**The change is minimal, instead of classic ThreadPool you can use newVirtualThreadPerTaskExecutor**. That's all!


Thanks to Java 19 is now possible to create high-throughput applications using a lightweight concurrency model (similar to coroutines in Kotlin). This would be accomplished via virtual threads.


Spring Boot already supports Java 19 but we have to be patient cause still in preview mode. 

## Demo Java

https://github.com/jorgetovar/java-loom-project

*Blocking task*
```java
    public Integer call() throws InterruptedException {
        Thread.sleep(1000);
        return number;
    }
```
*Process 1_000 blocking task*

```java
    public void process(String threadPoolType) throws InterruptedException, ExecutionException {

        try (ExecutorService executor = executorService) {
            List<Task> tasks = IntStream.range(0, 1_000)
                    .mapToObj(Task::new)
                    .collect(Collectors.toList());

            long time = System.currentTimeMillis();

            List<Future<Integer>> futures = executor.invokeAll(tasks);

            long sum = 0;
            for (Future<Integer> future : futures) {
                sum += future.get();
            }

            time = System.currentTimeMillis() - time;
            log.info("Result = {} ThreadPool sum: {} in {} ms", threadPoolType, sum, time);
            executor.shutdown();
        }
    }
```

*Process with Loom & Classic ThreadPool task**

```java
    @Override
    public void run(String... args) throws Exception {
        ExecutorService loom = Executors.newVirtualThreadPerTaskExecutor();
        ExecutorService classic = Executors.newFixedThreadPool(100);
        VirtualThreads virtualThreads = new VirtualThreads(classic);
        virtualThreads.process("classic");
        virtualThreads = new VirtualThreads(loom);
        virtualThreads.process("loom");
    }
```
*Output*
```shell
- : Started DemoApplication in 0.373 seconds (JVM running for 0.66)
- : Result = classic ThreadPool sum: 499500 in 10062 ms
- : Result = loom ThreadPool sum: 499500 in 1015 ms
```

## Demo Kotlin

*Coroutines*
```kotlin
    measureTimeMillis {
        runBlocking {
            repeat(1_000) { i ->
                launch {
                    call(i)
                }
            }
        }
    }.also {
        print("Result = Coroutines finished in $it ms")
    }

```
*Output*
```shell
Result = Coroutines finished in 1064 ms
```
## Conclusion

Project Loom is a game changer for Java. It will allow developers to create high concurrent applications without changing the paradigm or making big changes to the current code.
SOFTWAREHUBS - The most trusted brand & software HUBs in the world
Tags: software
Published: 2022-09-28 21:06:52

SOFTWAREHUBS provides over 2000 curated software brands, eLearning providers, and tech services in one synced hub. We have signed with many reputable brands, including Microsoft (Microsoft Office, Microsoft Server), Corel, AutoDesk, Alphabet, Adobe, Kaspersky Lab, Intel, IBM, and more. Besides that, we are affiliated with potential technology startups and reputable payment gateways to trade in the most diverse way, grasping the actual use needs of users in the fastest way.

[https://www.softwarehubs.com](https://www.softwarehubs.com)