Архив на: pstoev

Linux: installing global npm packages without using sudo (a.k.a. resolving EACCES permissions errors when installing packages globally)

1. Create a directory where global packages will be deployed:

mkdir ~/.npm-global

2. Set the newly created directory as default global directory for npm:

npm config set prefix '~/.npm-global'

3. Update the $PATH environment variable by adding this to your .profile file (in your user home directory) so that the terminal knows where to find the global packages:

export PATH=~/.npm-global/bin:$PATH

4. Reload environment in current shell by running (or just open a new one):

source ~/.profile

5. Test if the setup was successful by installing a package (without using sudo):

npm i -g jshint

6. And running it (should print out jshint version):

jshint --version

Stay healthy!

Adversarial Learning of Realistic Neural Talking Head Models

Redirecting your domain to a new URL on Apache using .htaccess (including SSL/TLS (HTTPS))

Redirecting to a new URL (domain and/or path)

Make sure you’ve got mod_rewrite on and your rewrite base is propertly set:

RewriteEngine On
RewriteBase /

Redirecting a domain

Describe all the domains that you want redirected. In this case we want to redirect both alpha-domain.com and its subdomain www.alpha-domain.com:

RewriteCond %{HTTP_HOST} ^alpha-domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.alpha-domain.com$

And point those requests that match the condition to the new domain by using:

RewriteRule (.*)$ https://beta-domain.com/$1 [R=301,L]

As a summary, this is what we should have in the .htaccess file:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^alpha-domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.alpha-domain.com$
RewriteRule (.*)$ https://beta-domain.com/$1 [R=301,L]

Redirecting to secure connection (TLS/SSL (aka HTTPS))

Below is all there’s needed. If you want to ensure the user is always redirected to TLS in addition to a new domain, just omit the first two lines if you already have them in the .htaccess file:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS}  !=on 
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] 

NB: This one is domain-agnostic, so in the case of redirecting to a new domain, make sure you have redirected the user to the new domain, before sending him on the secure connection.