teleren/devto huggingface dataset:
And finally: Hacktoberfest is over
Tags: hacktoberfest, programming, productivity, vscode
Published: 2021-10-31 18:58:55

After a month full of crazy ideas for some new projects, now at the end of October, I find myself sitting here and thinking about all the things I learnt over the past weeks, things that worked out well and those that doesn't 😐.
In this post I want to summarize the things I have learnt this month.

## Things I learned
### HTTP streams
Being honest, I heard of data streams quite often in the last seven years of my career, but I never really dived into it. This changed when I decided to build a webhook service, which allows both the sender and the receiver to communicate between firewalls. I needed some sort of event streaming over HTTP. And what should I say? There even is a [JavaScript standard for this (`EventSource`)](https://developer.mozilla.org/en-US/docs/Web/API/EventSource). It's sort of like a websocket, but without the ability to send a message back to server (without sending a new HTTP request).
### Workspaces and Devcontainer in VS Code
Another thing I never did before was to create a workspace in Visual Studio Code. This month I finally tried it out and it is really helpfull when working with Monorepos. It allows you to hide specific folder (like `node_modules`) completely, which makes it easier to organize yourself in complex folder structures. I really can recommend you to give it a try.

The second thing I tried out was [Microsoft's Remote - Containers Extension for VS Code](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) (it is like GitHub Codespaces on your local device). It allows you to predefine a `Dockerfile`, from which your development environment will be created. Whit it you can code right away on every machine without the need to install dependencies by hand ever again. It also is a good preparation for cloud-based development, which definitely will be the future (the same syntax is also used by GitHub Codespaces and soon Gitpod).

## Conclusion
I think if you really want to learn something, it doesn't need an event like Hacktoberfest to get started, however it is a great motivation to try out new things. Remember, we're never done learning.

I hope you all got through October well and maybe some of you also learned something new this month. I would like to invite you to also write about your highlights and achievements over the last month. Feel free to link your post in the comments.


Ps: For the equal rights of the American and British English speakers here, I used both word forms, "learnt" and "learned".
My Hacktoberfest Experience
Tags: hacktoberfest, opensource, programming, github
Published: 2021-10-31 18:58:29

I was doing something when a friend of mine reminded me of the start of [**Hacktoberfest**](https://hacktoberfest.digitalocean.com).
I was happy to find out and went to the official Site of [Hacktoberfest](https://hacktoberfest.digitalocean.com).
I read the description and registered.

![Hacktoberfest official Site](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sv9dzmedzs32k0yaadjv.png)

According to the rules, I had to register at least 4 PR in each project that had the tag [Hacktoberfest](https://hacktoberfest.digitalocean.com) in [Github](https://github.com/) or [Gitlab](https://gitlab.com/) during a month.
Also, registered PR must be approved to be counted in [Hacktoberfest](https://hacktoberfest.digitalocean.com).
At least 14 days must have passed since the PR was approved to ensure that it is valid.

![Hacktoberfest RULES](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jccmztodjs3d0yujii9k.png)

During one month, I participated in several projects and was able to successfully register 5 correct and approved [Hacktoberfest](https://hacktoberfest.digitalocean.com) PR.
Out of 5 PR, 3 of them have been completed and at least 14 days have passed and I am looking forward to the confirmation of the last one.

![ERFAN BAHRAMALI'S PROFILE](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iml6ux5mcx14nfglf0gx.png)

During this month, I became acquainted with many projects and services, and [Hacktoberfest](https://hacktoberfest.digitalocean.com) made me more involved in various projects.
I recommend participating in [Hacktoberfest](https://hacktoberfest.digitalocean.com) to all people who are interested in teamwork.
[Hacktoberfest](https://hacktoberfest.digitalocean.com) starts every year in October and according to the rules of that year, it gives prizes to people who participate in free projects.

Be happy😉
Hash Tables
Tags: javascript, webdev
Published: 2021-10-31 18:52:13

---
title: Hash Tables
published: true
description: 
tags: javascript, webdev
//cover_image: https://direct_url_to_image.jpg
---

                       -Intro to Hash Tables
                       -Handling Collisions
                       -Hash Table Keys and Values 
       

             
  
                        
             


###Intro to Hash Tables
Hash tables are used to store key-value pairs. 
They are similar to arrays but there is no required order. 
Hash tables have a great speed so they are widely used.
Hash tables have different names in other languages but the functionality is the same. 

Python hash tables are called dictionaries. 
JavaScript hash tables are called objects and maps. 


```javascript 

function hash(key, arrayLen) {
  let total = 0;
  for (let char of key) {
    // map "a" to 1, "b" to 2, "c" to 3, etc.
    let value = char.charCodeAt(0) - 96
    total = (total + value) % arrayLen;
  }
  return total;
}

```


###Handling Collisions
There are two ways to handle hash table collisions. 
1. Separate Chaining 
2. Linear Probing


####Separate Chaining 
is when the hash table has each index in the array has stored values with more data similar to an array or a linked list. 

####Linear Probing 
When a collision is found, a search is performed throughout the array to find the next  empty slot. 






###Hash Table Keys and Values 

Keys - Loops through the hash table array and returns an array of keys in the table 

Values - Loops through the hash table array and returns an array of values in the table 


```javascript 

 keys(){
    let keysArr = [];
    for(let i = 0; i < this.keyMap.length; i++){
      if(this.keyMap[i]){
        for(let j = 0; j < this.keyMap[i].length; j++){
          if(!keysArr.includes(this.keyMap[i][j][0])){
            keysArr.push(this.keyMap[i][j][0])
          }
        }
      }
    }
    return keysArr;
  }
  values(){
    let valuesArr = [];
    for(let i = 0; i < this.keyMap.length; i++){
      if(this.keyMap[i]){
        for(let j = 0; j < this.keyMap[i].length; j++){
          if(!valuesArr.includes(this.keyMap[i][j][1])){
            valuesArr.push(this.keyMap[i][j][1])
          }
        }

```
Running the Management Portal (Private Web Server) Over TLS/SSL/HTTPS
Tags: ssl, pracrice, beginners, tutorial
Published: 2021-10-31 18:17:50

Hi all,

 

I want to share a quick little method you can use to enable ssl with a self signed certificate on your local development instance of IRIS/HealthShare. This enables you to test https-specific features such as OAuth without a huge lift.

 

 

**1. Install OpenSSL**

<pre>Windows: https://slproweb.com/download/Win64OpenSSL_Light-1_1_1g.exe

Debian Linux: $ sudo apt-get -y install openssl

RHEL: $ sudo yum install openssl</pre>

 

**2. Create a self-signed certificate pair. In your terminal (powershell, bash, zsh, etc)**

<pre class="code-pre command prefixed">$<code> openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout apache-selfsigned.key -out apache-selfsigned.crt</code></pre>

`Note -- This above command will create a certificate that lasts for a year.`

**3. Edit your private web-server to use the new self-signed certificate pair.**

In you instance installation directory, edit your pws config **&lt;install-dir>/httpd/conf/httpd-local.conf.** Add the following section before the "Include .. " directives.

<pre># Port to listen for secure traffic On. The default is 443
LoadModule ssl_module "modules/mod_ssl.so"
Listen 10443

# Listen Virtual Host Block to define the keys we should use for that port
# If you define a different port in the Listen directive, change that here as well
&amp;lt;VirtualHost *:10443>

    # We need a servername, it has not effect but is required by apache
    ServerName mysecureinstance

    # Turn on SSL for this Virtual Host
    SSLEngine on

    #key files, replace these paths with the path you generated the keys from in step 2.
    SSLCertificateFile "/path/to/apache-selfsigned.crt"

    SSLCertificateKeyFile "/path/to/apache-selfsigned.key"
&amp;lt;/VirtualHost></pre>

 

**Here is an example of my config file:**

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

 

 

**In action:**

 

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

 

Note: this type of HTTPS support is not supported by InterSystems and if you need a production product you should follow directions to install apache2 / IIS / nginx in it's full form.
Tandem reading books - NoSQL
Tags: database
Published: 2021-10-31 18:03:38

Driven by the wish to explore the landscape of NoSql databases I decided to research the books available on the subject.

After browsing reviews and top lists of books on the subject I narrowed it down to these two books:

[Seven Databases in Seven Weeks](https://www.amazon.com/Seven-Databases-Weeks-Modern-Movement/dp/1934356921)

[NoSQL for Mere Mortals](https://www.amazon.com/NoSQL-Mere-Mortals-Dan-Sullivan/dp/0134023218) 

Both of them cover all the mainstream database families. Namely relational, key-value, columnar, graph and document databases.

Unable to decide which one to pick I decided to read them both. Back to back... to back.

Although I was initially put of by the title of the second one I still decided to read it despite not being a mere mortal.

"Seven Databases in Seven Weeks" is basically a collection of quickstart guides for one NoSql database per database family. It goes less into concepts and focuses more on implementation. After each chapter you will have a functioning example of simple database interactions with the database in question. The book does not shy away from using databases which are exclusively available through cloud providers. After completing one of the chapters you'll have a working DynamoDB instance hosted on AWS.

NoSQL for mere mortals, on the other hand, goes a lot deeper regarding motivation and limitations of each database family. It mostly stays database agnostic and focuses on guiding you through the concepts which are driving the design and behavior of the database families in question. Although it does not contain code it presents use cases for all the NoSql database families and provides conceptual solutions for them.

Prior to reading these books I was highly biased towards relation databases. Although I worked with MongoDB and Redis, most of the time I work with relational databases like PostgreSQL and MySQL. The idea that you have to do additional work up front but reap the rewards later suited me. Benefits like enforced data integrity with schema and foreign keys, transactions, "easy" querying and so forth.

Reading these books did not change my preconceived notion that much. NoSql database can be vary useful for specific tasks which fit the database model. It is of utmost importance to truly accept and embrace a particular NoSql database and its concepts. If you try to mimic the relational model in any of these database you'll have a bad time.

But one has to admit that one of the things in which NoSql databases are far ahead of relational databases is distributability. A lot of NoSql databases are build from the ground up with distributability in mind.
DPS909 - Release 0.2 W4
Tags: javascript, node
Published: 2021-10-31 17:59:47

### Week 4 Hacktoberfest

For this week, I have chosen to work on this repository: [link](https://github.com/askbuddie/buddies-tube). The issue that was asked from the creator was to implement jwt tokens that should be returned when a user authenticates themselves into the program.

The issue could be found here: [issue link](https://github.com/askbuddie/buddies-tube/issues/24)

I have made a PR with my changes, which could be found here:
[PR Link](https://github.com/askbuddie/buddies-tube/pull/25)

Here is my commit link:[commit](https://github.com/askbuddie/buddies-tube/pull/25/commits/b9a018de58ae252a52a294f9789a6f7fcde4d5bf)

Currently, I am waiting for the owner to add the Hacktoberfest label to the issue, as well as review my PR.
Anti Pattern - Mutable Default Arguments
Tags: python, programming, beginners
Published: 2021-10-31 17:34:56

## Introduction
In this article, you will understand what mutable default arguments are, why you should avoid using them and the workaround.


## Code Example With A Mutable Default Argument
Consider the following code example below. 

```python
def add_fruit(fruit, box=[]):
    box.append(fruit)
    return box

```

Let's understand step by step what is happening:

- We are creating a function to add fruits(str) in a box(list)
- There is a `add_fruit` function which is responsible for adding the `fruit`
- This function takes 2 arguments: `fruit` and `box`
- **Attention!** : The second argument here is a mutable default argument.

## So, what is mutable default argument?

An argument in a function with default value as mutable. 

In short, Python has both mutable and immutable types. The difference is: 
- mutables can be modified
- immutables can't be modified.

For eg: Tuple is an immutable type. If we define a tuple like this:

```python
weekends = ('saturday', 'sunday',)

weekends[0] = 'Monday' # TypeError: 'tuple' object does not support item assignment
```
An immutable type canot be modified.


## You Might Expect
let's modify our code and create a couple of boxes, i.e. red box and yellow box

```python
def add_fruit(fruit, box=[]):
    box.append(fruit)
    return box

red_box = add_fruit("apple")
print(f"red box: {red_box}")

yellow_box = add_fruit("mango")
print(f"yellow box: {yellow_box}")
```

### Expected Output

```
red box: ["apple"]

yellow box: ["mango"]
```

### Actually Output
Actually, you get the following output:

```
red box: ["apple"]

yellow box: ["apple", "mango"]
```

Wait? What? We never added apple in the yellow box. 

## What Exactly Happened?

A new list is created once when the function is defined, and the same list is used in each successive call. 

> Python’s default arguments are evaluated once when the function is defined. This means that if you use a mutable default argument and mutate it, you will and have mutated that object for all future calls to the function as well.

We will get the same result for other mutable types also(For eg: `dict`).

## What Should Be Done?
If your function needs to have a default argument for a mutable type, then default it with None and also add a check for the same.
Let's modify our `add_fruit` function:

```python
def add_fruit(fruit, box=None):
    if box is None:
        box = []
        
    box.append(fruit)
    return box

red_box = add_fruit("apple")
print(f"red box: {red_box}")

yellow_box = add_fruit("mango")
print(f"yellow box: {yellow_box}")
```

This extra check can saves hours of debugging!

## Conclusion
It's always a best practice to not use mutable default arguments. Instead, try adding an extra comparison check with 
`None` to handle the default arguments which are mutable.
[Post-3][LINQ] — Yield
Tags: csharp, dotnet, programming, 100daysofcode
Published: 2021-10-31 17:31:00




![](https://cdn-images-1.medium.com/max/2160/1*LYZGDNMhwoGTWm66buKIGw.png)

Yield in C# is very tricky concept and would take at least a couple of reads to understand its use or purpose. Lets try to de -mystify this concept and understand its use and purpose in this article. Get buckled up for an interesting read.

[***Enumerable ](https://medium.com/learninbytes/post-1-linq-enumerable-6804e4d6672c)***and [***Enumerator](https://medium.com/learninbytes/post-2-linq-ienumerator-31f5e3962f84) ***are foundational concepts to understanding of **Yield**. Any method that does *yield return* should return an ***Iterator. ***For a method to return an Iterator, its return type must of be one of the below types.

* IAsyncEnumerable<T>

* IEnumerable<T>

* IEnumerable

* IEnumerator<T>

* IEnumerator

If you are wondering what these *<T> *declarations mean, don’t worry, these are part of *Generics, *which will be covered in necessary proportions in the upcoming chapters. For now you can ignore them.

 <iframe src="https://medium.com/media/8d57bdae99bf5f83506d799cddee94f7" frameborder=0></iframe>

Add breakpoints at line 17 and at lines 22 till 26 then run the code. You’ll notice that the code does not go into *YieldNumber() *method. It bypasses the method and breaks directly at line 17.

The reason behind this functionality is that, yield return does a Lazy evaluation.

Lazy evaluation in this context means that, until the YieldNumber() method is iterated the yield return statements are not executed.

Now uncomment the line from 12 to 16 and execute the program.

Notice that the program now goes into the *YieldNumber *method and breaks at each yield return statement for each iteration of the while loop.

In the next post lets talk about **how Yield and LINQ are related** and understand **performance benefits of LINQ.**

The posts in this publication are intentionally kept short for easier learning.

**Any comment from you is greatly appreciated. Thanks!!!**
[Post 2]LINQ -IEnumerator
Tags: csharp, dotnet, programming, 100daysofcode
Published: 2021-10-31 17:25:28


## [Post-2] [LINQ] IEnumerator

![](https://cdn-images-1.medium.com/max/4490/1*E5b6X6tbMxcQrZ7YbDygYw.png)

Now that we have talked about [*“Enumerable”](https://medium.com/@yashaswi.yogeshwara?p=6804e4d6672c) .*Lets talk about *“Enumerator”.*
>  *Enumerators are those that make a data structure Enumerable.*

I.e. Enumerators help traverse or iterate an Enumerable. IEnumerable and IEnumerator implement the *“Iterator Pattern”.*

[**Iterator](https://www.youtube.com/watch?v=uNTNEfwYXhI)** is a behavioral design pattern that lets you traverse elements of a collection without exposing its underlying representation (list, stack, tree, etc.).
>  Making it simple Iterator pattern asks us to separate the underlying data collection and the functionality to traverse it.

Below are the IEnumerator and IEnumerable interfaces. IEnumerable exposes a method which returns an IEnumerator. IEnumerator provides following methods and properties.

 <iframe src="https://medium.com/media/59db242312b2c50f7b3ae8a45bc779ce" frameborder=0></iframe>

**bool** **MoveNext()**: Moves the pointer to next item in the collection and returns ***true***. If the pointer is at the end of collection it returns ***false***.

**object Current: **This property provides the current values of the item the pointer is located at.

**void Reset(): **Although not extensively used or is part of *Iterator pattern *UML diagram, this method sets the pointer to the initial value of the collection.

Look at the below example where different data structures return their Enumerators using which the these are iterated.
{% gist https://gist.github.com/yashaswiyogeshwara/fc1ac452529ab9dcb6d16c16eda17b56.js %}
If you notice, in the above code we are iterating different data structures using same method ***“Enumerate”***. If you get back to the *Iterator Pattern *definition, irrespective of the characteristics or internal implementation of the data structure we are able to iterate them uniformly.

Although it is not a common practice to use the enumerator for iterating a data structure. [Instead we would use the *foreach *loop directly.] Understanding this particular concept helps in understanding **LINQ**.

In the next post lets look into ***Yield ***and how IEnumerable and Yield are linked together.

Thanks, please subscribe to the publication for more interesting posts.

**[References]**

**Iterator Pattern** : [*https://www.youtube.com/watch?v=uNTNEfwYXhI](https://www.youtube.com/watch?v=uNTNEfwYXhI)*
Jetstream user banner photo upload
Tags: jetstream, laravel, photo, fortify
Published: 2021-10-31 17:24:58

---
title: Jetstream user banner photo upload
published: true
description: Laravel Jetstream photo upload functionality how it works.
tags: Jetstream, Laravel, photo, fortify
---

Hi, devs!
Does anyone of you understand the proccess of uploading photos for users.
I mean Jetstream already provide devs with the ability to uncomment fortify file user profile photo feature line;
But what if I want to let users upload their own profile banner photo. The proccess can't be understandable.
ANy help devs?!
1 line of code: How to get the first index of the highest numeric item of an Array
Tags: javascript, webdev, performance, codequality
Published: 2021-10-31 17:12:29


```javascript
const indexOfHighest = arr => arr.indexOf(Math.max.apply(null, arr));
```
Returns the index of the highest numerical item of the array. 
---

## The repository & npm package

You can find the all the utility functions from this series at [github.com/martinkr/onelinecode](https://github.com/martinkr/onelinecode)
The library is also published to [npm as @onelinecode](https://www.npmjs.com/package/@onelinecode/onelinecode) for your convenience.

The code and the npm package will be updated every time I publish a new article.

---

Follow me on [Twitter: @martinkr](http://twitter.com/_martinkr) and consider to [buy me a coffee](https://www.buymeacoffee.com/martinkr)

Photo by [zoo_monkey](https://unsplash.com/@zoo_monkey) on [Unsplash](https://unsplash.com/s/photos/fuji)

---
[Post 1]LINQ -Enumerable
Tags: csharp, dotnet, 100daysofcode, programming
Published: 2021-10-31 17:11:51


## [Post 1]LINQ -Enumerable

![](https://cdn-images-1.medium.com/max/4490/1*i5q5ZimWRcGDLeVVZ4Ggjg.png)

Enumerable is a data structures that can be iterated, counted or enumerated. Array, List, Dictionary are some data structures that are Enumerable.

In perspective of C# any Object that implements “*IEnumerable” *interface is an Enumerable. Array, List, Dictionary are some of the data structures that implement IEnumerable.

Every IEnumerable can support the use of *“foreach()” *method for iterating the collection. [This post limits itself to the concept of IEnumerable and does not divulge into “*IEnumerable<T>”.*]

### Documentation

IEnumerable is part of “*System.Collections” *namespace. IEnumearble contains only a single method *“GetEnumerator()” *which returns an “*IEnumerator”.*[A seperate post is being written on *“IEnumerator” *which would be published shortly.]
{% gist https://gist.github.com/yashaswiyogeshwara/86d276fe5dc89510e8fcd26c9ff9a1ee.js %}
A series of posts would follow this that talk about *“IEnumerator” , “Iterator Pattern” *and *“LINQ”.*

The posts are written small intentionally. The purpose of these posts is to provide information in nuggets for faster assimilation, keeping it short and simple.

`