teleren/devto huggingface dataset:
MVVM Project Infrastructure
Published: 2022-02-03 14:09:09

<font color=red>**👌. MVVM + RxSwift + CTMediatror + MJRefresh + DZNEmptyDataSet + SkeletonView**</font>

English | [**简体中文**](#简体中文)

This is a set of infrastructure based on `MVVM + RxSwift`

### Resources
- Resource module, which mainly deals with image resource and text resource reading.
  - Read image resource: `R.image("base_black_back")`
  - Read text resource: `R.text("base_empty_title")`

### Adapter
- This module is mainly to encapsulate the base class.
  - [BaseViewController](https://github.com/yangKJ/Rickenbacker): Support oc base class, public part.
  - [VMTableViewController](https://github.com/yangKJ/Rickenbacker): List base class, internally responsive processing.
  - [VMViewController](https://github.com/yangKJ/Rickenbacker): When inheriting this base class, you need to specify `ViewModel` or its subclasses as generics.
  - [ViewModel](https://github.com/yangKJ/Rickenbacker): Basic view model.
  - [TableViewModel](https://github.com/yangKJ/Rickenbacker): Mainly used for `VMTableViewController` data-driven binding model.

- CocoaPods Install ==> `pod 'Rickenbacker/Adapter'`

### CTMediatror
- This module mainly solves the cocoapods problem encountered by Swift using this componentized solution.

- CocoaPods Install ==> `pod 'Rickenbacker/CTMediatror'`

### HBDNavigationBar
- This module is based on `HBDNavigationBar` secondary encapsulation of the underlying basic Navigation.

- CocoaPods Install ==> `pod 'Rickenbacker/HBDNavigationBar'`

### MJRefresh
- This module is based on the refresh function of `MJRefresh` encapsulated UITableView.

- CocoaPods Install ==> `pod 'Rickenbacker/MJRefresh'`

### DZNEmptyDataSet
- This module is based on the empty data display function of the `EmptyDataSet-Swift` package UITableView.

- CocoaPods Install ==> `pod 'Rickenbacker/DZNEmptyDataSet'`

### Remarks

> The general process is almost like this, the Demo is also written in great detail, you can check it out for yourself.🎷
>
> [**RickenbackerDemo**](https://github.com/yangKJ/Rickenbacker)
>
> Tip: If you find it helpful, please help me with a star. If you have any questions or needs, you can also issue.
>
> Thanks.🎇

### About the author
- 🎷 **E-mail address: [yangkj310@gmail.com](yangkj310@gmail.com) 🎷**
- 🎸 **GitHub address: [yangKJ](https://github.com/yangKJ) 🎸**

### License
Rickenbacker is available under the [MIT](LICENSE) license. See the [LICENSE](LICENSE) file for more info.

-----
Hoisting in JavaScript [must know concept]
Tags: javascript, webdev, beginners, react
Published: 2022-02-03 13:58:11

### Did you know that JavaScript allocates memory to all variables and functions first, even before executing the code? 
Yes, that's true. And this results in a phenomenon called "**hoisting"** in JavaScript.

**Hoisting** allows us to use variables and functions even before they're declared. Look at this example

```
console.log(x);
var x = 'sample';
```

Interestingly, this will not throw an error. Instead, it will output `undefined`. Let's take a slightly deeper dive into this process.

1. Variable hoisting
 * The interpreter hoists variables declared with `var` with a default value of "undefined". Therefore, If you use a variable declared with `var` before it's been declared, it will return `undefined`.
 * The interpreter also hoists variables declared with `let` or `const`, but this time, the variables are not assigned a default value. JS just knows that these variables exist in the code. Therefore, If you use a variable declared with let/const before it's been initialized, it will throw an error stating *"cannot access xyz before initialization"*.
 * If you don't initialize the variable anywhere in the code, and try to use such variable, it will throw an error stating *"xyz is not initialized"*. See how this time JS doesn't even know that xyz exists.

2. Function hoisting
   * Unlike variables, an actual copy of the function is hoisted at the time of memory allocation. This gives an advantage of using calling functions even before they've been initialized.
   * Note that if you assign a function to a variable (like in arrow functions), it will no more be treated as a function. Just how variables are hoisted by a default value of *undefined*, this function will also be treated the same.

Want to read a detailed explanation with more examples, check out this [amazing article](https://www.freecodecamp.org/news/what-is-hoisting-in-javascript/) by Zach Snoek on FreeCodeCamp's website.

Happy coding :)

###10daysofJSfundamentals (DAY 7)
🎬Make a Joke Generator | HTML, CSS & javaScript🙌
Tags: javascript, api, tutorial, webdev
Published: 2022-02-03 13:40:21

Make a Make a Joke Generator | HTML, CSS & javaScript, step-by-step from SCRATCH…

***
{% youtube jUDpWHzuaR4%}
***

###Source Code:

**HTML**

```HTML
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Joke Generator</title>
  <link rel="stylesheet" href="style.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
</head>

<body>
  <div class="main_container">
    <h3>Try Not To Laugh Challenge</h3>
    <div class="joke" id="₢">
      Here goes the joke!
    </div>
    <button class="btn" id="₢">
      Get Another Joke
      <i class="fas fa-grin-squint-tears"></i>
    </button>
  </div>
  <script src="app.js"></script>

</body>

</html>
```

**CSS**

```CSS
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;700&display=swap');

* {
	box-sizing: border-box;
}

body {
	background: url(img/bg.jpg) center center/cover no-repeat;
	height: 100vh;
	display: flex;
	justify-content: center;
	align-items: center;
	margin: 0;
}

.main_container {
	background-color: #f6f1f4;
	border-radius: 10px;
	box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1), 0 6px 6px rgba(0, 0, 0, 0.1);
	padding: 50px 20px;
	max-width: 100%;
	width: 800px;
	text-align: center;
}

h3 {
	margin: 0;
	letter-spacing: 2px;
	opacity: 0.5;
}

.joke {
	font-size: 30px;
	color: #16110d;
	line-height: 40px;
	margin: 50px auto;
	max-width: 600px;
}
.btn {
	background-color: #9f68e0;
	border: 0;
	border-radius: 10px;
	box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1), 0 6px 6px rgba(0, 0, 0, 0.1);
	color: #fff;
	cursor: pointer;
	font-size: 16px;
	padding: 14px 40px;
}

.btn:active {
	transform: scale(.98);
}
.fas {
	margin-left: 4px;
}
```
Learn How To Contribute To Your First Opensource Project In 5 Minutes
Tags: opensource, codenewbie, github, git
Published: 2022-02-03 13:33:36

Have you ever wanted to contribute to a project you liked on Github but didn't know how to?

Here's is a complete guide for you. ↓

## Step 1: Explore

Find a project that you want to contribute to. Here I use as an example one of my favourite open source project [SuperTokens](https://github.com/supertokens/supertokens-core)


![Supertoken_1.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1643881098939/wSQFhSCoD.png)

## Step 2: Read guidelines

Most projects will have contributions guidelines that you have to follow. 

Note: Mostly will be in a file similar to the "Contribution MD" file. 

![Supertoken_2.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1643881791530/FBx007HTi.png)

## Step 3: Fork the repository

This will create a copy of the project under your profile. 

![Supertoken_3.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1643882194249/M4du3QdWu.png)

## Step 4: Clone the repository

To obtain a copy of the code in your local machine with which you can work. 

![Supertoken_4.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1643882661632/7PpDrOlIz.png)

## Step 5: Add your code

Please create a new branch, add your changes to the code and push it back to the repository. 

Here's a simple git reference guide for you → [Gitsheet](https://gitsheet.wtf/)

## Step 6: Pull request

This will let the maintainers of the original repository that we want to submit some contribution. 

![Supertoken_5.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1643883456933/7sVRAvgtC.png)

## Step 7: Provide a description

Explain the all changes you made, which issues it fixes and whatever the reviewers know. 

## Step 8: Discuss

The reviewers will go through your code, ask questions and provide suggestions to which you have to respond to.

Make changes to your code and push them. Once the reviewers are happy, they will merge your code with the main project.

That's it! If you run into any issues or have questions, feel free to reach out to me on [Twitter](https://twitter.com/ravinwashere).
python dict get
Tags: python
Published: 2022-02-03 12:55:06

---
canonical_url: https://waylonwalker.com/til/python-dict-get/
published: true
tags:
- python
series: til
title: python dict get
---

For an embarrassingly long time, til today, I have been wrapping my dict gets with key errors in python.  I'm sure I've read it in code a bunch of times, but just brushed over why you would use get.  That is until I read a bunch of PR's from my buddy Nic and notice that he never gets things with brackets and always with `.get`.  This turns out so much cleaner to create a default case than try except.


## Example

Lets consider this example for prices of supplies.  Here we set a variable of prices as a dictionary of items and thier price.

``` python
prices = {'pen': 1.2, 'pencil', 0.3, 'eraser', 2.3}
```

## Except KeyError

What I would always do is try to get the key, and if it failed on KeyError, I would set the value (`paper_price` in this case) to a default value.

``` python
try:
    paper_price = prices['paper']
except KeyError:
    paper_price = None
```

## .get

What I noticed Nic does is to use get.  This feels just so much cleaner that it's a one liner and feels much easier to read and understand that if there is no price for paper we set it to `None`.

``` python 
paper_price = prices.get('paper', None)
```

We can just as easily set the default to other values.  Let's consider sales for instance.  If there is not a record for the sale of paper, it might be that we sold 0 paper in the given dataset.

``` python
paper_sales = sales.get('paper', 0)
```
How to Create Own Cache driver and Learn Cache drivers from Laravel
Tags: laravel, drivers, cache, custom
Published: 2022-02-03 13:33:21

Laravel provides an expressive, unified API for various caching backends. We stored all Cache information in the config/cache.php file of your project. They configure Laravel to use a file cache driver to keep the serialized cached objects in the filesystem.

## Driver Prerequisites:-

### Database:
You are going with a database cache driver. You will need to create a table that contains cache items.
```
Schema::create('cache', function ($table) {
    $table->string('key')->unique();
    $table->text('value');
    $table->integer('expiration');
});
```
Run the artisan command php artisan cache:table. It will generate a migration with the proper schema.

### Memcached:
For Memcached driver requires Memcached PECL package. You may list all the Memcached servers in the config/cache.php file.

```
'memcached' => [
    [
        'host' => '127.0.0.1',
        'port' => 11211,
        'weight' => 100
    ],
],
```

[Read More](https://www.devrohit.com/cache-in-laravel/)
Another way of working with temporary files
Tags: python, productivity, programming, tutorial
Published: 2022-02-03 13:32:30

🗂 [`tmp-folder`](https://github.com/jalvaradosegura/tmp-folder) allows you to easily use a temporary folder during the execution of a function. After it is done executing, the folder will be automatically deleted (with all its content of course).

## Install it
```
pip install tmp-folder
```

## Watch it in action
All you need to do is to decorate the function that needs a temporary folder and your function will get a free extra parameter, that's your `tmp-folder`:

```py
# main.py
from pathlib import Path

from tmp_folder import use_tmp_folder


@use_tmp_folder  # This is the decorator
def do_some_stuff(my_tmp_folder: Path) -> Path:
    with open(my_tmp_folder / "some_file.txt", "w") as file:
        file.write("Hello World")

    assert my_tmp_folder.exists()

    return my_tmp_folder


if __name__ == "__main__":
    my_tmp_folder = do_some_stuff()
    assert not my_tmp_folder.exists()
    print("Everything went ok")

```

We execute the code with `python main.py`:

```
Everything went ok
```

✅ Cool, there are no assertion errors 👏🎉🎉🎉.

## Key points:
* The function that needs temporary stuff, is decorated with `use_tmp_folder`.
* You get a new parameter in your decorated function (it can be named however you want, in this case `my_tmp_folder`). See how when you are calling `do_some_stuff`, you are not passing any argument, but on its definition there is a parameter, well, that's because `tmp-folder` adds it for you.
* This new parameter is the temporary folder that `tmp-folder` gives you. You can store whatever you want in there. After the decorated function is done executing: bye bye temporary folder 👋.
* The parameter is a `Path` object, so you get all the cool things `pathlib` offers.
* The decorator is built on top of Python's  `TemporaryDirectory`, so you know is a safe thing to use.

---
For more details see the package [documentation](https://jalvaradosegura.github.io/tmp-folder/).
Image [author](https://www.instagram.com/circus.infernus/).
Get 1z0-1060-21 Online Test Engine For Immediate Learning - Dumpspass4sure.com
Tags: javascript, education, programming, oracle
Published: 2022-02-03 13:21:19

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6bcjsx3eorabaiqdz6w1.jpg)
There are no better learning materials than 1z0-1060-21 Exam Dumps because they have shown 100% result. IT has become a priority for IT students. You can easily transfer your certificate with the first attempt if you study intelligently according to expert guidelines at Dumpspass4sure. You can bring about the best results if you put your best efforts into the **[Pass4sure 1z0-1060-21 Study Material](https://www.dumpspass4sure.com/oracle/1z0-1060-21-dumps.html
)**. These items are available for download in PDF form but before downloading the full file you can check the demo questions for free. In addition, if you want to be accurate and check what you are reading you can practice in the online test engine after completing the 1z0-1060-21 Dumps.

Visit this site:[https://www.freeoracledumps.com/1z0-1060-21-dumps.html](https://www.freeoracledumps.com/1z0-1060-21-dumps.html)
How JavaScript work and It Execution Context
Tags: beginners, javascript, codenewbie, programming
Published: 2022-02-03 13:19:40

First of all Good day reader... surely shall you enjoy this content, yes you🙂.

Everything in JavaScript happens inside an Execution Context. you can assume this Execution Context as a Big Box where everything happens inside(code is stored and is been executed).

Below is a picture that explains the above said



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


The first Part is referred to Memory Component(Variable Environment). This is a place where all FUNCTIONS AND VARIABLES are stored as a Key:Value(Var name = 'Esla') (function Him() { var name = 'Esla') pairs.

The second Part is referred to Execution Context(Thread of Execution). This is where code is been EXECUTED Line by Line in an orderly or synchronously way.

I pray you find this article insightful. Thank you and remain bless.
Adding Custom Claims to ID Tokens with Auth0 Actions
Tags: webdev, programming, security
Published: 2022-02-03 13:10:26

### Learn how to create a new custom action that will add a custom claim to your Auth0-issued ID Token.

### <br>

Did you know that you can use Actions to customize the user ID token? Well, if you need to add custom claims to your users' ID tokens, you came to the right place! With this tutorial, you'll learn how to use the power of Actions to include custom claims to users' ID tokens.

If you prefer, you can also watch the videos below with me explaining to add custom claims to your users' ID tokens using Actions 👇!

{% youtube noLO8qv1jjs %}

## Auth0 Issued ID Tokens and Custom Claims

[ID Tokens](https://auth0.com/docs/secure/tokens/id-tokens) are commonly used in token-based authentication to pass user information to a client application. At Auth0, ID Tokens follow the [JSON Web Token (JWT)](https://auth0.com/docs/secure/tokens/json-web-tokens) standard; this means that all ID tokens Auth0 issues are JWTs.

Claims are pieces of information about a given subject. In the case of ID Tokens, claims will contain information about the user, such as the user's name. Using custom claims can give your ID token extra information that can improve your application, for example, storing a user ID from a third party or system.

In this example, you'll see how to use Actions to make a request to an external API and store back the obtained information as a custom claim to ID token payload to be used on the sample application.

## The Sample Application

Before you begin, you will need a sample code to customize.

>  For this blog post, you will use the React single-page application (SPA) sample. Keep in mind that <u>you can use what you'll learn here and apply it to your app no matter what language or framework it uses</u>.

You can clone the sample application from GitHub with the following command:

```bash
git clone https://github.com/auth0-blog/assign-random-dog.git
```

After the cloning finishes, follow the [README.md file](https://github.com/auth0-blog/assign-random-dog/blob/main/README.md) instructions to configure it to use Auth0. You'll need an Auth0 account, and if you don't have it, <a href="https://auth0.com/signup"  data-amp-replace="CLIENT_ID"  data-amp-addparams="anonId=CLIENT_ID(cid-scope-cookie-fallback-name)">you can get one for free here</a>.

After configuring the sample application, you can go into the app root folder and run it with the following command:

```bash
npm start
```

Open your browser and access [https://localhost:3000/](https://localhost:3000/). You should get the following page:

![Sample app home page](https://images.ctfassets.net/23aumh6u8s0i/1KGVVbq1ML8VZkXFhPgAWJ/205d7b2cac63ab7c718aa74d2c1d056a/starter-react-app)


[Read more...](https://auth0.com/blog/adding-custom-claims-to-id-token-with-auth0-actions/?utm_source=content_synd&utm_medium=sc&utm_campaign=actions)
"Hope you are doing well <3" - don't listen to people online
Tags: discuss, career, productivity, beginners
Published: 2022-02-03 12:47:46

Maybe you found on the Internet recently, that there are many companies and people online who are trying to convince you or me that they care about us.

It's like small talk of the current decade, but instead of simple "How are you?", they are trying to make you comfy by ensuring they take care of your emotional or physical state. The trend is not new, but it started growing when covid hit for the first time and Facebook introduced care emoji:

![Facebook Care Emoji](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/njp1elrs9srh84twlina.jpg)

What kind of emotion these companies or people are trying to introduce? I don't know, it's not my field of specialization. But, I surely know most of them don't give a fu*k about you or me. They wrote this to wear the mask of a friendly and caretaking company, recruiter or online buddy. 

With research on people being more lonely and [more fragile to criticism or different views than previous generations](https://www.scientificamerican.com/article/kids-today-are-being-socialized-to-think-theyre-fragile-snowflakes/), you can imagine what groups of people are especially affected by these words. People with low esteem or low emotional intelligence are usually feeling it's the duty of the company or other people online to take care of them because their [narcissistic way of living](https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0215637) can't accept living or taking responsibility for their own life.

One day Slack communicator wrote the following misleading update message. Thank you Slack, but I would rather read if the recently spotted minor bugs were fixed.

![Slack stupid message](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wm0rutbgo0nruytcja7i.jpg)
 
You can find this type of message everywhere. From LinkedIn posts, memes, insta stories to comments and post forums. For sure Internet is now a more friendly place but at the same time, it seems more artificial and fake.

Don't trust people online. They don't care about you. A few nice words won't change anything. Yeah, I'm grumpy and maybe this post is also not true. Maybe companies and people who don't know you, really take care how well you are feeling now. Or maybe if you need psychological advice you can visit the doctor and don't spend time relying on online comments. 

And remember:

![Lol](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/psxivufxo005jw9wd5sp.png)
 
What's your opinion on the take-care friendly messages online? I am eager to read and change my mind about the topic.
What is JSON
Tags: json, javascript, beginners, webdev
Published: 2022-02-03 12:35:31

JSON which is popularly known as javascript object notation, it is a text format used to transfer data from server to client in plain text format.

the format of json is similar to javascript objects.

here is how javascript object looks like:


![code 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dqa3rzf9w5fk9yfxpgbv.png)

next we are going to convert this `person` object to `JSON` using a method called `JSON.parse()`


![code 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lhody1kf4xvxvk123w7g.png)

the output looks like plain text. and that is called `JSON` data 

```
{"firstName":"John","lastName":"Doe","age":17,"address":{"city":"abc city","street":"abc street"}}
```
to convert back this `JSON` data to string we should use a method called `JSON.stringify()` and pass person object to it

there is an amazing website called [https://jsonlint.com/](https://jsonlint.com/) to test our json code
We are more than 75,000 people (stars 🌟) — awesome-go
Tags: opensource, go, github, programming
Published: 2022-02-03 12:06:10

I've been meaning to write this blogpost since when we reached 10,000 stars 🌟 (I never imagined it would reach that number of people), but every day I reached more (and more) people and always thought the text would get outdated.

> Today is the day to thank everyone who uses, contributes and follows awesome-go, it's time to celebrate 🎉🙌 — regardless of the number we reach and the people we help in some way.

Awesome-go was born on **2014-07-06** inspired by the _[awesome-python](https://github.com/vinta/awesome-python)_ project, after the [first commit](https://github.com/avelino/awesome-go/commit/8d356bc0dfbe817a378186b9b6fb5afe81781d42) containing _3 categories_ I messaged some friends who used Go at work to help list the libraries they used in their day-to-day work.

![awesome-go first commit](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nqu0nrobes34ggp4vcod.png)

I never imagined that a _“no code”_ project would receive so many contributions (we are more than [2000 contributors](https://github.com/avelino/awesome-go/graphs/contributors)).

As the number of pull requests grew, reviewing the contributions became impossible, and we had to invest time to automate our review work as much as possible by bringing in an automated process via CI to optimize the time of all maintainers of the project (now using code), running on each open pull request.

## Thanks to 🙏

I’m grateful to our community for all the support, I am excited by the number of people we reach and somehow help them find the best library for their project 💜.

Here is my eternal gratitude to all the people who send in their libraries and who help me keep awesome-go running ([the maintainers](https://github.com/avelino/awesome-go/graphs/contributors), _**you are amazing**_).

👉 Help us reach 100k! 🌟 [http://github.com/avelino/awesome-go](http://github.com/avelino/awesome-go)