teleren/devto huggingface dataset:
Remember you tmux hotkeys with list-keys
Tags: cli, linux, tmux
Published: 2021-08-12 16:08:24

---
title: Remember you tmux hotkeys with list-keys
tags: ['cli', 'linux', 'tmux',]
series: tmux
canonical_url: https://waylonwalker.com/tmux-list-keys/
published: true
---

Tmux list keys can be a useful tool to help remind you of what kebindinfs you
have setup.  You can search for them and scroll just like in tmux copy-mode.

## command line

You can call list-keys from the command line but the interface is not very
usable by itself.  It might be nice to mix with grep or a pager in some
circumstances.

``` bash
tmux list-keys
```

## tmux command line

Running `list-keys` from within the tmux command line puts you into a much more
pleasant `copy-mode`.

```
list-keys
```

## default keybinging

By default tmux comes with `list-keys` bound to prefix+?.

``` bash
bind-key          ? list-keys
```

## list-keys man page

You can see the additional flags provided by tmux in the man page for
`list-keys`.

``` bash
list-keys [-1aN] [-P prefix-string -T key-table] [key]
            (alias: lsk)

        List key bindings.  There are two forms: the default lists keys as
        bind-key commands; -N lists only keys with attached notes and shows
        only the ke y and note for each key.

        With the default form, all key tables are listed by default.  -T lists only keys in key-table.

        With the -N form, only keys in the root and prefix key tables are
        listed by default; -T also lists only keys in key-table.  -P specifies
        a prefix to print before each key and -1 lists only the first matching
        key.  -a lists the command for keys that do not have a note rather than
        skipping them.

```

Be sure to check out the full YouTube playlist and subscribe if you like it.

[![tmux playlist on youtub](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v4cgo76y53s1hwykajo1.png)](https://www.youtube.com/playlist?list=PLTRNG6WIHETB4reAxbWza3CZeP9KL6Bkr)

{% post https://dev.to/waylonwalker/how-i-navigate-tmux-in-2021-2ina %}
Mastering JS' 4 Best ESLint Tutorials
Tags: javascript, codenewbie
Published: 2021-08-12 16:06:33

At Mastering JS, we love [ESLint](https://masteringjs.io/eslint). However, ESLint is one of those tools that we strive to work with as **little** as possible. Every minute you spent tinkering with your linter config is a minute that you're not spending working on features or fixes. So make sure it's worth the effort!

Here's some of our most popular tutorials for ESLint:

4) [Intro to ESLint Config Files](https://masteringjs.io/tutorials/eslint/config)

This tutorial shows how to get started with your own ESLint config, including what version of JavaScript you're using and what rules you want to enforce.

3) [Understanding ESLint Rules](https://masteringjs.io/tutorials/eslint/rules)

Once you know how to create an [ESLint config file](https://masteringjs.io/tutorials/eslint/config), you need to configure rules. Even if you're using a preset config, like [Standard](https://standardjs.com/), you may find yourself wanting to overwrite default rules that don't make sense for your application. This tutorial shows you how to configure ESLint rules, from basic enable/disable to sophisticated config options.

2) [Using ESLint's --fix Flag](https://masteringjs.io/tutorials/eslint/fix)

ESLint can fix violations of certain rules automatically. Here's how you can use `--fix`, including how to set `--fix` when using npm scripts.

1) [Ignore Lines and Files In ESLint](https://masteringjs.io/tutorials/eslint/ignore)

Isn't it ironic that our most popular ESLint tutorial is how to disable ESLint? Well intentioned lint rules are helpful, but there's an exception to just about every rule. This tutorial shows you how to disable one ESLint rule for one line, one ESLint rule for one file, or ignore all rules in one file.
Ordering by Choice Label in Django
Tags: django
Published: 2021-08-12 15:55:15

_Photo by_ [_Edu Grande_](https://unsplash.com/@edgr?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) _on_ [_Unsplash_](https://unsplash.com/?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)
  

Let's say you have a Choice field on your model. And you want to order by that choice labels. It's a no-brainer if values and labels are the same. Because values are stored in the database and it's the one in charge of ordering.

```python
from django.db.models import TextChoices


class State(TextChoices):
    STARTED = 'STARTED', 'Started'
    WORKING = 'WORKING', 'Working'
    FINISHED = 'FINISHED', 'Finished'
```

This will work out of the box:

```python
from django_filters import (
    FilterSet,
    ...,
    OrderingFilter,
)

class MyFilter(FilterSet):
    ...some fields filtering declaration...
    
    ordering = OrderingFilter(
        fields: {
            'state': 'state',
        }
    )

    class Meta:
        model = MyModel
```

But if labels differ from values it just won't work. Because now the database doesn't know anything about labels.

```python
from django.db.models import TextChoices


class State(TextChoices):
    STARTED = 'STARTED', 'Initiated'
    WORKING = 'WORKING', 'Operating'
    FINISHED = 'FINISHED', 'Stopped'
```

What you'd need to do now is to sort State labels and then create `Case > When > Then` chains. This way the database will know how you want to order results (but it's still oblivious about the whole "labels" thing).

```python
class MyOrderingFilter(OrderingFilter):
    def filter(self, qs, value):
        state = None
        if value:
            for idx, param in enumerate(value):
                if param.strip('-') == 'state':
                    state = value.pop(idx)

        qs = super(MyOrderingFilter, self).filter(qs, value)
        if state:
            sorted_states = {
                val[0]: idx
                for idx, val in enumerate(
                    sorted(
                        State.choices,
                        key=lambda x: x[1],
                        reverse='-' in state,
                    )
                )
            }
            qs = qs.order_by(
                Case(
                    *[
                        When(state=key, then=Value(val))
                        for key, val in sorted_states.items()
                    ]
                )
            )

        return qs
```

And then use `MyOrderingFilter` instead of `OrderingFilter` in `MyFilter` from the snippet above. The magic happens inside `sorted_states = {...}` dict comprehension. We tell our DB that we want our values with label "Initiated" to be first (or rather zero) in order, values with "Operating" to be second and so on. And when we're building `qs = qs.order_by(Case(...))` we're just constructing the query itself.

So now your ordering will work according to the choice labels and not it's values.
The Ultimate Guide to Building a no-code WhatsApp bot in 2021
Tags: ai
Published: 2021-08-12 15:53:59

Introduction:

We cannot talk about instant messaging without mentioning WhatsApp. In 2020, WhatsApp had more than 2 billion active users! It suffices to say that WhatsApp is the most popular messaging platform globally, and users spend 195 minutes per week on WhatsApp. This makes me want to ask- Are you reaching out to your customers on this messaging platform?

Maybe you want to. Maybe your competitors are already doing it. But perhaps you’re at a technical standoff. You’re thinking, “Where do I start?”. If you’re looking for an answer, you’re at the right place. Speaking with prospective customers and having automated and real-time conversations with them is possible with the <a href:"https://wotnot.io/blog/guide-to-create-whatsapp-bot/">WhatsApp chatbot</a>.

This article is originally published here: https://wotnot.io/blog/guide-to-create-whatsapp-bot/
My experience with LGM'SOC-21!
Tags: opensource, webdev
Published: 2021-08-12 15:52:51

Welcome to my very first blog as well as very first actual open source experience! 🥳

![Idea](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pdi4lhcbyjeke5roywtx.png)
 
'[Let's Grow More](https://letsgrowmore.in/)' is a community of developers helping other developers to 'grow' as a developer. The community aims to help new software developers and provide learning opportunities to build a better tomorrow by organizing various events.

One of the events is **LetsGrowMore's Summer of Code**, an open-source event which was conducted from May to August of 2021. It was my second experience of contributing to an open-source event but the first one that contributed significant PRs.
 
The main thing I learnt during this event is the importance of time. There are so many other developers with same or better experience than you who want to work on the same project. So, if you are assigned to an issue, solve it ASAP or forget about PR!
 
Other few things I'd like to mention is I gained confidence to design websites with vanilla JS. I used Bulma in two projects and got my hands dirty with Bulma CSS too.
 
It was great working with real projects and contributing to the wide range of projects during the month of development. Though I didn't find enough time to contribute to many issues, I enjoyed and learnt a lot while resolving the one I was assigned!

Happy Contributing! 🎉
I'm at a loss on how to market my creations
Tags: help, webdev
Published: 2021-08-12 15:48:13

TL;Dr
I need some inspiration, creative ideas on how to market my website, with out having to spend months learning SEO/Marketing. I also don't have much money to spend on it. 


# Hello! 

We all can create awesome websites... but how many of us can actually get people to use it? 

I've worked on websites with hundreds of thousands of users, but they were never my personal projects. 


## Dirty Secret
I have a confession. 

Over the last 27 years of developing websites, I've only ever had one time where one of my project had more than a 1000 users. To be even more honest, I've not had any traffic on a lot of them and eventually let them fade away.

It may sounds like I'm clueless in the marketing arena, which would a little true, but most of it is that I hate doing what I fear or feel I'm not great at. 

## The fear is real
It's really two part that I've come to realize why, with the first being that I LOVE creating websites but I don't enjoy content creation (you think i would being a creator) nor generating traffic.

The second being that I'm a little fearful of the amount of stress and work it would take if I did have a successful website of my own.

## Side gig vs Work
It's totally different if you're working for someone else, I feel confident and it's no big deal because I work hard and maintain great quality code and processes. It's my all day every day thing, so I carry little to no fear.

But part time, side gigs? Ya they don't really allow room for error due to the lack of time allowed for them.

What should I do? Just pay for someone? I can't really afford much. I wouldn't be working multiple jobs if I could. So what does that leave me? 

This is my first attempt, writing this article/confession in hope to find someone or multiple people that can be kind enough to guide me. 

I am asking for help. I need to know what I can do. I could use something to motivate myself around marketing. 

I am willing to face my fears, I just need some guidance.

Will you help me? 

p.s. I know how to google, I know how to find tutorials. I can learn. I just don't have the bandwidth to become great at all of it. I need the solutions that I CAN do with me being solo.


---

Varymade LLC.

Current projects are https://charactergenerator4000.com and https://coder.exchange. Please check them out and let us know your thoughts.
Python Boot Camp.
Published: 2021-08-12 15:45:13

##Introduction
##Why python language?
Python is easy to learn, write and read. It’s a great starting programming language for beginners, and is easy to pick up for experienced developers. Despite its simplicity, Python’s growing job demand and technical versatility are everything but ordinary.

#Progress according to the four weeks
#Week one
Week one commenced with a variety of talks from how to be good python developer to setting up the environment and writing clean code. I learnt the professional way of writing python code. To make my learning easier I used Python Tutorial website for reference.

And by the end of the week I was able to build my a random password generator using python code. 
#Week 2
In this current week we begun to dig deeper, going from functions to complex python stuffs as we progressed to later weeks.
We were able to tackle: 
* Functions
* List, tuples, dictionaries & sets
* Data structures and algorithms
* Some of the common methods used in python.

#Week 3
Things got a little bit intense, We begun to dive more deeper. 
We were introduced to Flask applications factory & then the dynamic routing in a flask app. 
And the final week we start interacting with python for data science and machine learning. 
There is still much more to be covered in this last week, from data science to machine learning. 

_Hope you liked this article, stay tuned for further updates & *Happy coding*_
How to Rotate User Agent String While Web Scraping

Published: 2021-08-12 15:39:28

Are you getting IP blocked repeatedly when web scraping at scale?

Is this happening even after passing it through a couple of free proxy servers?

It might be because the target website's algorithm might be picking up on who you are by the User-Agent-String signature that your curl request or any other library you might be using is sending. Even the absence of it is telling.

But if you do it well, you do get a lease of life, albeit only for a while

https://youtu.be/QZUMMLpUTmo
Publishing a port on an existing docker container
Tags: docker
Published: 2021-08-12 15:36:43

When you need to publish some port on a container that was already run, you can do this by changing internal docker files.

First, you need to find the container `id` with

```
docker inspect <container_name>
```
Stop the container if it's running and go to the container directory:
```
cd /var/lib/docker/containers/<container_id>
```

<small>For `wsl` users, the container directory can be found here:<br/>`\\wsl$\docker-desktop-data\version-pack-data\community\docker\containers`</small>

add `"ExposedPorts"` to `config.v2.json`:
```
"Config": {
    ....
    "ExposedPorts": {
        "<port_number>/tcp": {},
    },
    ....
},
```
and `"PortBindings"` to `hostconfig.json`:
```
"PortBindings": {
     "<port_number>/tcp": [
         {
             "HostIp": "",
             "HostPort": "<port_number>"
         }
     ]
 }
```
For best results restart docker service:
```
systemctl restart docker
```
Now you can start the container and it should have ports published.
What Can I Do If a Parsing Error Occurs When I Update HMS Core (APK) on Non-Huawei Phones
Tags: huawei, hms, android
Published: 2021-08-12 15:35:15

#Problem

I successfully integrated the HMS Core SDK (HMS 5.1.0.300 on Android Studio) during a test on Huawei mobile phones. However, when I loaded a game on a Xiaomi phone, it prompted me to update HMS Core, and when I tried to update it a parsing error occurred.

#Analysis & Solution

We contacted Huawei technical support in the game’s QQ group (if you have not joined the group, you can also submit a ticket to Huawei’s technical support team) and they advised us to:
1. Check whether HUAWEI AppGallery has been installed on the non-Huawei phone.
If not, download and install HUAWEI AppGallery.
2. Check whether metadata has been configured. If the HMS Base SDK version is 5.0.4.300 or later, you need to [configure the metadata](https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides-V5/integrate-as-sdk-0000001050435953-V5#ZH-CN_TOPIC_0000001050435953__section1366322514715) shown in the following figure.
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iecz0ghm4bwk95p6yfav.png)
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xng53avmfivfzs22umjk.png) 
 
The metadata has already been configured, meaning it is not the problem.
3. Finally, the technical support asked whether the provider section has been added to the manifest file.
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6wtqlb28o60p28xmdilp.png) 
 
If not, an error indicating package parsing failure will be reported when HMS Core (APK) is installed on some models.
Note: The value of applicationId must be the app’s ID.

After following these steps, the Xiaomi phone test works as expected. 

These solutions will also work for other non-Huawei phones.
Ví clutch da nam
Published: 2021-08-12 15:32:24

Ví clutch da nam, ví cầm tay cho nam, Ví dài nam, Clutch dự tiệc sang trọng, Clutch doanh nhân cao cấp, hàng hiệu, handmade  sang trọng, lịch lãm
https://hangdachat.com/dm/clutch-da-nam/ 
#clutchcamtaynam #tuiclutchnam #clutchnamhanghieu #viclutchnam #clutchnamdathat #clutchnamcaocap #clutchnamhanoi #mauclutchnamdep #clutchdanam #clutchnamtphcm #vicamtayclutchnam #banclutchnam #clutchnamprada #clutchchonam #clutchnamcamtay #clutchnamgiare
/m/04lbp /m/0n5v01m /m/080hkjn /m/0176mf /m/02_vjy /m/06rrc /m/033j5y /m/03h90x /m/03gc5x

Website: https://hangdachat.com
Địa chỉ: 168 Trương Định, Hai Bà Trưng, Hà Nội
Hotline: 0905.281.262
How to generate randomly integer number with sign in JavaScript
Tags: javascript
Published: 2021-08-12 15:15:53

凭直觉第一反应，可能是封装一下``Math.random()``，但考虑到效率，这是最不建议的方式，使用``random``组件更痛快，这里的min和max都是包含的，也省去思考区间范围的烦恼

```
import random from 'random';
const randomInteger = random.int(min, max);
```

进一步的，比如默认值是0，我们希望随机修改为其他的一个整数，有可能是正整数，有可能是负的，但不能是0，应该怎么搞呢？一个函数搞定

```
const randomNonZeroInteger = (min, max) => random.int(min, max) || randomNonZeroInteger(min, max);
```

再进一步，如果我们希望生成一个跟指定值不同的随机数
```
const randomIntExcept = (value) => {
  const randomInt = random.int(magic.result.min, magic.result.max);
  if (value === randomInt) {
    return randomIntExcept(value);
  }

  return randomInt;
};
```

### References
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random
* https://www.npmjs.com/package/random
* https://www.udacity.com/blog/2021/04/javascript-random-numbers.html
Github Web editor: Edit any repo with just a press
Tags: github, code, vscode, git
Published: 2021-08-12 15:08:47

Do you want to have your mind blown?  🤯

**Check this new feature of Github**.

Just go to any of the repo you like and just press <kbd>.</kbd>. Yeah, you have seen it right. Just press on the period (.) sign on the keyboard and your mind will blow. This will open the code editor in the browser with the files of Github Repo.

Don't forgot to watch this video.

[https://www.loom.com/share/1940c85408444269bb1a90b84df71ab2](https://www.loom.com/share/1940c85408444269bb1a90b84df71ab2)
Using ES6 Modules with Jest
Tags: javascript, testing, jest, es6modules
Published: 2021-08-12 15:03:42

In this post we're going to see two possible ways of enabling ES6 Modules with Jest that works with all operating systems.

So, following is the screenshot of the file structure, nothing complex just a simple node app with `jest` installed (`npm i jest`)

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rm1usuwxsy36eu4qtkmv.png)

And following is the contents of `index.js` and `index.test.js`.

#### index.js
```js
export default (a, b) => a + b;
```

#### index.test.js
```js
import sum from "./index.js";

it("should sum", () => {
  expect(sum(1, 2)).toBe(3);
});
```

Now, let's update the test script and enable ES6 modules in `package.json`.

#### package.json
```json
{
  "name": "jest-es6-modules",
  "type": "module",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "jest"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "jest": "^27.0.6"
  }
}
```

But if you run `npm test` you would notice Jest is complaining that it cannot recognize `import`, so let's fix this.

### Method 1
All you need to do is set the `experimental-vm-modules` flag. Just modify the `test` script in `package.json` to the following:

#### package.json
```json
"scripts": {
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
}
```

### Method 2
You can also install [`cross-env`](https://github.com/kentcdodds/cross-env) as a dev dependency and use that for setting `NODE_OPTIONS`.

```bash
npm i --save-dev cross-env
```

#### package.json
```json
"scripts": {
  "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest"
}
```

Now, you can use ES6 modules with Jest. Hurray!

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3pe4dz20hjl42d2cp3of.png)
How to test whether a specific button is included in the document
Tags: testinglibrary, jest, jestdom
Published: 2021-08-12 14:33:44

最简单的方式的，其实是用test ID，没有任何限制，因为这个ID是我们指定用来测试的，所以跟业务没有什么关系，也不需要考虑按钮显示文字发生变化。

测试用例，主要要用``queryByTestId``，而不是``getByTestId``，如果用了后者，没有找到这个元素的时候会抛出异常。

```
it('should have increase button', () => {
  const { queryByTestId } = render(<App />);
  const button = queryByTestId('increase-button');
  expect(button).toBeInTheDocument();
})
```

通过验证的代码
```
<button data-testid="increase-button">+1</button>
```

另外一种方式，可以用``queryByRole``，对于button元素来说，不需要显性设置，他的role就是button，这时候可能还需要搭配其他的属性，比如我们用``aria-label``

```
it('should have increase button', () => {
  const { queryByRole } = render(<App />);
  const button = queryByRole('button', { name: 'increase-button' });
  expect(button).toBeInTheDocument();
})
```

通过验证的代码
```
<button aria-label="increase-button">+1</button>
```

如果我们要进一步验证，可以测试查询到元素的类型和内容
```
expect(button.nodeName).toBe('BUTTON');
expect(button.textContent).toBe('+1');
```

### References
* https://testing-library.com/docs/queries/byrole
* https://testing-library.com/docs/queries/bytestid
* https://www.npmjs.com/package/@testing-library/jest-dom#tobeinthedocument
* https://jestjs.io/docs/expect#tobevalue