Explore all Blog open source software, libraries, packages, source code, cloud functions and APIs.

Popular New Releases in Blog

hexo

5.4.2

mastodon

v3.5.1

mastodon

v3.4.1

halo

1.5.2

vuepress

v1.9.2

Popular Libraries in Blog

hexo

by hexojs doticonjavascriptdoticon

star image 34576 doticonMIT

A fast, simple & powerful blog framework, powered by Node.js.

mastodon

by mastodon doticonrubydoticon

star image 27588 doticonAGPL-3.0

Your self-hosted, globally interconnected microblogging community

mastodon

by tootsuite doticonrubydoticon

star image 24411 doticonAGPL-3.0

Your self-hosted, globally interconnected microblogging community

halo

by halo-dev doticonjavadoticon

star image 21921 doticonGPL-3.0

✍ 一款现代化的开源博客 / CMS 系统。

vuepress

by vuejs doticonjavascriptdoticon

star image 20197 doticonMIT

📝 Minimalistic Vue-powered static site generator

octopress

by imathis doticonrubydoticon

star image 9392 doticon

Octopress is an obsessively designed framework for Jekyll blogging. It’s easy to configure and easy to deploy. Sweet huh?

typecho

by typecho doticonphpdoticon

star image 8752 doticonGPL-2.0

A PHP Blogging Platform. Simple and Powerful.

gridea

by getgridea doticoncssdoticon

star image 7655 doticonMIT

✍️A static blog writing client (一个静态博客写作客户端)

utterances

by utterance doticontypescriptdoticon

star image 6268 doticonMIT

:crystal_ball: A lightweight comments widget built on GitHub issues

Trending New libraries in Blog

rust-blog

by pretzelhammer doticonrustdoticon

star image 3543 doticonNOASSERTION

Educational blog posts for Rust beginners

fastpages

by fastai doticonjupyter notebookdoticon

star image 2667 doticonApache-2.0

An easy to use blogging platform, with enhanced support for Jupyter Notebooks.

tailwind-nextjs-starter-blog

by timlrx doticonjavascriptdoticon

star image 2482 doticonMIT

This is a Next.js, Tailwind CSS blogging starter template. Comes out of the box configured with the latest technologies to make technical writing a breeze. Easily configurable and customizable. Perfect as a replacement to existing Jekyll and Hugo individual blogs.

nobelium

by craigary doticonjavascriptdoticon

star image 1314 doticonMIT

A static blog build on top of Notion and NextJS, deployed on Vercel.

BlogHelper

by onblog doticonjavascriptdoticon

star image 1082 doticonGPL-3.0

帮助国内用户写作的托盘助手,一键发布本地文章到主流博客平台(知乎、简书、博客园、CSDN、SegmentFault、掘金、开源中国),剪贴板图片一键上传至图床(新浪、Github、图壳、腾讯云、阿里云、又拍云、七牛云)(欢迎Star,🚫禁止Fork)

JD_Sign_Action

by xcqlucky doticonjavascriptdoticon

star image 923 doticon

基于github actions的京东自动化签到

waline

by walinejs doticonjavascriptdoticon

star image 738 doticonGPL-2.0

A Simple, Safe Comment System inspired by Valine | 一款基于 Valine 衍生的简洁、安全的评论系统

CPP_Optimizations_Diary

by facontidavide doticonc++doticon

star image 546 doticon

Tips and tricks to optimize your C++ code

fluss

by cnblogs doticoncsharpdoticon

star image 513 doticonApache-2.0

fluss is a blog engine, powered by .NET

Top Authors in Blog

1

hexojs

28 Libraries

star icon35671

2

TryGhost

11 Libraries

star icon4127

3

AppliedGo

10 Libraries

star icon32

4

YunoHost-Apps

9 Libraries

star icon146

5

tootsuite

8 Libraries

star icon24711

6

draftbox-co

8 Libraries

star icon102

7

strapi

6 Libraries

star icon794

8

theoria24

5 Libraries

star icon49

9

stevenh77

5 Libraries

star icon18

10

octopress

5 Libraries

star icon1786

1

28 Libraries

star icon35671

2

11 Libraries

star icon4127

3

10 Libraries

star icon32

4

9 Libraries

star icon146

5

8 Libraries

star icon24711

6

8 Libraries

star icon102

7

6 Libraries

star icon794

8

5 Libraries

star icon49

9

5 Libraries

star icon18

10

5 Libraries

star icon1786

Trending Kits in Blog

No Trending Kits are available at this moment for Blog

Trending Discussions on Blog

Error while loading rule 'prettier/prettier': context.getPhysicalFilename is not a function

What is jsconfig.json

The unauthenticated git protocol on port 9418 is no longer supported

npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher

Efficient overflow-immune arithmetic mean in C/C++

Error: Must use import to load ES Module: D:\node_modules\react-markdown\index.js require() of ES modules is not supported

Android Studio [BumbleBee 2021.1.1] Emulator Timeout on Mac M1

Log4j vulnerability - Is Log4j 1.2.17 vulnerable (was unable to find any JNDI code in source)?

Converting Numbers from Base 10 to Base 60

What's the mathematical reason behind Python choosing to round integer division toward negative infinity?

QUESTION

Error while loading rule 'prettier/prettier': context.getPhysicalFilename is not a function

Asked 2022-Apr-04 at 13:24

I am learning react js. I am a very beginner at this topic. But when I am doing setup to create a react environment I got an error. I have tried to solve the problem by Charles Stover blog in medium. But I got an error Command "up" not found.

Here's my index.js file:

1import React from 'react';
2import ReactDOM from 'react-dom';
3import App from './App';
4import reportWebVitals from './reportWebVitals';
5ReactDOM.render(
6   <React.StrictMode>
7      <App />
8   </React.StrictMode>,
9document.getElementById('root')
10);
11reportWebVitals();
12

My package.json file:

1import React from 'react';
2import ReactDOM from 'react-dom';
3import App from './App';
4import reportWebVitals from './reportWebVitals';
5ReactDOM.render(
6   <React.StrictMode>
7      <App />
8   </React.StrictMode>,
9document.getElementById('root')
10);
11reportWebVitals();
12{
13  "name": "myreact",
14  "version": "0.1.0",
15  "private": true,
16  "dependencies": {
17    "@testing-library/jest-dom": "^5.11.4",
18    "@testing-library/react": "^11.1.0",
19    "@testing-library/user-event": "^12.1.10",
20    "react": "^17.0.2",
21    "react-dom": "^17.0.2",
22    "react-scripts": "4.0.3",
23    "web-vitals": "^1.0.1"
24  },
25  "scripts": {
26    "start": "react-scripts start",
27    "build": "react-scripts build",
28    "test": "react-scripts test",
29    "eject": "react-scripts eject",
30    "lint": "yarn add -D prettier && yarn add -D babel-eslint && npx install-peerdeps --dev eslint-config-airbnb && yarn add -D eslint-config-prettier eslint-plugin-prettier"
31  },
32  "eslintConfig": {
33    "extends": [
34      "react-app",
35      "react-app/jest"
36    ]
37  },
38  "browserslist": {
39    "production": [
40      ">0.2%",
41      "not dead",
42      "not op_mini all"
43    ],
44    "development": [
45      "last 1 chrome version",
46      "last 1 firefox version",
47      "last 1 safari version"
48    ]
49  },
50  "devDependencies": {
51    "babel-eslint": "^10.1.0",
52    "eslint": "7.2.0",
53    "eslint-config-airbnb": "18.2.1",
54    "eslint-config-prettier": "^8.3.0",
55    "eslint-plugin-import": "2.22.1",
56    "eslint-plugin-jsx-a11y": "6.4.1",
57    "eslint-plugin-prettier": "^4.0.0",
58    "eslint-plugin-react": "7.21.5",
59    "eslint-plugin-react-hooks": "1.7.0",
60    "prettier": "^2.3.2"
61  }
62}
63

When I am running yarn start in terminal, I am getting an error.

1import React from 'react';
2import ReactDOM from 'react-dom';
3import App from './App';
4import reportWebVitals from './reportWebVitals';
5ReactDOM.render(
6   <React.StrictMode>
7      <App />
8   </React.StrictMode>,
9document.getElementById('root')
10);
11reportWebVitals();
12{
13  "name": "myreact",
14  "version": "0.1.0",
15  "private": true,
16  "dependencies": {
17    "@testing-library/jest-dom": "^5.11.4",
18    "@testing-library/react": "^11.1.0",
19    "@testing-library/user-event": "^12.1.10",
20    "react": "^17.0.2",
21    "react-dom": "^17.0.2",
22    "react-scripts": "4.0.3",
23    "web-vitals": "^1.0.1"
24  },
25  "scripts": {
26    "start": "react-scripts start",
27    "build": "react-scripts build",
28    "test": "react-scripts test",
29    "eject": "react-scripts eject",
30    "lint": "yarn add -D prettier && yarn add -D babel-eslint && npx install-peerdeps --dev eslint-config-airbnb && yarn add -D eslint-config-prettier eslint-plugin-prettier"
31  },
32  "eslintConfig": {
33    "extends": [
34      "react-app",
35      "react-app/jest"
36    ]
37  },
38  "browserslist": {
39    "production": [
40      ">0.2%",
41      "not dead",
42      "not op_mini all"
43    ],
44    "development": [
45      "last 1 chrome version",
46      "last 1 firefox version",
47      "last 1 safari version"
48    ]
49  },
50  "devDependencies": {
51    "babel-eslint": "^10.1.0",
52    "eslint": "7.2.0",
53    "eslint-config-airbnb": "18.2.1",
54    "eslint-config-prettier": "^8.3.0",
55    "eslint-plugin-import": "2.22.1",
56    "eslint-plugin-jsx-a11y": "6.4.1",
57    "eslint-plugin-prettier": "^4.0.0",
58    "eslint-plugin-react": "7.21.5",
59    "eslint-plugin-react-hooks": "1.7.0",
60    "prettier": "^2.3.2"
61  }
62}
63Error while loading rule 'prettier/prettier': context.getPhysicalFilename is not a function
64Occurred while linting F:\react-projects\myreact\src\index.js
65

Now what should I do?

ANSWER

Answered 2021-Sep-06 at 09:40

I got two different solution.

  1. remove
1import React from 'react';
2import ReactDOM from 'react-dom';
3import App from './App';
4import reportWebVitals from './reportWebVitals';
5ReactDOM.render(
6   <React.StrictMode>
7      <App />
8   </React.StrictMode>,
9document.getElementById('root')
10);
11reportWebVitals();
12{
13  "name": "myreact",
14  "version": "0.1.0",
15  "private": true,
16  "dependencies": {
17    "@testing-library/jest-dom": "^5.11.4",
18    "@testing-library/react": "^11.1.0",
19    "@testing-library/user-event": "^12.1.10",
20    "react": "^17.0.2",
21    "react-dom": "^17.0.2",
22    "react-scripts": "4.0.3",
23    "web-vitals": "^1.0.1"
24  },
25  "scripts": {
26    "start": "react-scripts start",
27    "build": "react-scripts build",
28    "test": "react-scripts test",
29    "eject": "react-scripts eject",
30    "lint": "yarn add -D prettier && yarn add -D babel-eslint && npx install-peerdeps --dev eslint-config-airbnb && yarn add -D eslint-config-prettier eslint-plugin-prettier"
31  },
32  "eslintConfig": {
33    "extends": [
34      "react-app",
35      "react-app/jest"
36    ]
37  },
38  "browserslist": {
39    "production": [
40      ">0.2%",
41      "not dead",
42      "not op_mini all"
43    ],
44    "development": [
45      "last 1 chrome version",
46      "last 1 firefox version",
47      "last 1 safari version"
48    ]
49  },
50  "devDependencies": {
51    "babel-eslint": "^10.1.0",
52    "eslint": "7.2.0",
53    "eslint-config-airbnb": "18.2.1",
54    "eslint-config-prettier": "^8.3.0",
55    "eslint-plugin-import": "2.22.1",
56    "eslint-plugin-jsx-a11y": "6.4.1",
57    "eslint-plugin-prettier": "^4.0.0",
58    "eslint-plugin-react": "7.21.5",
59    "eslint-plugin-react-hooks": "1.7.0",
60    "prettier": "^2.3.2"
61  }
62}
63Error while loading rule 'prettier/prettier': context.getPhysicalFilename is not a function
64Occurred while linting F:\react-projects\myreact\src\index.js
65"prettier/prettier": [
66            "error",
67            {
68                "trailingComma": "es5",
69                "singleQuote": true,
70                "printWidth": 100,
71                "tabWidth": 4,
72                "semi": true,
73                "endOfLine": "auto"
74            }
75        ]

from .eslintrc folder and change react script version from 4.0.3 to 4.0.1 and run npm install.

  1. Use yarn upgrade -R eslint and change react script version from 4.0.3 to 4.0.1 and run npm install.

Source https://stackoverflow.com/questions/69069719

QUESTION

What is jsconfig.json

Asked 2022-Mar-29 at 17:49

If i search the same question on the internet, then i'll get only links to vscode website ans some blogs which implements it.

I want to know that is jsconfig.json is specific to vscode or javascript/webpack?

What will happen if we deploy the application on AWS / Heroku, etc. Do we have to make change?

ANSWER

Answered 2021-Aug-06 at 04:10

This is definitely specific to VSCode.

The presence of jsconfig.json file in a directory indicates that the directory is the root of a JavaScript Project. The jsconfig.json file specifies the root files and the options for the features provided by the JavaScript language service.

Check more details here: https://code.visualstudio.com/docs/languages/jsconfig

You don't need this file when deploy it on AWS/Heroku, basically, you can exclude this from your commit if you are using git repo, i.e., add jsconfig.json in your .gitignore, this will make your project IDE independent.

Source https://stackoverflow.com/questions/68675994

QUESTION

The unauthenticated git protocol on port 9418 is no longer supported

Asked 2022-Mar-27 at 13:23

I have been using github actions for quite sometime but today my deployments started failing. Below is the error from github action logs

1Command: git
2Arguments: ls-remote --tags --heads git://github.com/adobe-webplatform/eve.git
3Directory: /home/runner/work/stackstream-fe/stackstream-fe
4Output:
5fatal: remote error: 
6  The unauthenticated git protocol on port 9418 is no longer supported.
7

Upon investigation, it appears that below section in my yml file is causing the issue.

1Command: git
2Arguments: ls-remote --tags --heads git://github.com/adobe-webplatform/eve.git
3Directory: /home/runner/work/stackstream-fe/stackstream-fe
4Output:
5fatal: remote error: 
6  The unauthenticated git protocol on port 9418 is no longer supported.
7    - name: Installing modules
8      run: yarn install
9

I have looked into this change log but can't seem to comprehend the issue.

Additional Details: Server: EC2 Instance Github actions steps:

1Command: git
2Arguments: ls-remote --tags --heads git://github.com/adobe-webplatform/eve.git
3Directory: /home/runner/work/stackstream-fe/stackstream-fe
4Output:
5fatal: remote error: 
6  The unauthenticated git protocol on port 9418 is no longer supported.
7    - name: Installing modules
8      run: yarn install
9  steps:
10  - name: Checkout
11    uses: actions/checkout@v2
12
13  - id: vars
14    run: |
15      if [ '${{ github.ref }}' == 'refs/heads/master' ]; then echo "::set-output name=environment::prod_stackstream" ; echo "::set-output name=api-url::api" ; elif [ '${{ github.ref }}' == 'refs/heads/staging' ]; then echo "::set-output name=environment::staging_stackstream"  ; echo "::set-output name=api-url::stagingapi" ; else echo "::set-output name=environment::dev_stackstream" ; echo "::set-output name=api-url::devapi" ; fi
16
17  - uses: pCYSl5EDgo/cat@master
18    id: slack
19    with:
20      path: .github/workflows/slack.txt
21
22  - name: Slack Start Notification
23    uses: 8398a7/action-slack@v3
24    env:
25      SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
26      ENVIRONMENT: '`${{ steps.vars.outputs.environment }}`'
27      COLOR: good
28      STATUS: '`Started`'
29    with:
30      status: custom
31      fields: workflow,job,commit,repo,ref,author,took
32      custom_payload: |
33        ${{ steps.slack.outputs.text }}
34
35  - name: Installing modules
36    env:
37      REACT_APP_API_URL: 'https://${{ steps.vars.outputs.api-url }}mergestack.com/api/v1'
38    run: yarn install
39
40  - name: Create Frontend Build
41    env:
42      REACT_APP_API_URL: 'https://${{ steps.vars.outputs.api-url }}mergestack.com/api/v1'
43    run: yarn build
44
45  - name: Deploy to Frontend Server DEV
46    if: ${{ contains(github.ref, 'dev') }}
47    uses: easingthemes/ssh-deploy@v2.1.5
48    env:
49      SSH_PRIVATE_KEY: ${{ secrets.DEV_KEY }}
50      ARGS: '-rltgoDzvO --delete'
51      SOURCE: 'deploy/'
52      REMOTE_HOST: ${{ secrets.DEV_HOST }}
53      REMOTE_USER: plyfolio-dev
54      TARGET: '/home/plyfolio-dev/${{ steps.vars.outputs.environment }}/fe/deploy'
55

package.json file

1Command: git
2Arguments: ls-remote --tags --heads git://github.com/adobe-webplatform/eve.git
3Directory: /home/runner/work/stackstream-fe/stackstream-fe
4Output:
5fatal: remote error: 
6  The unauthenticated git protocol on port 9418 is no longer supported.
7    - name: Installing modules
8      run: yarn install
9  steps:
10  - name: Checkout
11    uses: actions/checkout@v2
12
13  - id: vars
14    run: |
15      if [ '${{ github.ref }}' == 'refs/heads/master' ]; then echo "::set-output name=environment::prod_stackstream" ; echo "::set-output name=api-url::api" ; elif [ '${{ github.ref }}' == 'refs/heads/staging' ]; then echo "::set-output name=environment::staging_stackstream"  ; echo "::set-output name=api-url::stagingapi" ; else echo "::set-output name=environment::dev_stackstream" ; echo "::set-output name=api-url::devapi" ; fi
16
17  - uses: pCYSl5EDgo/cat@master
18    id: slack
19    with:
20      path: .github/workflows/slack.txt
21
22  - name: Slack Start Notification
23    uses: 8398a7/action-slack@v3
24    env:
25      SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
26      ENVIRONMENT: '`${{ steps.vars.outputs.environment }}`'
27      COLOR: good
28      STATUS: '`Started`'
29    with:
30      status: custom
31      fields: workflow,job,commit,repo,ref,author,took
32      custom_payload: |
33        ${{ steps.slack.outputs.text }}
34
35  - name: Installing modules
36    env:
37      REACT_APP_API_URL: 'https://${{ steps.vars.outputs.api-url }}mergestack.com/api/v1'
38    run: yarn install
39
40  - name: Create Frontend Build
41    env:
42      REACT_APP_API_URL: 'https://${{ steps.vars.outputs.api-url }}mergestack.com/api/v1'
43    run: yarn build
44
45  - name: Deploy to Frontend Server DEV
46    if: ${{ contains(github.ref, 'dev') }}
47    uses: easingthemes/ssh-deploy@v2.1.5
48    env:
49      SSH_PRIVATE_KEY: ${{ secrets.DEV_KEY }}
50      ARGS: '-rltgoDzvO --delete'
51      SOURCE: 'deploy/'
52      REMOTE_HOST: ${{ secrets.DEV_HOST }}
53      REMOTE_USER: plyfolio-dev
54      TARGET: '/home/plyfolio-dev/${{ steps.vars.outputs.environment }}/fe/deploy'
55   {
56  "name": "stackstream-fe",
57  "version": "1.0.0",
58  "authors": [
59    "fayyaznofal@gmail.com"
60  ],
61  "private": true,
62  "dependencies": {
63    "@fortawesome/fontawesome-svg-core": "^1.2.34",
64    "@fortawesome/free-solid-svg-icons": "^5.15.2",
65    "@fortawesome/react-fontawesome": "^0.1.14",
66    "@fullcalendar/bootstrap": "^5.5.0",
67    "@fullcalendar/core": "^5.5.0",
68    "@fullcalendar/daygrid": "^5.5.0",
69    "@fullcalendar/interaction": "^5.5.0",
70    "@fullcalendar/react": "^5.5.0",
71    "@lourenci/react-kanban": "^2.1.0",
72    "@redux-saga/simple-saga-monitor": "^1.1.2",
73    "@testing-library/jest-dom": "^5.11.9",
74    "@testing-library/react": "^11.2.3",
75    "@testing-library/user-event": "^12.6.0",
76    "@toast-ui/react-chart": "^1.0.2",
77    "@types/jest": "^26.0.14",
78    "@types/node": "^14.10.3",
79    "@types/react": "^16.9.49",
80    "@types/react-dom": "^16.9.8",
81    "@vtaits/react-color-picker": "^0.1.1",
82    "apexcharts": "^3.23.1",
83    "availity-reactstrap-validation": "^2.7.0",
84    "axios": "^0.21.1",
85    "axios-mock-adapter": "^1.19.0",
86    "axios-progress-bar": "^1.2.0",
87    "bootstrap": "^5.0.0-beta2",
88    "chart.js": "^2.9.4",
89    "chartist": "^0.11.4",
90    "classnames": "^2.2.6",
91    "components": "^0.1.0",
92    "dotenv": "^8.2.0",
93    "draft-js": "^0.11.7",
94    "echarts": "^4.9.0",
95    "echarts-for-react": "^2.0.16",
96    "firebase": "^8.2.3",
97    "google-maps-react": "^2.0.6",
98    "history": "^4.10.1",
99    "i": "^0.3.6",
100    "i18next": "^19.8.4",
101    "i18next-browser-languagedetector": "^6.0.1",
102    "jsonwebtoken": "^8.5.1",
103    "leaflet": "^1.7.1",
104    "lodash": "^4.17.21",
105    "lodash.clonedeep": "^4.5.0",
106    "lodash.get": "^4.4.2",
107    "metismenujs": "^1.2.1",
108    "mkdirp": "^1.0.4",
109    "moment": "2.29.1",
110    "moment-timezone": "^0.5.32",
111    "nouislider-react": "^3.3.9",
112    "npm": "^7.6.3",
113    "prop-types": "^15.7.2",
114    "query-string": "^6.14.0",
115    "react": "^16.13.1",
116    "react-apexcharts": "^1.3.7",
117    "react-auth-code-input": "^1.0.0",
118    "react-avatar": "^3.10.0",
119    "react-bootstrap": "^1.5.0",
120    "react-bootstrap-editable": "^0.8.2",
121    "react-bootstrap-sweetalert": "^5.2.0",
122    "react-bootstrap-table-next": "^4.0.3",
123    "react-bootstrap-table2-editor": "^1.4.0",
124    "react-bootstrap-table2-paginator": "^2.1.2",
125    "react-bootstrap-table2-toolkit": "^2.1.3",
126    "react-chartist": "^0.14.3",
127    "react-chartjs-2": "^2.11.1",
128    "react-color": "^2.19.3",
129    "react-confirm-alert": "^2.7.0",
130    "react-content-loader": "^6.0.1",
131    "react-countdown": "^2.3.1",
132    "react-countup": "^4.3.3",
133    "react-cropper": "^2.1.4",
134    "react-data-table-component": "^6.11.8",
135    "react-date-picker": "^8.0.6",
136    "react-datepicker": "^3.4.1",
137    "react-dom": "^16.13.1",
138    "react-draft-wysiwyg": "^1.14.5",
139    "react-drag-listview": "^0.1.8",
140    "react-drawer": "^1.3.4",
141    "react-dropzone": "^11.2.4",
142    "react-dual-listbox": "^2.0.0",
143    "react-facebook-login": "^4.1.1",
144    "react-flatpickr": "^3.10.6",
145    "react-google-login": "^5.2.2",
146    "react-hook-form": "^7.15.2",
147    "react-i18next": "^11.8.5",
148    "react-icons": "^4.2.0",
149    "react-image-lightbox": "^5.1.1",
150    "react-input-mask": "^2.0.4",
151    "react-jvectormap": "^0.0.16",
152    "react-leaflet": "^3.0.5",
153    "react-meta-tags": "^1.0.1",
154    "react-modal-video": "^1.2.6",
155    "react-notifications": "^1.7.2",
156    "react-number-format": "^4.7.3",
157    "react-perfect-scrollbar": "^1.5.8",
158    "react-rangeslider": "^2.2.0",
159    "react-rating": "^2.0.5",
160    "react-rating-tooltip": "^1.1.6",
161    "react-redux": "^7.2.1",
162    "react-responsive-carousel": "^3.2.11",
163    "react-router-dom": "^5.2.0",
164    "react-script": "^2.0.5",
165    "react-scripts": "3.4.3",
166    "react-select": "^4.3.1",
167    "react-sparklines": "^1.7.0",
168    "react-star-ratings": "^2.3.0",
169    "react-super-responsive-table": "^5.2.0",
170    "react-switch": "^6.0.0",
171    "react-table": "^7.6.3",
172    "react-toastify": "^7.0.3",
173    "react-toastr": "^3.0.0",
174    "react-twitter-auth": "0.0.13",
175    "reactstrap": "^8.8.1",
176    "recharts": "^2.0.8",
177    "redux": "^4.0.5",
178    "redux-saga": "^1.1.3",
179    "reselect": "^4.0.0",
180    "sass": "^1.37.5",
181    "simplebar-react": "^2.3.0",
182    "styled": "^1.0.0",
183    "styled-components": "^5.2.1",
184    "toastr": "^2.1.4",
185    "typescript": "^4.0.2",
186    "universal-cookie": "^4.0.4"
187  },
188  "devDependencies": {
189    "@typescript-eslint/eslint-plugin": "^2.27.0",
190    "@typescript-eslint/parser": "^2.27.0",
191    "@typescript-eslint/typescript-estree": "^4.15.2",
192    "eslint-config-prettier": "^6.10.1",
193    "eslint-plugin-prettier": "^3.1.2",
194    "husky": "^4.2.5",
195    "lint-staged": "^10.1.3",
196    "prettier": "^1.19.1",
197    "react-test-renderer": "^16.13.1",
198    "redux-devtools-extension": "^2.13.8",
199    "redux-mock-store": "^1.5.4"
200  },
201  "scripts": {
202    "start": "react-scripts start",
203    "build": "react-scripts build && mv build ./deploy/build",
204    "build-local": "react-scripts build",
205    "test": "react-scripts test",
206    "eject": "react-scripts eject"
207  },
208  "eslintConfig": {
209    "extends": "react-app"
210  },
211  "husky": {
212    "hooks": {
213      "pre-commit": "lint-staged"
214    }
215  },
216  "lint-staged": {
217    "*.{js,ts,tsx}": [
218      "eslint --fix"
219    ]
220  },
221  "browserslist": {
222    "production": [
223      ">0.2%",
224      "not dead",
225      "not op_mini all"
226    ],
227    "development": [
228      "last 1 chrome version",
229      "last 1 firefox version",
230      "last 1 safari version"
231    ]
232  }
233}
234

ANSWER

Answered 2022-Mar-16 at 07:01

First, this error message is indeed expected on Jan. 11th, 2022.
See "Improving Git protocol security on GitHub".

January 11, 2022 Final brownout.

This is the full brownout period where we’ll temporarily stop accepting the deprecated key and signature types, ciphers, and MACs, and the unencrypted Git protocol.
This will help clients discover any lingering use of older keys or old URLs.

Second, check your package.json dependencies for any git:// URL, as in this example, fixed in this PR.

As noted by Jörg W Mittag:

There was a 4-month warning.
The entire Internet has been moving away from unauthenticated, unencrypted protocols for a decade, it's not like this is a huge surprise.

Personally, I consider it less an "issue" and more "detecting unmaintained dependencies".

Plus, this is still only the brownout period, so the protocol will only be disabled for a short period of time, allowing developers to discover the problem.

The permanent shutdown is not until March 15th.


For GitHub Actions:

As in actions/checkout issue 14, you can add as a first step:

1Command: git
2Arguments: ls-remote --tags --heads git://github.com/adobe-webplatform/eve.git
3Directory: /home/runner/work/stackstream-fe/stackstream-fe
4Output:
5fatal: remote error: 
6  The unauthenticated git protocol on port 9418 is no longer supported.
7    - name: Installing modules
8      run: yarn install
9  steps:
10  - name: Checkout
11    uses: actions/checkout@v2
12
13  - id: vars
14    run: |
15      if [ '${{ github.ref }}' == 'refs/heads/master' ]; then echo "::set-output name=environment::prod_stackstream" ; echo "::set-output name=api-url::api" ; elif [ '${{ github.ref }}' == 'refs/heads/staging' ]; then echo "::set-output name=environment::staging_stackstream"  ; echo "::set-output name=api-url::stagingapi" ; else echo "::set-output name=environment::dev_stackstream" ; echo "::set-output name=api-url::devapi" ; fi
16
17  - uses: pCYSl5EDgo/cat@master
18    id: slack
19    with:
20      path: .github/workflows/slack.txt
21
22  - name: Slack Start Notification
23    uses: 8398a7/action-slack@v3
24    env:
25      SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
26      ENVIRONMENT: '`${{ steps.vars.outputs.environment }}`'
27      COLOR: good
28      STATUS: '`Started`'
29    with:
30      status: custom
31      fields: workflow,job,commit,repo,ref,author,took
32      custom_payload: |
33        ${{ steps.slack.outputs.text }}
34
35  - name: Installing modules
36    env:
37      REACT_APP_API_URL: 'https://${{ steps.vars.outputs.api-url }}mergestack.com/api/v1'
38    run: yarn install
39
40  - name: Create Frontend Build
41    env:
42      REACT_APP_API_URL: 'https://${{ steps.vars.outputs.api-url }}mergestack.com/api/v1'
43    run: yarn build
44
45  - name: Deploy to Frontend Server DEV
46    if: ${{ contains(github.ref, 'dev') }}
47    uses: easingthemes/ssh-deploy@v2.1.5
48    env:
49      SSH_PRIVATE_KEY: ${{ secrets.DEV_KEY }}
50      ARGS: '-rltgoDzvO --delete'
51      SOURCE: 'deploy/'
52      REMOTE_HOST: ${{ secrets.DEV_HOST }}
53      REMOTE_USER: plyfolio-dev
54      TARGET: '/home/plyfolio-dev/${{ steps.vars.outputs.environment }}/fe/deploy'
55   {
56  "name": "stackstream-fe",
57  "version": "1.0.0",
58  "authors": [
59    "fayyaznofal@gmail.com"
60  ],
61  "private": true,
62  "dependencies": {
63    "@fortawesome/fontawesome-svg-core": "^1.2.34",
64    "@fortawesome/free-solid-svg-icons": "^5.15.2",
65    "@fortawesome/react-fontawesome": "^0.1.14",
66    "@fullcalendar/bootstrap": "^5.5.0",
67    "@fullcalendar/core": "^5.5.0",
68    "@fullcalendar/daygrid": "^5.5.0",
69    "@fullcalendar/interaction": "^5.5.0",
70    "@fullcalendar/react": "^5.5.0",
71    "@lourenci/react-kanban": "^2.1.0",
72    "@redux-saga/simple-saga-monitor": "^1.1.2",
73    "@testing-library/jest-dom": "^5.11.9",
74    "@testing-library/react": "^11.2.3",
75    "@testing-library/user-event": "^12.6.0",
76    "@toast-ui/react-chart": "^1.0.2",
77    "@types/jest": "^26.0.14",
78    "@types/node": "^14.10.3",
79    "@types/react": "^16.9.49",
80    "@types/react-dom": "^16.9.8",
81    "@vtaits/react-color-picker": "^0.1.1",
82    "apexcharts": "^3.23.1",
83    "availity-reactstrap-validation": "^2.7.0",
84    "axios": "^0.21.1",
85    "axios-mock-adapter": "^1.19.0",
86    "axios-progress-bar": "^1.2.0",
87    "bootstrap": "^5.0.0-beta2",
88    "chart.js": "^2.9.4",
89    "chartist": "^0.11.4",
90    "classnames": "^2.2.6",
91    "components": "^0.1.0",
92    "dotenv": "^8.2.0",
93    "draft-js": "^0.11.7",
94    "echarts": "^4.9.0",
95    "echarts-for-react": "^2.0.16",
96    "firebase": "^8.2.3",
97    "google-maps-react": "^2.0.6",
98    "history": "^4.10.1",
99    "i": "^0.3.6",
100    "i18next": "^19.8.4",
101    "i18next-browser-languagedetector": "^6.0.1",
102    "jsonwebtoken": "^8.5.1",
103    "leaflet": "^1.7.1",
104    "lodash": "^4.17.21",
105    "lodash.clonedeep": "^4.5.0",
106    "lodash.get": "^4.4.2",
107    "metismenujs": "^1.2.1",
108    "mkdirp": "^1.0.4",
109    "moment": "2.29.1",
110    "moment-timezone": "^0.5.32",
111    "nouislider-react": "^3.3.9",
112    "npm": "^7.6.3",
113    "prop-types": "^15.7.2",
114    "query-string": "^6.14.0",
115    "react": "^16.13.1",
116    "react-apexcharts": "^1.3.7",
117    "react-auth-code-input": "^1.0.0",
118    "react-avatar": "^3.10.0",
119    "react-bootstrap": "^1.5.0",
120    "react-bootstrap-editable": "^0.8.2",
121    "react-bootstrap-sweetalert": "^5.2.0",
122    "react-bootstrap-table-next": "^4.0.3",
123    "react-bootstrap-table2-editor": "^1.4.0",
124    "react-bootstrap-table2-paginator": "^2.1.2",
125    "react-bootstrap-table2-toolkit": "^2.1.3",
126    "react-chartist": "^0.14.3",
127    "react-chartjs-2": "^2.11.1",
128    "react-color": "^2.19.3",
129    "react-confirm-alert": "^2.7.0",
130    "react-content-loader": "^6.0.1",
131    "react-countdown": "^2.3.1",
132    "react-countup": "^4.3.3",
133    "react-cropper": "^2.1.4",
134    "react-data-table-component": "^6.11.8",
135    "react-date-picker": "^8.0.6",
136    "react-datepicker": "^3.4.1",
137    "react-dom": "^16.13.1",
138    "react-draft-wysiwyg": "^1.14.5",
139    "react-drag-listview": "^0.1.8",
140    "react-drawer": "^1.3.4",
141    "react-dropzone": "^11.2.4",
142    "react-dual-listbox": "^2.0.0",
143    "react-facebook-login": "^4.1.1",
144    "react-flatpickr": "^3.10.6",
145    "react-google-login": "^5.2.2",
146    "react-hook-form": "^7.15.2",
147    "react-i18next": "^11.8.5",
148    "react-icons": "^4.2.0",
149    "react-image-lightbox": "^5.1.1",
150    "react-input-mask": "^2.0.4",
151    "react-jvectormap": "^0.0.16",
152    "react-leaflet": "^3.0.5",
153    "react-meta-tags": "^1.0.1",
154    "react-modal-video": "^1.2.6",
155    "react-notifications": "^1.7.2",
156    "react-number-format": "^4.7.3",
157    "react-perfect-scrollbar": "^1.5.8",
158    "react-rangeslider": "^2.2.0",
159    "react-rating": "^2.0.5",
160    "react-rating-tooltip": "^1.1.6",
161    "react-redux": "^7.2.1",
162    "react-responsive-carousel": "^3.2.11",
163    "react-router-dom": "^5.2.0",
164    "react-script": "^2.0.5",
165    "react-scripts": "3.4.3",
166    "react-select": "^4.3.1",
167    "react-sparklines": "^1.7.0",
168    "react-star-ratings": "^2.3.0",
169    "react-super-responsive-table": "^5.2.0",
170    "react-switch": "^6.0.0",
171    "react-table": "^7.6.3",
172    "react-toastify": "^7.0.3",
173    "react-toastr": "^3.0.0",
174    "react-twitter-auth": "0.0.13",
175    "reactstrap": "^8.8.1",
176    "recharts": "^2.0.8",
177    "redux": "^4.0.5",
178    "redux-saga": "^1.1.3",
179    "reselect": "^4.0.0",
180    "sass": "^1.37.5",
181    "simplebar-react": "^2.3.0",
182    "styled": "^1.0.0",
183    "styled-components": "^5.2.1",
184    "toastr": "^2.1.4",
185    "typescript": "^4.0.2",
186    "universal-cookie": "^4.0.4"
187  },
188  "devDependencies": {
189    "@typescript-eslint/eslint-plugin": "^2.27.0",
190    "@typescript-eslint/parser": "^2.27.0",
191    "@typescript-eslint/typescript-estree": "^4.15.2",
192    "eslint-config-prettier": "^6.10.1",
193    "eslint-plugin-prettier": "^3.1.2",
194    "husky": "^4.2.5",
195    "lint-staged": "^10.1.3",
196    "prettier": "^1.19.1",
197    "react-test-renderer": "^16.13.1",
198    "redux-devtools-extension": "^2.13.8",
199    "redux-mock-store": "^1.5.4"
200  },
201  "scripts": {
202    "start": "react-scripts start",
203    "build": "react-scripts build && mv build ./deploy/build",
204    "build-local": "react-scripts build",
205    "test": "react-scripts test",
206    "eject": "react-scripts eject"
207  },
208  "eslintConfig": {
209    "extends": "react-app"
210  },
211  "husky": {
212    "hooks": {
213      "pre-commit": "lint-staged"
214    }
215  },
216  "lint-staged": {
217    "*.{js,ts,tsx}": [
218      "eslint --fix"
219    ]
220  },
221  "browserslist": {
222    "production": [
223      ">0.2%",
224      "not dead",
225      "not op_mini all"
226    ],
227    "development": [
228      "last 1 chrome version",
229      "last 1 firefox version",
230      "last 1 safari version"
231    ]
232  }
233}
234    - name: Fix up git URLs
235      run: echo -e '[url "https://github.com/"]\n  insteadOf = "git://github.com/"' >> ~/.gitconfig
236

That will change any git://github.com/ into https://github.com/.

For local projects

For all your repositories, you can set:

1Command: git
2Arguments: ls-remote --tags --heads git://github.com/adobe-webplatform/eve.git
3Directory: /home/runner/work/stackstream-fe/stackstream-fe
4Output:
5fatal: remote error: 
6  The unauthenticated git protocol on port 9418 is no longer supported.
7    - name: Installing modules
8      run: yarn install
9  steps:
10  - name: Checkout
11    uses: actions/checkout@v2
12
13  - id: vars
14    run: |
15      if [ '${{ github.ref }}' == 'refs/heads/master' ]; then echo "::set-output name=environment::prod_stackstream" ; echo "::set-output name=api-url::api" ; elif [ '${{ github.ref }}' == 'refs/heads/staging' ]; then echo "::set-output name=environment::staging_stackstream"  ; echo "::set-output name=api-url::stagingapi" ; else echo "::set-output name=environment::dev_stackstream" ; echo "::set-output name=api-url::devapi" ; fi
16
17  - uses: pCYSl5EDgo/cat@master
18    id: slack
19    with:
20      path: .github/workflows/slack.txt
21
22  - name: Slack Start Notification
23    uses: 8398a7/action-slack@v3
24    env:
25      SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
26      ENVIRONMENT: '`${{ steps.vars.outputs.environment }}`'
27      COLOR: good
28      STATUS: '`Started`'
29    with:
30      status: custom
31      fields: workflow,job,commit,repo,ref,author,took
32      custom_payload: |
33        ${{ steps.slack.outputs.text }}
34
35  - name: Installing modules
36    env:
37      REACT_APP_API_URL: 'https://${{ steps.vars.outputs.api-url }}mergestack.com/api/v1'
38    run: yarn install
39
40  - name: Create Frontend Build
41    env:
42      REACT_APP_API_URL: 'https://${{ steps.vars.outputs.api-url }}mergestack.com/api/v1'
43    run: yarn build
44
45  - name: Deploy to Frontend Server DEV
46    if: ${{ contains(github.ref, 'dev') }}
47    uses: easingthemes/ssh-deploy@v2.1.5
48    env:
49      SSH_PRIVATE_KEY: ${{ secrets.DEV_KEY }}
50      ARGS: '-rltgoDzvO --delete'
51      SOURCE: 'deploy/'
52      REMOTE_HOST: ${{ secrets.DEV_HOST }}
53      REMOTE_USER: plyfolio-dev
54      TARGET: '/home/plyfolio-dev/${{ steps.vars.outputs.environment }}/fe/deploy'
55   {
56  "name": "stackstream-fe",
57  "version": "1.0.0",
58  "authors": [
59    "fayyaznofal@gmail.com"
60  ],
61  "private": true,
62  "dependencies": {
63    "@fortawesome/fontawesome-svg-core": "^1.2.34",
64    "@fortawesome/free-solid-svg-icons": "^5.15.2",
65    "@fortawesome/react-fontawesome": "^0.1.14",
66    "@fullcalendar/bootstrap": "^5.5.0",
67    "@fullcalendar/core": "^5.5.0",
68    "@fullcalendar/daygrid": "^5.5.0",
69    "@fullcalendar/interaction": "^5.5.0",
70    "@fullcalendar/react": "^5.5.0",
71    "@lourenci/react-kanban": "^2.1.0",
72    "@redux-saga/simple-saga-monitor": "^1.1.2",
73    "@testing-library/jest-dom": "^5.11.9",
74    "@testing-library/react": "^11.2.3",
75    "@testing-library/user-event": "^12.6.0",
76    "@toast-ui/react-chart": "^1.0.2",
77    "@types/jest": "^26.0.14",
78    "@types/node": "^14.10.3",
79    "@types/react": "^16.9.49",
80    "@types/react-dom": "^16.9.8",
81    "@vtaits/react-color-picker": "^0.1.1",
82    "apexcharts": "^3.23.1",
83    "availity-reactstrap-validation": "^2.7.0",
84    "axios": "^0.21.1",
85    "axios-mock-adapter": "^1.19.0",
86    "axios-progress-bar": "^1.2.0",
87    "bootstrap": "^5.0.0-beta2",
88    "chart.js": "^2.9.4",
89    "chartist": "^0.11.4",
90    "classnames": "^2.2.6",
91    "components": "^0.1.0",
92    "dotenv": "^8.2.0",
93    "draft-js": "^0.11.7",
94    "echarts": "^4.9.0",
95    "echarts-for-react": "^2.0.16",
96    "firebase": "^8.2.3",
97    "google-maps-react": "^2.0.6",
98    "history": "^4.10.1",
99    "i": "^0.3.6",
100    "i18next": "^19.8.4",
101    "i18next-browser-languagedetector": "^6.0.1",
102    "jsonwebtoken": "^8.5.1",
103    "leaflet": "^1.7.1",
104    "lodash": "^4.17.21",
105    "lodash.clonedeep": "^4.5.0",
106    "lodash.get": "^4.4.2",
107    "metismenujs": "^1.2.1",
108    "mkdirp": "^1.0.4",
109    "moment": "2.29.1",
110    "moment-timezone": "^0.5.32",
111    "nouislider-react": "^3.3.9",
112    "npm": "^7.6.3",
113    "prop-types": "^15.7.2",
114    "query-string": "^6.14.0",
115    "react": "^16.13.1",
116    "react-apexcharts": "^1.3.7",
117    "react-auth-code-input": "^1.0.0",
118    "react-avatar": "^3.10.0",
119    "react-bootstrap": "^1.5.0",
120    "react-bootstrap-editable": "^0.8.2",
121    "react-bootstrap-sweetalert": "^5.2.0",
122    "react-bootstrap-table-next": "^4.0.3",
123    "react-bootstrap-table2-editor": "^1.4.0",
124    "react-bootstrap-table2-paginator": "^2.1.2",
125    "react-bootstrap-table2-toolkit": "^2.1.3",
126    "react-chartist": "^0.14.3",
127    "react-chartjs-2": "^2.11.1",
128    "react-color": "^2.19.3",
129    "react-confirm-alert": "^2.7.0",
130    "react-content-loader": "^6.0.1",
131    "react-countdown": "^2.3.1",
132    "react-countup": "^4.3.3",
133    "react-cropper": "^2.1.4",
134    "react-data-table-component": "^6.11.8",
135    "react-date-picker": "^8.0.6",
136    "react-datepicker": "^3.4.1",
137    "react-dom": "^16.13.1",
138    "react-draft-wysiwyg": "^1.14.5",
139    "react-drag-listview": "^0.1.8",
140    "react-drawer": "^1.3.4",
141    "react-dropzone": "^11.2.4",
142    "react-dual-listbox": "^2.0.0",
143    "react-facebook-login": "^4.1.1",
144    "react-flatpickr": "^3.10.6",
145    "react-google-login": "^5.2.2",
146    "react-hook-form": "^7.15.2",
147    "react-i18next": "^11.8.5",
148    "react-icons": "^4.2.0",
149    "react-image-lightbox": "^5.1.1",
150    "react-input-mask": "^2.0.4",
151    "react-jvectormap": "^0.0.16",
152    "react-leaflet": "^3.0.5",
153    "react-meta-tags": "^1.0.1",
154    "react-modal-video": "^1.2.6",
155    "react-notifications": "^1.7.2",
156    "react-number-format": "^4.7.3",
157    "react-perfect-scrollbar": "^1.5.8",
158    "react-rangeslider": "^2.2.0",
159    "react-rating": "^2.0.5",
160    "react-rating-tooltip": "^1.1.6",
161    "react-redux": "^7.2.1",
162    "react-responsive-carousel": "^3.2.11",
163    "react-router-dom": "^5.2.0",
164    "react-script": "^2.0.5",
165    "react-scripts": "3.4.3",
166    "react-select": "^4.3.1",
167    "react-sparklines": "^1.7.0",
168    "react-star-ratings": "^2.3.0",
169    "react-super-responsive-table": "^5.2.0",
170    "react-switch": "^6.0.0",
171    "react-table": "^7.6.3",
172    "react-toastify": "^7.0.3",
173    "react-toastr": "^3.0.0",
174    "react-twitter-auth": "0.0.13",
175    "reactstrap": "^8.8.1",
176    "recharts": "^2.0.8",
177    "redux": "^4.0.5",
178    "redux-saga": "^1.1.3",
179    "reselect": "^4.0.0",
180    "sass": "^1.37.5",
181    "simplebar-react": "^2.3.0",
182    "styled": "^1.0.0",
183    "styled-components": "^5.2.1",
184    "toastr": "^2.1.4",
185    "typescript": "^4.0.2",
186    "universal-cookie": "^4.0.4"
187  },
188  "devDependencies": {
189    "@typescript-eslint/eslint-plugin": "^2.27.0",
190    "@typescript-eslint/parser": "^2.27.0",
191    "@typescript-eslint/typescript-estree": "^4.15.2",
192    "eslint-config-prettier": "^6.10.1",
193    "eslint-plugin-prettier": "^3.1.2",
194    "husky": "^4.2.5",
195    "lint-staged": "^10.1.3",
196    "prettier": "^1.19.1",
197    "react-test-renderer": "^16.13.1",
198    "redux-devtools-extension": "^2.13.8",
199    "redux-mock-store": "^1.5.4"
200  },
201  "scripts": {
202    "start": "react-scripts start",
203    "build": "react-scripts build && mv build ./deploy/build",
204    "build-local": "react-scripts build",
205    "test": "react-scripts test",
206    "eject": "react-scripts eject"
207  },
208  "eslintConfig": {
209    "extends": "react-app"
210  },
211  "husky": {
212    "hooks": {
213      "pre-commit": "lint-staged"
214    }
215  },
216  "lint-staged": {
217    "*.{js,ts,tsx}": [
218      "eslint --fix"
219    ]
220  },
221  "browserslist": {
222    "production": [
223      ">0.2%",
224      "not dead",
225      "not op_mini all"
226    ],
227    "development": [
228      "last 1 chrome version",
229      "last 1 firefox version",
230      "last 1 safari version"
231    ]
232  }
233}
234    - name: Fix up git URLs
235      run: echo -e '[url "https://github.com/"]\n  insteadOf = "git://github.com/"' >> ~/.gitconfig
236git config --global url."https://github.com/".insteadOf git://github.com/
237

You can also use SSH, but GitHub Security reminds us that, as of March 15th, 2022, GitHub stopped accepting DSA keys. RSA keys uploaded after Nov 2, 2021 will work only with SHA-2 signatures.
The deprecated MACs, ciphers, and unencrypted Git protocol are permanently disabled.

So this (with the right key) would work:

1Command: git
2Arguments: ls-remote --tags --heads git://github.com/adobe-webplatform/eve.git
3Directory: /home/runner/work/stackstream-fe/stackstream-fe
4Output:
5fatal: remote error: 
6  The unauthenticated git protocol on port 9418 is no longer supported.
7    - name: Installing modules
8      run: yarn install
9  steps:
10  - name: Checkout
11    uses: actions/checkout@v2
12
13  - id: vars
14    run: |
15      if [ '${{ github.ref }}' == 'refs/heads/master' ]; then echo "::set-output name=environment::prod_stackstream" ; echo "::set-output name=api-url::api" ; elif [ '${{ github.ref }}' == 'refs/heads/staging' ]; then echo "::set-output name=environment::staging_stackstream"  ; echo "::set-output name=api-url::stagingapi" ; else echo "::set-output name=environment::dev_stackstream" ; echo "::set-output name=api-url::devapi" ; fi
16
17  - uses: pCYSl5EDgo/cat@master
18    id: slack
19    with:
20      path: .github/workflows/slack.txt
21
22  - name: Slack Start Notification
23    uses: 8398a7/action-slack@v3
24    env:
25      SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
26      ENVIRONMENT: '`${{ steps.vars.outputs.environment }}`'
27      COLOR: good
28      STATUS: '`Started`'
29    with:
30      status: custom
31      fields: workflow,job,commit,repo,ref,author,took
32      custom_payload: |
33        ${{ steps.slack.outputs.text }}
34
35  - name: Installing modules
36    env:
37      REACT_APP_API_URL: 'https://${{ steps.vars.outputs.api-url }}mergestack.com/api/v1'
38    run: yarn install
39
40  - name: Create Frontend Build
41    env:
42      REACT_APP_API_URL: 'https://${{ steps.vars.outputs.api-url }}mergestack.com/api/v1'
43    run: yarn build
44
45  - name: Deploy to Frontend Server DEV
46    if: ${{ contains(github.ref, 'dev') }}
47    uses: easingthemes/ssh-deploy@v2.1.5
48    env:
49      SSH_PRIVATE_KEY: ${{ secrets.DEV_KEY }}
50      ARGS: '-rltgoDzvO --delete'
51      SOURCE: 'deploy/'
52      REMOTE_HOST: ${{ secrets.DEV_HOST }}
53      REMOTE_USER: plyfolio-dev
54      TARGET: '/home/plyfolio-dev/${{ steps.vars.outputs.environment }}/fe/deploy'
55   {
56  "name": "stackstream-fe",
57  "version": "1.0.0",
58  "authors": [
59    "fayyaznofal@gmail.com"
60  ],
61  "private": true,
62  "dependencies": {
63    "@fortawesome/fontawesome-svg-core": "^1.2.34",
64    "@fortawesome/free-solid-svg-icons": "^5.15.2",
65    "@fortawesome/react-fontawesome": "^0.1.14",
66    "@fullcalendar/bootstrap": "^5.5.0",
67    "@fullcalendar/core": "^5.5.0",
68    "@fullcalendar/daygrid": "^5.5.0",
69    "@fullcalendar/interaction": "^5.5.0",
70    "@fullcalendar/react": "^5.5.0",
71    "@lourenci/react-kanban": "^2.1.0",
72    "@redux-saga/simple-saga-monitor": "^1.1.2",
73    "@testing-library/jest-dom": "^5.11.9",
74    "@testing-library/react": "^11.2.3",
75    "@testing-library/user-event": "^12.6.0",
76    "@toast-ui/react-chart": "^1.0.2",
77    "@types/jest": "^26.0.14",
78    "@types/node": "^14.10.3",
79    "@types/react": "^16.9.49",
80    "@types/react-dom": "^16.9.8",
81    "@vtaits/react-color-picker": "^0.1.1",
82    "apexcharts": "^3.23.1",
83    "availity-reactstrap-validation": "^2.7.0",
84    "axios": "^0.21.1",
85    "axios-mock-adapter": "^1.19.0",
86    "axios-progress-bar": "^1.2.0",
87    "bootstrap": "^5.0.0-beta2",
88    "chart.js": "^2.9.4",
89    "chartist": "^0.11.4",
90    "classnames": "^2.2.6",
91    "components": "^0.1.0",
92    "dotenv": "^8.2.0",
93    "draft-js": "^0.11.7",
94    "echarts": "^4.9.0",
95    "echarts-for-react": "^2.0.16",
96    "firebase": "^8.2.3",
97    "google-maps-react": "^2.0.6",
98    "history": "^4.10.1",
99    "i": "^0.3.6",
100    "i18next": "^19.8.4",
101    "i18next-browser-languagedetector": "^6.0.1",
102    "jsonwebtoken": "^8.5.1",
103    "leaflet": "^1.7.1",
104    "lodash": "^4.17.21",
105    "lodash.clonedeep": "^4.5.0",
106    "lodash.get": "^4.4.2",
107    "metismenujs": "^1.2.1",
108    "mkdirp": "^1.0.4",
109    "moment": "2.29.1",
110    "moment-timezone": "^0.5.32",
111    "nouislider-react": "^3.3.9",
112    "npm": "^7.6.3",
113    "prop-types": "^15.7.2",
114    "query-string": "^6.14.0",
115    "react": "^16.13.1",
116    "react-apexcharts": "^1.3.7",
117    "react-auth-code-input": "^1.0.0",
118    "react-avatar": "^3.10.0",
119    "react-bootstrap": "^1.5.0",
120    "react-bootstrap-editable": "^0.8.2",
121    "react-bootstrap-sweetalert": "^5.2.0",
122    "react-bootstrap-table-next": "^4.0.3",
123    "react-bootstrap-table2-editor": "^1.4.0",
124    "react-bootstrap-table2-paginator": "^2.1.2",
125    "react-bootstrap-table2-toolkit": "^2.1.3",
126    "react-chartist": "^0.14.3",
127    "react-chartjs-2": "^2.11.1",
128    "react-color": "^2.19.3",
129    "react-confirm-alert": "^2.7.0",
130    "react-content-loader": "^6.0.1",
131    "react-countdown": "^2.3.1",
132    "react-countup": "^4.3.3",
133    "react-cropper": "^2.1.4",
134    "react-data-table-component": "^6.11.8",
135    "react-date-picker": "^8.0.6",
136    "react-datepicker": "^3.4.1",
137    "react-dom": "^16.13.1",
138    "react-draft-wysiwyg": "^1.14.5",
139    "react-drag-listview": "^0.1.8",
140    "react-drawer": "^1.3.4",
141    "react-dropzone": "^11.2.4",
142    "react-dual-listbox": "^2.0.0",
143    "react-facebook-login": "^4.1.1",
144    "react-flatpickr": "^3.10.6",
145    "react-google-login": "^5.2.2",
146    "react-hook-form": "^7.15.2",
147    "react-i18next": "^11.8.5",
148    "react-icons": "^4.2.0",
149    "react-image-lightbox": "^5.1.1",
150    "react-input-mask": "^2.0.4",
151    "react-jvectormap": "^0.0.16",
152    "react-leaflet": "^3.0.5",
153    "react-meta-tags": "^1.0.1",
154    "react-modal-video": "^1.2.6",
155    "react-notifications": "^1.7.2",
156    "react-number-format": "^4.7.3",
157    "react-perfect-scrollbar": "^1.5.8",
158    "react-rangeslider": "^2.2.0",
159    "react-rating": "^2.0.5",
160    "react-rating-tooltip": "^1.1.6",
161    "react-redux": "^7.2.1",
162    "react-responsive-carousel": "^3.2.11",
163    "react-router-dom": "^5.2.0",
164    "react-script": "^2.0.5",
165    "react-scripts": "3.4.3",
166    "react-select": "^4.3.1",
167    "react-sparklines": "^1.7.0",
168    "react-star-ratings": "^2.3.0",
169    "react-super-responsive-table": "^5.2.0",
170    "react-switch": "^6.0.0",
171    "react-table": "^7.6.3",
172    "react-toastify": "^7.0.3",
173    "react-toastr": "^3.0.0",
174    "react-twitter-auth": "0.0.13",
175    "reactstrap": "^8.8.1",
176    "recharts": "^2.0.8",
177    "redux": "^4.0.5",
178    "redux-saga": "^1.1.3",
179    "reselect": "^4.0.0",
180    "sass": "^1.37.5",
181    "simplebar-react": "^2.3.0",
182    "styled": "^1.0.0",
183    "styled-components": "^5.2.1",
184    "toastr": "^2.1.4",
185    "typescript": "^4.0.2",
186    "universal-cookie": "^4.0.4"
187  },
188  "devDependencies": {
189    "@typescript-eslint/eslint-plugin": "^2.27.0",
190    "@typescript-eslint/parser": "^2.27.0",
191    "@typescript-eslint/typescript-estree": "^4.15.2",
192    "eslint-config-prettier": "^6.10.1",
193    "eslint-plugin-prettier": "^3.1.2",
194    "husky": "^4.2.5",
195    "lint-staged": "^10.1.3",
196    "prettier": "^1.19.1",
197    "react-test-renderer": "^16.13.1",
198    "redux-devtools-extension": "^2.13.8",
199    "redux-mock-store": "^1.5.4"
200  },
201  "scripts": {
202    "start": "react-scripts start",
203    "build": "react-scripts build && mv build ./deploy/build",
204    "build-local": "react-scripts build",
205    "test": "react-scripts test",
206    "eject": "react-scripts eject"
207  },
208  "eslintConfig": {
209    "extends": "react-app"
210  },
211  "husky": {
212    "hooks": {
213      "pre-commit": "lint-staged"
214    }
215  },
216  "lint-staged": {
217    "*.{js,ts,tsx}": [
218      "eslint --fix"
219    ]
220  },
221  "browserslist": {
222    "production": [
223      ">0.2%",
224      "not dead",
225      "not op_mini all"
226    ],
227    "development": [
228      "last 1 chrome version",
229      "last 1 firefox version",
230      "last 1 safari version"
231    ]
232  }
233}
234    - name: Fix up git URLs
235      run: echo -e '[url "https://github.com/"]\n  insteadOf = "git://github.com/"' >> ~/.gitconfig
236git config --global url."https://github.com/".insteadOf git://github.com/
237git config --global url."git@github.com:".insteadOf git://github.com/
238

That will change any git://github.com/ (unencrypted Git protocol) into git@github.com: (SSH URL).

Source https://stackoverflow.com/questions/70663523

QUESTION

npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher

Asked 2022-Mar-22 at 09:17

I am getting this warning from github on my npm project build process... I tried searching on the internet and also read the blog link posted by github - but I could not find the solution to it anywhere. Am I missing something ?

Warning seen

npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/

ANSWER

Answered 2021-Sep-10 at 15:18

Besides updating your version of node to an active or current LTS you want to ensure your NPM registry is set to an HTTPS endpoint:

1registry=https://registry.npmjs.org/
2

Source https://stackoverflow.com/questions/69044064

QUESTION

Efficient overflow-immune arithmetic mean in C/C++

Asked 2022-Mar-10 at 14:02

The arithmetic mean of two unsigned integers is defined as:

1mean = (a+b)/2
2

Directly implementing this in C/C++ may overflow and produce a wrong result. A correct implementation would avoid this. One way of coding it could be:

1mean = (a+b)/2
2mean = a/2 + b/2 + (a%2 + b%2)/2
3

But this produces rather a lot of code with typical compilers. In assembler, this usually can be done much more efficiently. For example, the x86 can do this in the following way (assembler pseudo code, I hope you get the point):

1mean = (a+b)/2
2mean = a/2 + b/2 + (a%2 + b%2)/2
3ADD a,b   ; addition, leaving the overflow condition in the carry bit
4RCR a,1   ; rotate right through carry, effectively a division by 2
5

After those two instructions, the result is in a, and the remainder of the division is in the carry bit. If correct rounding is desired, a third ADC instruction would have to add the carry into the result.

Note that the RCR instruction is used, which rotates a register through the carry. In our case, it is a rotate by one position, so that the previous carry becomes the most significant bit in the register, and the new carry holds the previous LSB from the register. It seems that MSVC doesn't even offer an intrinsic for this instruction.

Is there a known C/C++ pattern that can be expected to be recognized by an optimizing compiler so that it produces such efficient code? Or, more generally, is there a rational way how to program in C/C++ source level so that the carry bit is being used by the compiler to optimize the generated code?

EDIT:

A 1-hour lecture about std::midpoint: https://www.youtube.com/watch?v=sBtAGxBh-XI

Wow!

EDIT2: Great discussion on Microsoft blog

ANSWER

Answered 2022-Mar-08 at 10:54

The following method avoids overflow and should result in fairly efficient assembly (example) without depending on non-standard features:

1mean = (a+b)/2
2mean = a/2 + b/2 + (a%2 + b%2)/2
3ADD a,b   ; addition, leaving the overflow condition in the carry bit
4RCR a,1   ; rotate right through carry, effectively a division by 2
5    mean = (a&b) + (a^b)/2;
6

Source https://stackoverflow.com/questions/71019078

QUESTION

Error: Must use import to load ES Module: D:\node_modules\react-markdown\index.js require() of ES modules is not supported

Asked 2022-Feb-13 at 06:31

Currently I'm using "react": "17.0.2" and I have installed "react-markdown": "^7.0.1" via npm i react-markdown I'm using this package to display my rich text that I'm fetching from my Strapi CMS. I have used the following code to display the content:

1import ReactMarkdown from "react-markdown";
2
3export default function name({ posts }) {
4  return (
5    <>
6      <div>
7        <div>
8          {posts.Title}
9        </div>
10      </div>
11      <div>
12        <ReactMarkdown source={posts.Content} escapeHtml={false} />
13      </div>
14    </>
15  );
16}
17
18export async function getStaticProps() {
19  const res = await fetch("http://localhost:1337/blogs");
20  const posts = await res.json();
21
22  return {
23    props: { posts },
24  };
25}
26

But when I run this it gives me the following error:

enter image description here

I'm using node v14.17.0 and have tried adding "type": "module".

My package.json:

1import ReactMarkdown from "react-markdown";
2
3export default function name({ posts }) {
4  return (
5    <>
6      <div>
7        <div>
8          {posts.Title}
9        </div>
10      </div>
11      <div>
12        <ReactMarkdown source={posts.Content} escapeHtml={false} />
13      </div>
14    </>
15  );
16}
17
18export async function getStaticProps() {
19  const res = await fetch("http://localhost:1337/blogs");
20  const posts = await res.json();
21
22  return {
23    props: { posts },
24  };
25}
26{
27  "name": "passportlegacy",
28  "version": "0.1.0",
29  "private": true,
30  "scripts": {
31    "dev": "next dev",
32    "build": "next build",
33    "start": "next start",
34    "lint": "next lint"
35  },
36  "dependencies": {
37    "axios": "^0.21.1",
38    "babel-plugin-inline-react-svg": "^2.0.1",
39    "next": "11.0.1",
40    "next-images": "^1.8.1",
41    "react": "17.0.2",
42    "react-dom": "17.0.2",
43    "react-map-gl": "^6.1.16",
44    "react-markdown": "^7.0.1",
45  },
46  "devDependencies": {
47    "@svgr/webpack": "^5.5.0",
48    "@types/react": "17.0.16",
49    "eslint": "7.32.0",
50    "eslint-config-next": "11.0.1",
51    "typescript": "4.3.5"
52  }
53}
54

ANSWER

Answered 2021-Sep-01 at 10:23

Node is currently treating your .js file as CommonJS. You need to tell Node to treat it as an ES module.

Try adding "type": "module" in your package.json file.

You can place it anywhere at the top level. E.g.:

1import ReactMarkdown from "react-markdown";
2
3export default function name({ posts }) {
4  return (
5    <>
6      <div>
7        <div>
8          {posts.Title}
9        </div>
10      </div>
11      <div>
12        <ReactMarkdown source={posts.Content} escapeHtml={false} />
13      </div>
14    </>
15  );
16}
17
18export async function getStaticProps() {
19  const res = await fetch("http://localhost:1337/blogs");
20  const posts = await res.json();
21
22  return {
23    props: { posts },
24  };
25}
26{
27  "name": "passportlegacy",
28  "version": "0.1.0",
29  "private": true,
30  "scripts": {
31    "dev": "next dev",
32    "build": "next build",
33    "start": "next start",
34    "lint": "next lint"
35  },
36  "dependencies": {
37    "axios": "^0.21.1",
38    "babel-plugin-inline-react-svg": "^2.0.1",
39    "next": "11.0.1",
40    "next-images": "^1.8.1",
41    "react": "17.0.2",
42    "react-dom": "17.0.2",
43    "react-map-gl": "^6.1.16",
44    "react-markdown": "^7.0.1",
45  },
46  "devDependencies": {
47    "@svgr/webpack": "^5.5.0",
48    "@types/react": "17.0.16",
49    "eslint": "7.32.0",
50    "eslint-config-next": "11.0.1",
51    "typescript": "4.3.5"
52  }
53}
54{
55  "name": "passportlegacy",
56  "version": "0.1.0",
57  "type": "module",
58  "private": true,
59  "scripts": {
60    ...
61  }
62  ...
63}
64

Source https://stackoverflow.com/questions/69008215

QUESTION

Android Studio [BumbleBee 2021.1.1] Emulator Timeout on Mac M1

Asked 2022-Feb-02 at 09:11

I have Android Studio BumbleBee 2021.1.1 downloaded, running on a MacBook Pro M1. When downloading Android Studio, I chose the Apple Chip option (opposed to Intel)

I've created a Virtual Device - Android 12.0 arm64-v8a Pixel 4.

When I attempt to run the emulator it gets stuck here

Connecting to the Emulator...

Then, it times out:

Timeout Error

I have searched SO and other blogs and can only find outdated material based on a time in 2020/2021 when Android did not support ARM64. However, it's my understanding that this has now changed so https://github.com/google/android-emulator-m1-preview is no longer needed.

What is the correct way to run the Android Emulator on a Mac with an M1 Chip?

ANSWER

Answered 2022-Jan-28 at 19:17

I have found the issue so marking this as solved, however, if anyone knows why this solves the problem, please share!

I found an issue opened on Google's anroid-emulator-m1-preview repo with this answer https://github.com/google/android-emulator-m1-preview/issues/76#issuecomment-1023563846

Turns out, I just needed to uncheck 'Launch in a tool window' but again, not sure why that fixed the issue.

Source https://stackoverflow.com/questions/70898219

QUESTION

Log4j vulnerability - Is Log4j 1.2.17 vulnerable (was unable to find any JNDI code in source)?

Asked 2022-Feb-01 at 15:47

With regard to the Log4j JNDI remote code execution vulnerability that has been identified CVE-2021-44228 - (also see references) - I wondered if Log4j-v1.2 is also impacted, but the closest I got from source code review is the JMS-Appender.

The question is, while the posts on the Internet indicate that Log4j 1.2 is also vulnerable, I am not able to find the relevant source code for it.

Am I missing something that others have identified?

Log4j 1.2 appears to have a vulnerability in the socket-server class, but my understanding is that it needs to be enabled in the first place for it to be applicable and hence is not a passive threat unlike the JNDI-lookup vulnerability which the one identified appears to be.

Is my understanding - that Log4j v1.2 - is not vulnerable to the jndi-remote-code execution bug correct?

References

This blog post from Cloudflare also indicates the same point as from AKX....that it was introduced from Log4j 2!

Update #1 - A fork of the (now-retired) apache-log4j-1.2.x with patch fixes for few vulnerabilities identified in the older library is now available (from the original log4j author). The site is https://reload4j.qos.ch/. As of 21-Jan-2022 version 1.2.18.2 has been released. Vulnerabilities addressed to date include those pertaining to JMSAppender, SocketServer and Chainsaw vulnerabilities. Note that I am simply relaying this information. Have not verified the fixes from my end. Please refer the link for additional details.

ANSWER

Answered 2022-Jan-01 at 18:43

The JNDI feature was added into Log4j 2.0-beta9.

Log4j 1.x thus does not have the vulnerable code.

Source https://stackoverflow.com/questions/70310980

QUESTION

Converting Numbers from Base 10 to Base 60

Asked 2022-Jan-31 at 05:15

Recently, I was reading about the Ancient Babylonian Civilization that used a number system with base 60 instead of base 10. Even with this number system at base 60, they were still able to approximate the square root of 2 — and that too, thousands of years ago!

enter image description here

I was curious about this, and wanted to see how numbers from our decimal system (base 10) can be converted into the sexagesimal system (base 60). Using the R programming language, I found this link in which an answer is provided on converting numbers from some base to a different base.

However, it seems here that the base can only be between 2 and 36 (I want base 60):

1base <- function(b, base = 10)
2{
3  base <- as.integer(base)
4  if(base > 36 | base < 2) stop("'base' must be between 2 and 36.")
5  
6  structure(lapply(b, function(x) 
7    {
8      n   <- ceiling(log(x, base))
9      vec <- numeric()
10      val <- x
11      
12      while(n >= 0)
13      {
14        rem <- val %/% base^n
15        val <- val - rem * base^n
16        vec <- c(vec, rem)
17        n <- n - 1
18      }
19      
20      while(vec[1] == 0 & length(vec) > 1) vec <- vec[-1]
21      structure(x, base = base, representation = vec) 
22    }), class = "base")
23}
24

The article that I linked to reads in the headline "One eighth equals seven and thirty in this strange base 60 world" - I would like to see this and convert "1/8" from the decimal system into "7 and 30" in the sexagesimal system.

Can someone please help me with this?

ANSWER

Answered 2022-Jan-30 at 20:41

The code as given almost works. The limitation to bases < 36 is only there because the original author wanted to express the values with the symbols [0-9A-Z]. Removing that limitation and extending the algorithm to allow extra digits 'after the decimal point' (or 'after the sexagesimal point' in the case of base 60 :-) ) we get something that almost works (function definition below):

1base &lt;- function(b, base = 10)
2{
3  base &lt;- as.integer(base)
4  if(base &gt; 36 | base &lt; 2) stop(&quot;'base' must be between 2 and 36.&quot;)
5  
6  structure(lapply(b, function(x) 
7    {
8      n   &lt;- ceiling(log(x, base))
9      vec &lt;- numeric()
10      val &lt;- x
11      
12      while(n &gt;= 0)
13      {
14        rem &lt;- val %/% base^n
15        val &lt;- val - rem * base^n
16        vec &lt;- c(vec, rem)
17        n &lt;- n - 1
18      }
19      
20      while(vec[1] == 0 &amp; length(vec) &gt; 1) vec &lt;- vec[-1]
21      structure(x, base = base, representation = vec) 
22    }), class = &quot;base&quot;)
23}
24base(1/8, base = 60, digits = 6)
25[[1]]
26[1] 0.125
27attr(,&quot;base&quot;)
28[1] 60
29attr(,&quot;representation&quot;)
30[1]  7 29 59 59 59 59
31
32attr(,&quot;class&quot;)
33[1] &quot;base&quot;
34

Instead of "7 30" we get "7 29 (59 repeating)", which is analogous to doing a decimal calculation that should be 0.2 and instead getting 0.1999....

This would presumably be fixable with an appropriate 'numeric fuzz' threshold.

The other thing that's missing from the code, now that it does fractional parts, is that the result should return information that tells you where the 'decimal' point is located (at the simplest, including the value of digits in the output).

There are other aspects of the code that could be improved (e.g. pre-allocating vec rather than building it up iteratively).


1base &lt;- function(b, base = 10)
2{
3  base &lt;- as.integer(base)
4  if(base &gt; 36 | base &lt; 2) stop(&quot;'base' must be between 2 and 36.&quot;)
5  
6  structure(lapply(b, function(x) 
7    {
8      n   &lt;- ceiling(log(x, base))
9      vec &lt;- numeric()
10      val &lt;- x
11      
12      while(n &gt;= 0)
13      {
14        rem &lt;- val %/% base^n
15        val &lt;- val - rem * base^n
16        vec &lt;- c(vec, rem)
17        n &lt;- n - 1
18      }
19      
20      while(vec[1] == 0 &amp; length(vec) &gt; 1) vec &lt;- vec[-1]
21      structure(x, base = base, representation = vec) 
22    }), class = &quot;base&quot;)
23}
24base(1/8, base = 60, digits = 6)
25[[1]]
26[1] 0.125
27attr(,&quot;base&quot;)
28[1] 60
29attr(,&quot;representation&quot;)
30[1]  7 29 59 59 59 59
31
32attr(,&quot;class&quot;)
33[1] &quot;base&quot;
34base &lt;- function(b, base = 10, digits = 0) {
35  base &lt;- as.integer(base)
36  structure(lapply(b, function(x)
37    {
38      n   &lt;- ceiling(log(x, base))
39      vec &lt;- numeric()
40      val &lt;- x
41
42      while(n &gt;= -1*digits )  {
43        rem &lt;- val %/% base^n
44        val &lt;- val - rem * base^n
45        vec &lt;- c(vec, rem)
46        n &lt;- n - 1
47      }
48
49      while(vec[1] == 0 &amp; length(vec) &gt; 1) vec &lt;- vec[-1]
50      structure(x, base = base, representation = vec)
51    }), class = &quot;base&quot;)
52}
53

Source https://stackoverflow.com/questions/70918281

QUESTION

What's the mathematical reason behind Python choosing to round integer division toward negative infinity?

Asked 2022-Jan-30 at 01:29

I know Python // rounds towards negative infinity and in C++ / is truncating, rounding towards 0.

And here's what I know so far:

1               |remainder|
2-12 / 10  = -1,   - 2      // C++
3-12 // 10 = -2,   + 8      # Python
4
512 / -10  = -1,     2      // C++
612 // -10 = -2,   - 8      # Python
7
812 / 10  = 1,      2       // Both
912 // 10 = 1,      2
10
11-12 / -10 = 1,    - 2      // Both
12          = 2,    + 8
13
14C++:
151. m%(-n) == m%n
162. -m%n == -(m%n)
173. (m/n)*n + m%n == m
18
19Python:
201. m%(-n) == -8 == -(-m%n)
212. (m//n)*n + m%n == m
22

But why Python // choose to round towards negative infinity? I didn't find any resources explain that, but only find and hear people say vaguely: "for mathematics reasons".

For example, in Why is -1/2 evaluated to 0 in C++, but -1 in Python?:

People dealing with these things in the abstract tend to feel that rounding toward negative infinity makes more sense (that means it's compatible with the modulo function as defined in mathematics, rather than % having a somewhat funny meaning).

But I don't see C++ 's / not being compatible with the modulo function. In C++, (m/n)*n + m%n == m also applies.

So what's the (mathematical) reason behind Python choosing rounding towards negative infinity?


See also Guido van Rossum's old blog post on the topic.

ANSWER

Answered 2022-Jan-18 at 21:46

Although I can't provide a formal definition of why/how the rounding modes were chosen as they were, the citation about compatibility with the % operator, which you have included, does make sense when you consider that % is not quite the same thing in C++ and Python.

In C++, it is the remainder operator, whereas, in Python, it is the modulus operator – and, when the two operands have different signs, these aren't necessarily the same thing. There are some fine explanations of the difference between these operators in the answers to: What's the difference between “mod” and “remainder”?

Now, considering this difference, the rounding (truncation) modes for integer division have to be as they are in the two languages, to ensure that the relationship you quoted, (m/n)*n + m%n == m, remains valid.

Here are two short programs that demonstrate this in action (please forgive my somewhat naïve Python code – I'm a beginner in that language):

C++:

1               |remainder|
2-12 / 10  = -1,   - 2      // C++
3-12 // 10 = -2,   + 8      # Python
4
512 / -10  = -1,     2      // C++
612 // -10 = -2,   - 8      # Python
7
812 / 10  = 1,      2       // Both
912 // 10 = 1,      2
10
11-12 / -10 = 1,    - 2      // Both
12          = 2,    + 8
13
14C++:
151. m%(-n) == m%n
162. -m%n == -(m%n)
173. (m/n)*n + m%n == m
18
19Python:
201. m%(-n) == -8 == -(-m%n)
212. (m//n)*n + m%n == m
22#include &lt;iostream&gt;
23
24int main()
25{
26    int dividend, divisor, quotient, remainder, check;
27    std::cout &lt;&lt; &quot;Enter Dividend: &quot;;                        // -27
28    std::cin &gt;&gt; dividend;
29    std::cout &lt;&lt; &quot;Enter Divisor: &quot;;                         // 4
30    std::cin &gt;&gt; divisor;
31
32    quotient = dividend / divisor;
33    std::cout &lt;&lt; &quot;Quotient = &quot; &lt;&lt; quotient &lt;&lt; std::endl;    // -6
34    remainder = dividend % divisor;
35    std::cout &lt;&lt; &quot;Remainder = &quot; &lt;&lt; remainder &lt;&lt; std::endl;  // -3
36
37    check = quotient * divisor + remainder;
38    std::cout &lt;&lt; &quot;Check = &quot; &lt;&lt; check &lt;&lt; std::endl;          // -27
39    return 0;
40}
41

Python:

1               |remainder|
2-12 / 10  = -1,   - 2      // C++
3-12 // 10 = -2,   + 8      # Python
4
512 / -10  = -1,     2      // C++
612 // -10 = -2,   - 8      # Python
7
812 / 10  = 1,      2       // Both
912 // 10 = 1,      2
10
11-12 / -10 = 1,    - 2      // Both
12          = 2,    + 8
13
14C++:
151. m%(-n) == m%n
162. -m%n == -(m%n)
173. (m/n)*n + m%n == m
18
19Python:
201. m%(-n) == -8 == -(-m%n)
212. (m//n)*n + m%n == m
22#include &lt;iostream&gt;
23
24int main()
25{
26    int dividend, divisor, quotient, remainder, check;
27    std::cout &lt;&lt; &quot;Enter Dividend: &quot;;                        // -27
28    std::cin &gt;&gt; dividend;
29    std::cout &lt;&lt; &quot;Enter Divisor: &quot;;                         // 4
30    std::cin &gt;&gt; divisor;
31
32    quotient = dividend / divisor;
33    std::cout &lt;&lt; &quot;Quotient = &quot; &lt;&lt; quotient &lt;&lt; std::endl;    // -6
34    remainder = dividend % divisor;
35    std::cout &lt;&lt; &quot;Remainder = &quot; &lt;&lt; remainder &lt;&lt; std::endl;  // -3
36
37    check = quotient * divisor + remainder;
38    std::cout &lt;&lt; &quot;Check = &quot; &lt;&lt; check &lt;&lt; std::endl;          // -27
39    return 0;
40}
41print(&quot;Enter Dividend: &quot;)             # -27
42dividend = int(input())
43print(&quot;Enter Divisor: &quot;)              # 4
44divisor = int(input())
45quotient = dividend // divisor;
46print(&quot;Quotient = &quot; + str(quotient))  # -7
47modulus = dividend % divisor;
48print(&quot;Modulus = &quot; + str(modulus))    # 1
49check = quotient * divisor + modulus; # -27
50print(&quot;Check = &quot; + str(check))
51

Note that, for the given inputs of different signs (-27 and 4), both the quotient and remainder/modulus are different between the languages but also that the restored check value is correct in both cases.

Source https://stackoverflow.com/questions/70730831

Community Discussions contain sources that include Stack Exchange Network

Tutorials and Learning Resources in Blog

Tutorials and Learning Resources are not available at this moment for Blog

Share this Page

share link

Get latest updates on Blog