teleren/devto huggingface dataset:
Shotstack Virtual Hackathon: Build Awesome Media Apps
Tags: news, hacktoberfest, webdev, programming
Published: 2022-09-23 04:49:16

We're excited to announce the Shotstack's first ever virtual hackathon is starting on 26th September 2022. Shotstack is inviting builders to join us to build awesome media applications. 

Digital media is an integral part of our lives. With the rise of AI and automation, it is evolving as fast as ever. [Shotstack API ](https://shotstack.io/product/video-editing-api/)enables builders to rapidly develop and launch media apps so you get to build the next big media product. 

**Shotstack's virtual hackathon** is a great way to showcase your idea, skills, and get along with the community that have similar interest.

[Visit our website](https://shotstack.io/learn/first-shotstack-public-hackathon/) to learn about the hackathon.

Register for the hackathon below 👇
[https://forms.gle/r2sqyFRmz7Sr7JUVA](https://forms.gle/r2sqyFRmz7Sr7JUVA)
WFMA Agency Shares How TO Rank Higher in Search
Tags: seo, digitalmarketing, management, marketingagency
Published: 2022-09-23 04:47:47

Marketing is a game of strategy, the right kind of framework working behind it, and smart work. 
Learn how this emerging [digital marketing agency](https://wfma.agency/top-5-ways-to-rank-higher-on-search-in-2022/) is utilizing wholesome SEO Marketing & Cross marketing to have a fast result. The top 5 ways to rank their client sites.
1680. Leetcode solution in cpp
Tags: cpp
Published: 2022-09-23 04:25:12

```
class Solution {
public:
    int concatenatedBinary(int n) {
        long ans = 0, mod = 1e9+7;
        for (int i = 1; i <= n; ++i) {
            int len = 0;
            for (int j = i; j; j >>= 1, ++len);
            ans = ((ans << len) % mod + i) % mod;
        }
        return ans;
    }
};
```

#leetcode
#challenge
here is the link for the problem: 
https://leetcode.com/problems/concatenation-of-consecutive-binary-numbers/
What is the difference between list.sort() and sorted() in Python?
Tags: python, beginners, programming
Published: 2022-09-23 04:21:52

Python provides two ways to sort a list, the built-in list method `list.sort()` and the built-in function `sorted()`. Although both will sort the elements of a list, if used incorrectly they can produce unexpected or undesired results.

### Differences and similarities

The primary difference between the two is that `list.sort()` will sort the list in-place, mutating its indexes and returning `None`, whereas `sorted()` will return a new sorted list leaving the original list unchanged. Another difference is that `sorted()` accepts any iterable while `list.sort()` is a method of the `list` class and can only be used with lists.

```py
nums = [2, 3, 1, 5, 6, 4, 0]

print(sorted(nums))   # [0, 1, 2, 3, 4, 5, 6]
print(nums)           # [2, 3, 1, 5, 6, 4, 0]

print(nums.sort())    # None
print(nums)           # [0, 1, 2, 3, 4, 5, 6]
```

Both `list.sort()` and `sorted()` have the same `key` and `reverse` optional arguments and can be called on each list element prior to making comparisons.

### When to use each one

`list.sort()` should be used whenever mutating the list is intended and retrieving the original order of the elements is not desired. On the other hand, `sorted()` should be used when the object to be sorted is an iterable (e.g. list, tuple, dictionary, string) and the desired outcome is a sorted list containing all elements.

---

_Do you like short, high-quality code snippets and articles? So do we! Visit [30 seconds of code](https://www.30secondsofcode.org/) for more articles like this one or follow us on [Twitter](https://twitter.com/30secondsofcode) for daily JavaScript, React and Python snippets!_ 👨‍💻
Digital Marketing
Tags: digital, marketing
Published: 2022-09-23 04:06:16

Simply said, we don’t think of cookie-cutter answers. We are a full- Tactics require a driver. You must use our sales strategist, web developer, writer, SEO analyst, and other specialists to collaborate, innovate, and go beyond limits to get the results you want. When you work with Dhanda Dekho, you get a team of strategic, data-driven experts who are committed to your success. With
 more than 25 in-house experts, we have the experience and knowledge to help your business succeed. Whether you need a dynamic, performance-driven campaign or an ongoing strategic agency partnership to assist you to speed up your sales goals, we have the experience and expertise to help.
jQuery After And Before Example
Tags: jquery, javascript, after, before
Published: 2022-09-23 03:58:26

In this article, We will see examples of the jquery after() and before() methods. The before() method inserts specified content before the selected elements. 

The after() method inserts specified content after the selected elements.

Using the jquery after() method you can append HTML after div, append text to div, and jquery add text after span. 

Using the before() method you can add HTML before div, append HTML before div, append text before div, and jquery add text after span.

> Example: After() Method

In this example, we will append HTML after p tag.  It appends some text to the element on the button click event.

Syntax:

```
$(selector).after(content);
```

```
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("p").after("<p>Hello, Techsolutionstuff !!</p>");
  });
});
</script>
</head>
<body>

<h3>Jquery After And Before Example - Techsolutionstuff</h3>
<p>This is a paragraph tag.</p>

<button>Insert content after P tag</button>

</body>
</html>
```

> Example: Before() Method

In this example, we will append HTML before p tag.  It appends text to the element on the button click event.

Syntax:

```
$(selector).before(content);
```

```
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("p").before("<p>Hello, Techsolutionstuff !!</p>");
  });
});
</script>
</head>
<body style="padding:20px;">

<h3>Jquery After And Before Example - Techsolutionstuff</h3>
<p>This is a paragraph tag.</p>

<button>Insert content before P tag</button>

</body>
</html>
```
Tips: How to get last element of an array in javascipt
Tags: javascript, beginners, programming, webdev
Published: 2022-09-23 03:56:54

An array is a data structure, which can store a fixed-size collection of elements of the same data type

If you have worked with JavaScript arrays before, you might know that they can be destructured much like objects. This is most commonly used to extract the first value of an array or the values of an array with a known length.

But destructuring can go much further, as it allows you to extract the `length` property of an array. Add this to the fact that extracted variables can be used in the destructuring assignment itself and you can put together a one-liner to extract the last element of an array.

```javascript
const arr = [1, 2, 3];
const { 0: first, length, [length - 1]: last } = arr;
first; // 1
last; // 3
length; // 3
```

While this technique is interesting, it has a couple of caveats. First off, you have to extract the length property, which creates an additional variable for it. And secondly, it doesn’t have any significant performance advantages over other options, such as using ` Array.prototype.slice()`. 



Another way we can do is, first we need array length then subtract 1 to get the last element index.

Take a look at code

```javascript
const arr = [1, 2, 3];
const lastEle = arr[arr.length - 1]
lastEle; // 3
```


arr.length = 3
3 – 1 = 2
arr[2] = 3

website [DevvSakib.Me](https://devvsakib.me/blog)
5 Tips for Black Women Learning How to Code
Tags: javascript, blackwomenintech, career, codenewbie
Published: 2022-09-23 03:05:08

Black women face unique challenges when attempting to start a career as developers or software engineers. We are often doubted and underestimated, and consequently suffer from lack of representation and made to work twice as hard. YET, we are more than capable of excelling in the field! If you are a Black woman who'd like to learn how to code and become a software engineer (or if you know one), here are 5 tips to help you out:

1. See yourself there Find Black women in tech on social media (Instagram, Twitter, YouTube and LinkedIn) and follow them! Keeping your goals within sight will motivate you to achieve them. Seeing women who look like you succeeding in their tech careers will help you remember that you are just as capable.

2. Use free learning resources There is a pervading belief that you must have a computer science degree or pay for an expensive bootcamp to become a software engineer. While every educational path has its own merits, you can achieve your goal by leveraging free educational resources online such as free coding bootcamps like the Ada Developers Academy!

3. Don't doubt your intelligence Another pervading belief is that you need to be super smart or some sort of math genius to learn how to code. The truth is, unless you're in a super specialized field, most software development jobs require relatively little math. Genius or not, you will be fine! Coding may get challenging but it's achievable so I believe you should practice and learn ways to be kind to yourself while learning. One way to do this is to stop yourself when you say something negative about your learning journey and reframe it with a more positive statement. For example, try replacing "'I'm so dumb', 'this was a dumb mistake', or 'I should've fixed this by now'" to "I'm learning something new and stepping outside of my comfort zone so I need to be patient with myself."

4. Recognize that Imposter Syndrome is lying to you Imposter syndrome is the belief that you are a fraud or don't deserve to be successful. It might make you question your decision to even attempt your development career and nip it in the bud. But guess what? Imposter syndrome is one big liar. You deserve your success because you've worked hard to achieve it. Don't feel unworthy of good things because you're not perfect - no one is.

5. Hurtful comments are not your truth As a Black woman in tech, you might unfortunately have to experience people doubting you in various ways. other people's doubts about your skills or motives, however, only speaks to their limiting beliefs and prejudices, not your true ability. Whatever they say or think, refuse to accept it as your reality because it isn't. You know who you are, you know what you can do, and you know what you are worth. Their opinions don't matter.

I hope this encourages you to step up and take ownership of your tech career! Have a good one :)
Why should I care about SBOMs as a Software Developer ...
Tags: news, devops, security
Published: 2022-09-23 03:02:32

> In the future full of SBOMs, be the VEX that can reduce the volume. 


Last week, the US White House released a memorandum on software supply chain security (link in comments). SBOM was a heavily featured word in the same...

## SBOM - Software Bill Of Materials

3-4 types of professionals should take notice:

1) **Software Developers [Suppliers?]**: Of course, this is a no brainer! Developers will be required to define and create SBOMs for every release you will do in the future. Also, Devs will have to adhere to standards expected by the ecosystem. Don't worry, there are tools available. Some are mentioned in the comments.

2) **Software Buyer/Procurement team**: Inspect the licenses(open vs proprietary), the package, the components and vulnerabilities that unfortunately tag along. Insist on SBOMs to get transparency on all of these items!

3) **Software Operators / Security Professionals**: You will need to worry about how to consume and interpret SBOMs. SBOMs will basically help you with details on what vulnerabilities are part of your entire software supply chain. You will then need tools / frameworks like 

## VEX - Vulnerability Exploitability eXchange.

To reduce the work done by software users for looking into non-exploitable vulnerabilities that don’t ultimately manifest in the final software product, Software Developers can issue a **VEX that clarifies** the vulnerability's status:
- Not affected - No remediation required.
- Affected - Remediation needed.
- Fixed - Version that's got a patch/fix of previously detected vulnerability.
- Under Investigation - Vulnerability status is unknown but to be clarified in the future.

{Important links about SBOMs have been included in the post comments.}
Rails guide - Adding tests - Part 4
Tags: ruby, rails, beginners, testing
Published: 2022-09-23 02:54:19

Hey guys! How are you?

This article is a part of a series that will teach how to create a production ready rails application. Today we're gonna talk about testing with rspec.

# Table of content

- [What is Rspec](#what-is-rspec)
- [Setting up environment](#setting-up-environment)
- [Configuring Rspec](#configuring-rspec)
- [Test it out](#test-it-out)


# What is Rspec

[Rspec](https://rspec.info/) is a ruby gem that allow us to test our applications, it provides the best way to do TDD while developing new features.

# Setting up environment

We need to follow those instructions to get rspec working:

### Install the gems

```ruby
group :test do
  # Rspec
  gem "rspec-rails", "~> 5.1.2"

  # Fake data generator
  gem "faker", "~> 2.23.0"

  # Clean database before each test execution
  gem "database_cleaner-active_record", "~> 2.0.1"

  # Factories
  gem "factory_bot_rails", "~> 6.2.0"

  # Models specs
  gem "shoulda-matchers", "~> 5.1.0"
end
```

### Download the dependencies

```sh
bundle install
```

### Generate Rspec configuration files

```sh
rails generate rspec:install
```

### Require rails helper

To properly run specs we need to require rails helper on top of each spec file, to prevent this we can create a file called `.rspec` in the root path of the application and put the following content there:

```sh
--require rails_helper
```

# Configuring Rspec

Now that we have all the setup done we need to properly configure rspec, to do so we need to edit `rails_helper` and `spec_helper`. You'll find the full code snippet in a pull request in the end of the article, nut here's a quick explanation of some important points:

### Rails Helper

This file stores all rspec general configuration and some dependencies configurations such as factory_bot and shoulda_matchers. Another important thing is that on the top of the file we have a guard clause that prevents rspec to run in a environemnt different thant test, you should never remove this safe guard

### Spec Helper

This file is simpler, it contains only some inclusions and basic setup, rails_helper requires this file to improve it configuration

# Test it out

Now that everything should be ok lets test it out. To do so we need to create a spec file and verify if it's passing.

Create a file under the `spec` folder called `test_spec.rb` and put the following content there:

```ruby
RSpec.describe do
  describe "rspec setup" do
    it "returns true" do
      expect(true).to be(true)
    end
  end
end
```

Now all you need to do is run rspec using this command:

```sh
rspec
```

You should look something like this if everything is ok:


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

You can either specify somethings to this command such as the file and line it should execute, here's an example:

```sh
rspec spec/test_spec.rb
rspec spec/test_spec.rb:3
```

You can see all the code changed [here](https://github.com/augusto-queirantes/rails_guide/pull/3)
Python Function Arguments
Tags: python, programming, 100daysofcode
Published: 2022-09-23 02:08:30

An argument is a value that is passed to a function when it is called. It might be a variable, value, or object passed to a function or method as input. 

In python, there are 3 different types of arguments we can give a function. 

<u>Default arguments</u>: arguments that are given default values 

<u>Positional arguments</u>: arguments that can be called by their position in the function definition

<u>Keyword arguments</u>: arguments that can be called by their name.
## Default argument
We can give a default argument by using an assignment operator `=`. This will happen in the function declaration. 
Example:

```
def find_dinner_total(food, drinks, tip):
  print(food + drinks + tip =15)
```
Our function is called `find_dinner_total()` which will calculate the total cost for dinner 🍽️. In our example our default argument is tip =15.
We can either choose to call the function without providing a value (this will result in the default value to be assigned) OR we can overwrite the default argument by entering a different value.

## Positional argument 

```
def find_diner_total(food, drinks, tip):
  print(food + drinks + tip)
```
The first parameter passed is `food`, second `drinks`, and third is `tip`.
When our function is called, the position of the arguments will be mapped based on the positions that are defined in the function declaration.
Example:
```
# $70 total for food
# $30 total for drinks
# 15 tip
diner_bill(70, 30, 15)

```
## Keyword Arguments

In Keyword Arguments, where we refer to what each argument is assigned to in the function call. 
Example:
```
dinner_bill(drinks=30, food=70, tip=15)
```
AWS Lambda Gotchas
Tags: aws, lambda, gotcha
Published: 2022-09-23 01:34:15

This post includes few gotchas on AWS Lambda.

### 1)  Lambda Python Runtimes - Python 3.6/3.7 are Amazon Linux 1 and Python 3.8/3.9 are Amazon Linux 2

Python 3.6/3.7 are Amazon Linux 1 and Python 3.8/3.9 are Amazon Linux 2.

In general it should be fine to upgrade from Python 3.6 to 3.9.

But there are cases you'll need to make some changes. For example, if you have code utilizing some sys call, e.g. `curl` - `curl` is not installed in Amazon Linux 2 by default.


### 2)  AWS CLI not allowing valid JSON in payload parameter with lambda invoke

If you see error like `Invalid base64:`, it could be because since awscli 2, payloads need to be base64 encoded when invoking a Lambda function.

> By default, the AWS CLI version 2 now passes all binary input and binary output parameters as base64-encoded strings. A parameter that requires binary input has its type specified as blob (binary large object) in the documentation.

You will need to pass in also `--cli-binary-format raw-in-base64-out`. For example:
```
aws lambda invoke --function-name testsms \
    --invocation-type Event \
    --cli-binary-format raw-in-base64-out \
    --payload '{"key": "test"}' response.json
```
See also
- https://github.com/aws/aws-cli/issues/4968
- https://stackoverflow.com/questions/60310607/amazon-aws-cli-not-allowing-valid-json-in-payload-parameter


### 3)  Cannot do `ping` from Lambda Function

See [AWS Lambda FAQs](https://aws.amazon.com/lambda/faqs/)
> Lambda attempts to impose as few restrictions as possible on normal language and operating system activities, but there are a few activities that are disabled: Inbound network connections are blocked by AWS Lambda, and for outbound connections, only TCP/IP and UDP/IP sockets are supported, and ptrace (debugging) system calls are blocked. TCP port 25 traffic is also blocked as an anti-spam measure.


### 4)  Code storage for uploaded Lambda functions (`CodeStorageExceededException`)

The Lambda service stores your function code in an internal **S3 bucket** that's private to your account. Each AWS account is allocated **75 GB of storage in each Region** (and can be increased up to Terabytes). Code storage includes the total storage used by both **Lambda functions and layers**. If you reach the quota, you receive a **`CodeStorageExceededException`** when you attempt to deploy new functions.

See [Lambda quotas](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html).

To see the storage used

1. From AWS Lambda console > Dashboard
2. From AWS CLI:
    ```
    aws lambda list-versions-by-function --function-name myTestFunction
    aws lambda get-layer-version --layer-version --layer-name TestLayer --version-number 2
    ```
    This returns each published version of the function/layer together with the $LATEST version. The CodeSize attribute shows the total number of bytes used by code storage of this function/layer.

See [Monitoring Lambda code storage](https://docs.aws.amazon.com/lambda/latest/operatorguide/code-storage.html).
Open Source Lab 2
Published: 2022-09-23 01:17:43

In my second lab, I am continuing my work on my SSG. This time we are working with someone else's SSG and implementing reading a markdown file and creating an HTML document with the corresponding HTML tags for example # is the tag <h1> and * is the tag for indenting. For this lab, I also worked with Tong.

# Changes to my SSG  

[My Repo](https://github.com/P-DR0ZD/pdrozd-ssg)

[Tong's Issue](https://github.com/P-DR0ZD/pdrozd-ssg/issues/6)

[Tong's Request](https://github.com/P-DR0ZD/pdrozd-ssg/pull/9)

Tong Added Heading support for my Python SSG. When reviewing it I noticed his HTML wasn't consistent with the format I had done with my previous work so I asked him to fix the issue after that I didn't notice any other issues.

# Changes to Tong's SSG

[Tong's Repo](https://github.com/liutng/SSGifier)

[My Issue](https://github.com/liutng/SSGifier/issues/7)

[My Request](https://github.com/liutng/SSGifier/pull/9)

For Tong's SSG, I wanted to add two features so I decided I wanted to add the Heading tags and Italics Tags. To begin I needed to understand his code and how his code is formatted so that when I added something to his code it fits and he would be able to understand what it does. I then saw that he had a function that take the text file and send it to another function that would parse a text file. I decided I would remake those two functions but instead add markdown support to them so that when he needs the markdown version rather than the text version he uses the one corresponding to the file type.

In my previous work with Tong, I noticed an issue with files of incorrect types being processed Tong's fix for the issue was for when an incorrect file type was in a directory it didn't include using the incorrect file type on its own so I decided to fix this issue too.

Finally, after Tong reviewed my issue he asked me to document the changes I made so he can understand where I made the changes to his code and what the changes do

# Conclusion

Overall I understand how pull requests work with GitHub Much better I now understand that when you make an initial Pull request changes can still be made and that you don't need a new pull request for that.
Can't install Node below version 15? Here's how.
Published: 2022-09-23 01:15:06

## Requirements
In order to continue with this article please have [nvm](https://github.com/nvm-sh/nvm#readme) installed on your device.

## Background
If you have an [Apple Silicon Device](https://support.apple.com/en-us/HT211814) (usually newer MacBooks) you probably saw an error when trying to install Node below version 15 (Like v14.0.0) with [nvm](https://github.com/nvm-sh/nvm#readme). Here's how to get past that error and install node below version 15.

## Solution
First you want to install Rosetta. To do this open Terminal and type in the following:
```
softwareupdate --install-rosetta
```

Once installed, you will need to go to your Applications folder on your device and find Terminal. If your Mac was setup like mine it will be in a nested folder within applications.

```
Applications -> Utilities -> Terminal
```

Once you see the terminal icon, right click on it, click on `Get Info` and select `Open using Rosetta`. Then restart your terminal.

Now open terminal back up and run the following command

```
arch -x86_64 zsh
```

Your device should now be able to install Node below version 15!

## Resources
* [Stackoverflow](https://stackoverflow.com/questions/67254339/nvm-install-node-fails-to-install-on-macos-big-sur-m1-chip)