teleren/devto huggingface dataset:
Passing Mutables as Function Parameters in Python
Tags: python, beginners
Published: 2022-08-18 09:29:01

In Python it is comparatively very easy to create functions, meaning there are no return types or I should say no types at all!

Okay, So some of you might say that no type hinting is still a thing but I'm going to deny the fact and say that..

> The Python runtime does not enforce function and variable type annotations. They can be used by third party tools such as type checkers, IDEs, linters, etc. 

![A funny meme on python type hints](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oyj1ridvt4ben37yucv4.png)

They do certainly help for writing clean and understandable code.

Anyway coming on the topic in hand, Have you ever tried passing a mutable object to a function as a parameter and manipulating it afterwards? No? Because you cannot at least as a positional argument. It won't just run and it doesn't make much sense either.

```py
def pos_func([]):
    pass
```
Ok so how do we access the passed list now? You get it.
Now, if we passed a list as a keyword argument then accessing it is not a big deal, But manipulating it is. 

```py
def keyword_func(num, array=[]):
    array.append(num)
    return array

print(keyword_func(1))
print(keyword_func(2))
print(keyword_func(3))
```
You would expect the output will be the following 

```
[1]
[2]
[3]
```

But no, the actual output is 

```
[1]
[1, 2]
[1, 2, 3]
```
The reason is

> The default value is evaluated only once. This makes a difference when the default is a mutable object such as a list, dictionary, or instances of most classes.

If you don't want this behaviour and don't want the default to be shared between subsequent calls, you can write the function like this instead: 

```py
def keyword_func(num, array=None):
    if array is None:
        array = [] 
    array.append(num)
    return array
```
That's how you pass a mutable object to a function if you don't want the object to be shared between every call.

This was my first blog here at dev.to. Feel free to comment anything you feel about this blog. Next blog would be related to positional arguments, keyword arguments, using them together and how they are separated. Thank you!

Credits: 
[Type hinting Quote](https://docs.python.org/3/library/typing.html)
[Type hinting Meme]
(https://www.reddit.com/r/ProgrammerHumor/comments/co635o/just_use_listdictstr_any_bro_its_more_pythonic/)
[Reference and Examples]
(https://docs.python.org/3/tutorial/controlflow.html#more-on-defining-functions)
How I created a custom time-frame for my client's website, using Date-fns.
Tags: javascript, nextjs, date, time
Published: 2022-08-18 09:24:00

{% embed https://www.linkedin.com/feed/update/urn:li:activity:6965965595452264448/ %}

Available for work. Full Stack developer.
https://www.linkedin.com/in/gal-naim-גל-נעים-910460246/
Creating a progress bar using JavaScript
Tags: javascript, webdev, programming, css
Published: 2022-08-18 09:22:15

A progress bar is used to represent the progress of any running task. Progress bars are generally used to show the status of uploading and downloading. In other words, we can say that progress bars can be used to depict the status of whatever is going on.

To create a basic progress bar using JavaScript, the following steps should be performed:

- Create an HTML structure for your progress bar:
- Link HTML, CSS and JavaScript elements
- Creating a Labeled Progress Bar

Below is the complete program using HTML, CSS, and JavaScript to create a tagged progress bar:

```
<!DOCTYPE html>
<html>
<style>

#Progress_Status {
  width: 50%;
  background-color: #ddd;
}

#myprogressBar {
  width: 1%;
  height: 35px;
  background-color: #4CAF50;
  text-align: center;
  line-height: 32px;
  color: black;
}


</style>
<body>

<h3>Example of Progress Bar Using JavaScript</h3>

<p>Download Status of a File:</p>

<div id="Progress_Status">
  <div id="myprogressBar">1%</div>
</div>

<br>
<button onclick="update()">Start Download</button> 

<script>

function update() {
  var element = document.getElementById("myprogressBar");   
  var width = 1;
  var identity = setInterval(scene, 10);
  function scene() {
    if (width >= 100) {
      clearInterval(identity);
    } else {
      width++; 
      element.style.width = width + '%'; 
      element.innerHTML = width * 1  + '%';
    }
  }
}

</script>

</body>
</html>

```
How would you refactor this code? (tennis-3-modern)
Tags: javascript, discuss, beginners, refactorit
Published: 2022-08-18 09:13:54

```javascript
export class TennisGame {
  constructor(p1N, p2N) {
    this.p2 = 0;
    this.p1 = 0;

    this.p1N = p1N;
    this.p2N = p2N;
  }

  getScore() {
    let s;
    if (this.p1 < 4 && this.p2 < 4 && this.p1 + this.p2 < 6) {
      const p = ["Love", "Fifteen", "Thirty", "Forty"];
      s = p[this.p1];
      return this.p1 == this.p2 ? `${s}-All` : `${s}-${p[this.p2]}`;
    } else {
      if (this.p1 == this.p2) return "Deuce";
      s = this.p1 > this.p2 ? this.p1N : this.p2N;
      return (this.p1 - this.p2) * (this.p1 - this.p2) == 1
        ? `Advantage ${s}`
        : `Win for ${s}`;
    }
  }
  
  wonPoint(playerName) {
    if (playerName == "player1") this.p1 += 1;
    else this.p2 += 1;
  }
}

```

I've created a modern version of the Tennis-3 refactoring kata. The class calculates the tennis score for a game. You can find the full code including a test suite on [GitHub](https://github.com/p42ai/javascript-refactoring-kata/tree/main/tennis-3-modern).

**How would you refactor it?**
How to create GIN index in Django migration
Tags: django, beginners, python, webdev
Published: 2022-08-18 09:13:00

In your models.py file import 
```py
from django.contrib.postgres.indexes import GinIndex
```
In class Meta create your index by your model field - 
```py
    class Meta:
        indexes = [
            GinIndex(name='NewGinIndex',fields=['title','keywords','shortDescription','details'])
        ]
```
Then run `python manage.py makemigrations` and when you run `python manage.py migrate` you will get an error like this - 
> data type character varying has no default operator class for access method "gin"
> HINT:  You must specify an operator class for the index or define a default operator class for the data type.
![data type character varying has no default operator class for access method "gin"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2vd532n9rnc8yrx28tko.png)

Then go to your app -> migrations -> <number>_modelName_giniIndexname.py file 

Then in `<number>_modelName_giniIndexname.py` file import 
```py
from django.contrib.postgres.operations import BtreeGinExtension
```
And also in `operations` list add - 
```py
BtreeGinExtension(),
```
Then you can run migrate. Probably you will get another error some kind of super user issue. To resolve this issue 
Login psql by current user via - 

```bash 
sudo -u postgres psql
```
then -> 
```bash 
postgres-# alter role <user_name> superuser;
```
this user should be in your database config user profile - 
![Permission denied to create extension "extension_name"
HINT:  Must be superuser to create this extension postgres](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zb43r4jtozebkqxw23fl.png)

then -> 
```bash 
postgres-# CREATE EXTENSION btree_gin;
```
> If you want alter super user permission by after login with current user in psql -
```bash 
postgres-# alter role <user_name> nosuperuser;
```

exit from database by - 
```bash 
\q 
```
then `python manage.py migrate`

Thank you...

😇 Read more -
* https://dev.to/siumhossain/solved-valueerror-the-field-adminlogentryuser-was-declared-with-a-lazy-reference-5fm1
* https://dev.to/siumhossain/djangodbutilsprogrammingerror-column-of-relation-appnametable-already-exists-231g
* https://dev.to/siumhossain/how-to-save-model-object-using-only-foreign-keys-id-in-django-rest-framework-572b
* https://dev.to/siumhossain/how-to-serve-media-files-on-django-production-environment-531m
* https://dev.to/siumhossain/how-to-find-if-its-an-insert-or-update-in-the-django-signal-15l3
* https://dev.to/siumhossain/withdraw-and-modify-restriction-in-password-django-application-2c91
* https://dev.to/siumhossain/how-to-create-gin-index-in-django-migration-django-search-1310
Hire Frontend Developers
Tags: hiredeveloper, webdeveloper, webdev
Published: 2022-08-18 09:02:00

Hire experienced Frontend Developers from Authorselvi to make your website more responsive. Our dedicated front-end developers are flexible and more committed to your business plans. Moreover, if you have any ideas to expand your development team with us, our [frontend developers](https://authorselvi.com/hire-frontend-developers/) help you to make sure you feel like working in-house.For more details contact us info@authorselvi.com
I made a Personal Voice Assistant but it...(worked/failed)
Tags: python, beginners, tutorial, programming
Published: 2022-08-18 08:37:38

I searched a lot, spent 10 to 20 hours, and finally got to know this was use___

Welcome everyone 
Today I will tell you the python libraries used for your voice assistant using python. Also, some important things to keep in mind will be told in the next tutorial.

Used libraries are:
pyttsx3
speech_recognition
os
time
wikipedia
pyfiglet
datetime
webbrowser

Also, we will try to make a code for a personal voice assistant in android and Java.

Thanks, A Lot
Stay Tuned
How did you land your first developer job as a self-taught programmer?
Tags: discuss, career, webdev, productivity
Published: 2022-08-18 08:35:00

I am currently looking for a tech role that fits my skill set. Believe me or not, I applied to more than 60 companies including start-ups, and got rejected by all. Every morning I wake up and open my Mail, what I see is a bunch of rejection letters. I would love to know **How did you break into tech as a self-taught developer?**
Web Design & Development
Published: 2022-08-18 08:15:36

Our [Koozai](https://www.koozai.com) website dev specialists will ensure that your site is built with your specific needs in mind – and we’ll work with you to improve engagement from users on desktop and mobile at every step of their customer journey.

Not only that, but we’ll also work hand-in-hand with our SEO experts throughout to ensure that SEO strategies are baked into your project from the very beginning. This is to make sure that nothing will prohibit your site from being crawled and indexed by search engines, giving your website the SEO fundamentals it needs to have the best chance of gaining valuable traffic from organic search rankings.

Our [web development specialists](https://www.koozai.com/services/web-design-development/) have been in the game of creating functional and beautiful sites for clients of all sizes since 2006, and we’re experienced in a range of platforms including WordPress and Woocommerce websites.

We also offer website audits, web hosting, ongoing website development support and WP Engine hosting.
Quantity Buttons for WooCommerce
Tags: woocommerce, quantity, buttons, plugins
Published: 2022-08-18 08:13:43

[WooCommerce quantity increment plugin](https://woocommerce.com/products/quantity-buttons-for-woocommerce/) adds customizable buttons for increasing or decreasing item quantities on product, shop, and cart pages.
Key Features of Quantity buttons for WooCommerce are

1. Add quantity increment buttons to your store
2. Display buttons on product, shop, cart pages
3. Replace the default arrow with modern buttons
4. Define increment steps
5. Configure min/max quantity limit
6. Personalize the quantity increment buttons
7. Apply buttons on specific products or categories
8. Allow ordering product items in decimals
Permission denied to create extension "extension_name" HINT: Must be superuser to create this extension postgres
Tags: django, postgres, errors, python
Published: 2022-08-18 08:03:32

If you want install a extension in your postgresql database via `python manage.py migrate` it will throw an error if database user is not a super user. We can resolve this issue by give superuser permission to our current user. We can also withdraw super user permission after that 😬.

Login psql by current user via - 

```bash 
sudo -u postgres psql
```
then -> 
```bash 
postgres-# alter role <user_name> superuser;
```
this user should be in your database config user profile - 
![Permission denied to create extension "extension_name"
HINT:  Must be superuser to create this extension postgres](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zb43r4jtozebkqxw23fl.png)

exit from database by - 
```bash 
\q 
```
Then you can successfully migrate.

Oh! hold on 
If you want alter super user permission by after login with current user in psql -
```bash 
postgres-# alter role <user_name> nosuperuser;
```

Thank you...
How DevOps works?
Tags: devops
Published: 2022-08-18 08:03:28

How do DevOps function?

DevOps is an application development method that enhances the cooperation between operations and developers with the help of various automation tools. The automation tools are utilized through multiple stages that form part of the DevOps Lifecycle.
How DevOps Does It Work? Check out the complete DevOps functions in [DevOps Post Graduate Program](https://www.edureka.co/executive-programs/purdue-devops).

The DevOps Lifecycle is divided into this SDLC lifecycle into these phases:
Automated CI/CD Pipeline
Continuous Development: This step involves committing the code to tools for version control like Git or SVN to maintain the various version of code and using tools such as Ant, Maven, and Gradle to build or package the code into executable files that are then sent to QAs to test.
Continuous Integration:
The stage is crucial in the DevOps Lifecycle. It integrates all the phases in the DevOps lifecycle and is the most critical step to automating the entire DevOps process.
Continuous Deployment:
In this phase, the application is developed, and the environment or application is containerized and moved to the server you want. The stages' most important processes include Configuration Management, Virtualization, and Containerization.
4. Continuous Testing:
The process involves automatic testing for the app developed through the developers. If an error occurs, it is reported directly to integration tools, informing the developer of the issue. If the test is successful, the message is transmitted to Integration-tool, which will push the build to the server that runs production.
Continuous Monitoring:
The stage continuously monitors the running application for any glitches or crashes. It is also installed to collect feedback from users. The data collected is given to the developers to improve the app.
RFC: new API for Type::Params
Tags: perl, rfc
Published: 2022-08-18 08:02:21

Firstly, I'm not planning on breaking compatibility with Type::Params. The new API would live under a different namespace, such as Type::Params2.

The API for Type::Params is currently:

```perl
use feature 'state';
use Type::Params qw( compile compile_named_oo );
use Types::Standard -types;

sub function_with_positional_parameters {
  state $check = compile( ArrayRef, Int, Int );
  my ( $list, $start, $end ) = $check->( @_ );

  my @slice = @{$list}[ $start .. $end ];
  return \@slice;
}

sub function_with_named_parameters {
  state $check = compile_named_oo( list => ArrayRef, start => Int, end => Int );
  my ( $arg ) = $check->( @_ );

  my @slice = @{$arg->list}[ $arg->start .. $arg->end ];
  return \@slice;
}
```

Alternatively, there's:

```perl
use Type::Params qw( wrap_subs compile_named_oo );
use Types::Standard -types;

wrap_subs function_with_positional_parameters => [ ArrayRef, Int, Int ];

sub function_with_positional_parameters {
  my ( $list, $start, $end ) = @_;

  my @slice = @{$list}[ $start .. $end ];
  return \@slice;
}

wrap_subs function_with_named_parameters =>
  compile_named_oo( list => ArrayRef, start => Int, end => Int );

sub function_with_named_parameters {
  my ( $arg ) = @_;

  my @slice = @{$arg->list}[ $arg->start .. $arg->end ];
  return \@slice;
}
```

My suggested API is:

```perl
use feature 'state';
use Type::Params2;
use Types::Standard -types;

sub function_with_positional_parameters {
  state $check = signature(
    pos => [ ArrayRef, Int, Int ],
  );
  my ( $list, $start, $end ) = $check->( @_ );

  my @slice = @{$list}[ $start .. $end ];
  return \@slice;
}

sub function_with_named_parameters {
  state $check = signature(
    named => [ list => ArrayRef, start => Int, end => Int ],
  );
  my ( $arg ) = $check->( @_ );

  my @slice = @{$arg->list}[ $arg->start .. $arg->end ];
  return \@slice;
}
```

It would also support the inside-out technique:

```perl
use Type::Params2;
use Types::Standard -types;

signature_for function_with_positional_parameters => (
  pos => [ ArrayRef, Int, Int ],
);

sub function_with_positional_parameters {
  my ( $list, $start, $end ) = @_;

  my @slice = @{$list}[ $start .. $end ];
  return \@slice;
}

signature_for function_with_named_parameters => (
  named => [ list => ArrayRef, start => Int, end => Int ],
);

sub function_with_named_parameters {
  my ( $arg ) = @_;

  my @slice = @{$arg->list}[ $arg->start .. $arg->end ];
  return \@slice;
}
```

There would be a shortcut for methods:

```perl
signature_for method_with_named_parameters => (
  method => 1,
  named  => [ list => ArrayRef, start => Int, end => Int ],
);

sub method_with_named_parameters {
  my ( $self, $arg ) = @_;

  my @slice = @{$arg->list}[ $arg->start .. $arg->end ];
  return \@slice;
}
```

Comments? Do people think this would be an improvement?
A Nice Developer Joke For Today
Tags: jokes, dailydeveloperjokes
Published: 2022-08-18 08:00:01

---
title: "A Nice Developer Joke For Today"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e12592aa5db7.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
Asynchronous JavaScript is amazing.

I Promise you, await and see.
 -->
#TestCulture 🦅 Episode 17 – Agile dictionary
Tags: beginners, webdev, agile, productivity
Published: 2022-08-18 07:41:00

_Here are some notions to master to understand Agile methods. Do you have other vocabulary words to share?_

𝐍𝐨-𝐜𝐨𝐝𝐞 𝐭𝐞𝐬𝐭 𝐚𝐮𝐭𝐨𝐦𝐚𝐭𝐢𝐨𝐧: process that runs on automated tests. It reduces the amount of time and cost used by manual testing.

𝐃𝐞𝐯𝐎𝐩𝐬: multidisciplinary approach that combines software development and IT operations. Helps to create a more agile work process.

𝐀𝐠𝐢𝐥𝐞: iterative approach to project management and software development. An agile team delivers work in small, but consumable.

𝐂𝐨𝐧𝐭𝐢𝐧𝐮𝐨𝐮𝐬 𝐭𝐞𝐬𝐭𝐢𝐧𝐠: approach that encourages testing as early as possible. It is a guarantee of stability and non-regression.

[𝐖𝐈𝐏 (𝐖𝐨𝐫𝐤 𝐢𝐧 𝐏𝐫𝐨𝐠𝐫𝐞𝐬𝐬)](https://www.agilitest.com/cards/wip-work-in-progress): commonly used concept in agility. It consists in limiting the number of jobs in progress in order to ensure the quantity of work delivered to the customer.

𝐒𝐜𝐫𝐮𝐦: a framework for project management, with an initial emphasis on software development, that is a lightweight, iterative and incremental framework for developing, delivering, and sustaining complex products.

𝐁𝐚𝐜𝐤𝐥𝐨𝐠: changing list of product requirements based on the customer’s needs. The backlog is not a to-do list; rather, it is a list of all the desired features for the product.

𝐔𝐬𝐞𝐫 𝐒𝐭𝐨𝐫𝐲: brief, non-technical description of a software system requirement written from the customer’s or end-user’s point of view.

𝐈𝐭𝐞𝐫𝐚𝐭𝐢𝐨𝐧: a fixed or timeboxed period of time, generally spanning two to four weeks, during which an Agile team develops a deliverable, potentially shippable product. A typical Agile project consists of a series of iterations, along with a planning meeting prior to development and a retrospective meeting at the end of the iteration.

----

📚 𝕊𝕠𝕦𝕣𝕔𝕖𝕤:

🌐 https://en.wikipedia.org/wiki/Scrum_(software_development)

🌐 https://smartsheet.com/ultimate-agile-dictionary

🎴 https://agilitest.com/cards/wip-work-in-progress


----
Thread [on Twitter](https://twitter.com/agilitest/status/1552670035667288065?s=20&t=GWEG-ceN9Q0AGic-mU1hrw).
Migrate & Import Shopify to WooCommerce
Tags: woocommerce, shopify, migrate, plugins
Published: 2022-08-18 07:38:09

[Migrate Shopify to WooCommerce plugin](https://woocommerce.com/products/migrate-import-shopify-to-woocommerce/) enables you to import whole store from Shopify to WooCommerce with just few clicks. It lets you directly import products, orders, coupons, blogs, and pages.

Key features of this plugins are

1. Directly import 6 types of data from Shopify to WooCommerce
2. Import all products from Shopify to WooCommerce
3. Import specific products using various filters such as title, type, vendor, specific ID, or publishing date.
4. Import products as active, achieved, and draft
5. Import all or specific orders using filters
6. Import all or specific coupons using various filters
7. Option to import pages, blog posts, and customer lists
8. Track import with a progress bar
OpenSource DevRel's journey: the beginnings
Tags: devrel
Published: 2022-08-18 07:20:10

I am a clinically diagnosed autist, who was 1 day away from a suicide, just over a year ago. Luckily, I had help.

When I began feeling better, I started thinking "How can I use my experience, to help people find the way out from complicated life situations?". What did I know? Well, I was a ~40 years old average developer, who had met some amazing new friends at Devoxx UK. My friends helped me to realize that the most optimal way to become a better developer is to join the OpenSource movement.

Well, I have chosen few OpenJDK projects to contribute to. I even started contributing. And then one thought stroke me. “You are privileged. You know how to become better and grow, by contributing to OpenSource projects that matter. There are many people, who could do so much better in life, but they are hold back by racism, underrepresentation, cost of education, geography." Basically, helping myself only would had been selfish. I had to help those amazing friends I have not met yet.  I had to contribute by sharing my experience and not by investing into myself only. The world is bigger than "I".

And so it started. On the 5th of June “Together, We OpenSource” had 1 member. Today, on the 18th of August 2022, there are 366 amazing friends in the meetup.

Did we solve all the challenges? 
No.

Did we all got promoted or got new jobs?
Not yet, but changes are happening.

Did we inspire others? 
We did inspire thousands.

Will we succeed?
We will. Because we are *together*.


https://www.meetup.com/twosseng/