Semantic Versioning

 Semantic Versioning 2.0.0 | Semantic Versioning (semver.org)

Given a version number MAJOR.MINOR.PATCH, increment the:

  1. MAJOR version when you make incompatible API changes,
  2. MINOR version when you add functionality in a backwards compatible manner, and
  3. PATCH version when you make backwards compatible bug fixes.

Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.

bitbucket: Import an existing, unversioned code project

 

Import code using the terminal

Import code from an existing project using the terminal by first cloning the repository to your local system and then pushing to an empty Bitbucket repository.

Import an existing, unversioned code project

If you have code on your local machine that is not under source control, you can put it under source control and import it into Bitbucket.

Assuming you have Git installed on your local machine, then:

  1. Locally, change to the root directory of your existing source.
  2. Initialize the project by running the following commands in the terminal:

    git init
    git add --all
    git commit -m "Initial Commit"
  3. Log into Bitbucket and create a new repository.
  4. Locate the clone URL in the nav panel on the left (for example:  https://username@your.bitbucket.domain:7999 /yourproject/repo.git).
  5. Push your files to the repository by running the following commands in the terminal (change the URL accordingly):

    git remote add origin https://username@your.bitbucket.domain:7999/yourproject/repo.git 
    git push -u origin master
  6. Done! Your repository is now available in Bitbucket.

Import an existing Git project 

You can import your existing Git repository into an empty repository in Bitbucket. When you do this, Bitbucket maintains your commit history.

  1. Check out the repository from your existing Git host. Use the --bare parameter:

    git clone --bare https://username@bitbucket.org/exampleuser/old-repository.git
  2. Log into Bitbucket and create a new repository (we've called it repo.git in this example).

  3. Locate the clone URL in the nav panel on the left (for example:  https://username@your.bitbucket.domain:7999 /yourproject/repo.git).

  4. Add Bitbucket as another remote in your local repository:

    cd old-repository
    git remote add bitbucket https://username@your.bitbucket.domain:7999/yourproject/repo.git
  5. Push all branches and tags to the new repository:

    git push --all bitbucket
    git push --tags bitbucket
  6. Remove your temporary local repository:

    cd ..
    rm -rf old-repository

Importing code from an existing project | Bitbucket Data Center and Server 7.17 | Atlassian Documentation

Mirror an existing Git repository

You can mirror an existing repository into a repository hosted in Bitbucket.

  1. Check out the repository from your existing Git host. Use the --mirror parameter:

    git clone --mirror https://username@bitbucket.org/exampleuser/repository-to-mirror.git
  2. Log into Bitbucket and create a new repository (we've called it repo.git in this example).

  3. Locate the clone URL in the nav panel on the left (for example:  https://username@your.bitbucket.domain:7999 /yourproject/repo.git).

  4. Add Bitbucket as another remote in your local repository:

    git remote add bitbucket https://username@your.bitbucket.domain:7999/yourproject/repo.git
  5. Then push all branches and tags to Bitbucket:

    git push --all bitbucket
    git push --tags bitbucket
  6. Use git fetch --prune origin  ('–prune' will remove any branches that no longer exist in the remote) followed by the git push commands from step 5 to update the Bitbucket mirror with new changes from the upstream repository.

NGINX: (13: Permission denied) while connecting to upstream:[nginx]

 

Disclaimer

Make sure there are no security implications for your use-case before running this.

Answer

I had a similar issue getting Fedora 20, Nginx, Node.js, and Ghost (blog) to work. It turns out my issue was due to SELinux.

This should solve the problem:

setsebool -P httpd_can_network_connect 1

django - (13: Permission denied) while connecting to upstream:[nginx] - Stack Overflow

Details

I checked for errors in the SELinux logs:

sudo cat /var/log/audit/audit.log | grep nginx | grep denied

And found that running the following commands fixed my issue:

sudo cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M mynginx
sudo semodule -i mynginx.pp

Option #2 (untested, but probably more secure)

setsebool -P httpd_can_network_relay 1

https://security.stackexchange.com/questions/152358/difference-between-selinux-booleans-httpd-can-network-relay-and-httpd-can-net

References

http://blog.frag-gustav.de/2013/07/21/nginx-selinux-me-mad/
https://wiki.gentoo.org/wiki/SELinux/Tutorials/Where_to_find_SELinux_permission_denial_details
http://wiki.gentoo.org/wiki/SELinux/Tutorials/Managing_network_port_labels

POETRY: Add awareness of pip installed packages

 

Poetry is not aware of accidental/purposeful use of pip to install packages

$ poetry init
$ poetry add tqdm
$ poetry shell
$ pip install numpy # e.g., user did this accidentally 

Actual

$ poetry lock && poetry install
$ poetry show
tqdm 4.50.0 Fast, Extensible Progress Meter

Expected

$ poetry lock && poetry install
$ poetry show
tqdm 4.50.0 Fast, Extensible Progress Meter
numpy 1.19.2 NumPy is the fundamental package for array computing with Python.

I understand this is very difficult to support currently and the current design recommends user to avoid pip in favor of installing via poetry. However, in peculiar cases (e.g., syntax conventions), sometimes install via poetry is not possible/easy and pip is preferred to be used.

Is there a standard function to check for null, undefined, or blank variables in JavaScript?

 Is there a standard function to check for null, undefined, or blank variables in JavaScript? - Stack Overflow

You can just check if the variable has a truthy value or not. That means

if( value ) {
}

will evaluate to true if value is not:

  • null
  • undefined
  • NaN
  • empty string ("")
  • 0
  • false

The above list represents all possible falsy values in ECMA-/Javascript. Find it in the specification at the ToBoolean section.

Furthermore, if you do not know whether a variable exists (that means, if it was declared) you should check with the typeof operator. For instance

if( typeof foo !== 'undefined' ) {
    // foo could get resolved and it's defined
}

If you can be sure that a variable is declared at least, you should directly check if it has a truthy value like shown above.

GITLAB: How to reset user password

 How to reset user password | GitLab

There are a few ways to reset the password of a user.

Rake Task

Introduced in GitLab 13.9.

GitLab provides a Rake Task to reset passwords of users using their usernames, which can be invoked by the following command:

sudo gitlab-rake "gitlab:password:reset"

GitLab asks for a username, a password, and a password confirmation. Upon giving proper values for them, the password of the specified user is updated.

The Rake task also takes the username as an argument, as shown in the example below:

sudo gitlab-rake "gitlab:password:reset[johndoe]"
To reset the default admin password, run this Rake task with the username root, which is the default username of that administrator account.

Python: How can I correctly include a path dependency in pyproject.toml?

 python - How can I correctly include a path dependency in pyproject.toml? - Stack Overflow

Your folder structure looks a bit weird. It looks like your prefer the "src" variant. So I would suggest the following:

./
├── abc-lib
│   ├── pyproject.toml
│   └── src
│       └── abc_lib
│           ├── __init__.py
│           └── main.py
└── abc-web-api
    ├── pyproject.toml
    └── src
        └── abc_web_api
            ├── __init__.py
            └── main.py

With this pyproject.toml in abc-lib:

[tool.poetry]
name = "abc-lib"
version = "0.1.0"
description = ""
authors = ["Someone <someone@example.com>"]


[tool.poetry.dependencies]
python = "^3.6"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry>=1.0"]
build-backend = "poetry.masonry.api"

And this in abc-web-api:

[tool.poetry]
name = "abc-web-api"
version = "0.1.0"
description = ""
authors = ["Someone <someone@example.com>"]


[tool.poetry.dependencies]
python = "^3.6"
abc-lib = {path = "../abc-lib"}

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry>=1.0"]
build-backend = "poetry.masonry.api"

Git: Copy source code to new branch without history

 Git: Copy source code to new branch without history - Stack Overflow

I found a faster way that can be used:

git checkout <branch> -- .

This will replace the content of the currently checkouted branch by the content of the <branch>.

This doesn't copy <branch> commit history.

If you just want to checkout only some files just replace the . with the file paths from <branch>.

EDIT: I found out that this will only replace current files and it will not delete files that are not on the <branch>.

It is then better to run rm -rf before doing the checkout.

GIT: Bitbucket delete master branch

 

git - Deleting remote master branch, refused due to being the current branch - Stack Overflow

Note: for Bitbucket, you would change the default branch by accessing the settings of your repository, and changing the branch at the "Main branch" combo box.




Once the main branch is no longer master, then you can push and remove master.

MarsAndBack confirms in the comments this applies to GitHub as well.

GIT: Import an existing Git project

 Importing code from an existing project | Bitbucket Data Center and Server 7.17 | Atlassian Documentation


git clone -mirror vs. git clone -bare

git clone --bare

Similar to git init --bare, when the -bare argument is passed to git clone, a copy of the remote repository will be made with an omitted working directory. This means that a repository will be set up with the history of the project that can be pushed and pulled from, but cannot be edited directly. In addition, no remote branches for the repo will be configured with the -bare repository. Like git init --bare, this is used to create a hosted repository that developers will not edit directly.

git clone --mirror

Passing the --mirror argument implicitly passes the --bare argument as well. This means the behavior of --bare is inherited by --mirror. Resulting in a bare repo with no editable working files. In addition, --mirror will clone all the extended refs of the remote repository, and maintain remote branch tracking configuration. You can then run git remote update on the mirror and it will overwrite all refs from the origin repo. Giving you exact 'mirrored' functionality.

You can import your existing Git repository into an empty repository in Bitbucket. When you do this, Bitbucket maintains your commit history.

  1. Check out the repository from your existing Git host. Use the --bare parameter:

    git clone --bare https://username@bitbucket.org/exampleuser/old-repository.git
  2. Log into Bitbucket and create a new repository (we've called it repo.git in this example).

  3. Locate the clone URL in the nav panel on the left (for example:  https://username@your.bitbucket.domain:7999 /yourproject/repo.git).

  4. Add Bitbucket as another remote in your local repository:

    cd old-repository
    git remote add bitbucket https://username@your.bitbucket.domain:7999/yourproject/repo.git
  5. Push all branches and tags to the new repository:

    git push --all bitbucket
    git push --tags bitbucket
  6. Remove your temporary local repository:

    cd ..
    rm -rf old-repository

anti-pattern là gì

  Trong công nghệ và lập trình, Anti-pattern (mẫu phản diện) là những giải pháp bề ngoài có vẻ hiệu quả để giải quyết một vấn đề phổ biến, ...