Install VSFTPd on AWS EC2



sudo apt install vsftpd
sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.original
sudo nano /etc/vsftpd.conf

anonymous_enable=NO
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
ls_recurse_enable=YES
local_root=/var/www
seccomp_sandbox=no
pam_service_name=ftp
pasv_enable=YES
pasv_min_port=13000
pasv_max_port=13100
port_enable=YES
pasv_address=__your_ec2_domain__
pasv_addr_resolve=YES

sudo useradd myftp
sudo passwd myftp
sudo usermod --home /var/www/ myftp

sudo addgroup ftpusers
sudo usermod -a -G ftpusers myftp
sudo usermod -a -G www-data myftp
sudo usermod -g ftpusers myftp

sudo nano /etc/vsftpd.chroot_list
ubuntu

sudo nano /etc/ssh/sshd_config

Match Group ftpusers
ForceCommand internal-sftp
ChrootDirectory /var/www/
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no

sudo service ssh restart
sudo systemctl restart vsftpd

Set you EC2 Security Group to allow incoming tcp traffic to port 20-21, 13000-13100
Connect from you ftp client and set connection to passive mode

 

Nodejs – Error: ENOENT: no such file or directory, scandir ‘node_modules/node-sass/vendor’


I’ve experience weird moment today when trying to run my friend’s gulp script which call node-sass, it throw this error

Error: ENOENT: no such file or directory, scandir '**/node_modules/node-sass/vendor'

I call it weird because normally it has ‘vendor’ folder.

After Googling, visiting some stackoverflow pages, the solution is simple: just invoke these two commands

nodejs node_modules/node-sass/scripts/install.js
npm rebuild node-sass

then you’re good to go 🙂

 

PostgreSQL: Create Database, User and Grant Privileges


Open terminal and invoke this command:

psql -U postgres

to create new database, invoke this command:

CREATE DATABASE mydatabase;

to create new user, invoke this command:

CREATE USER dbuser WITH PASSWORD 'mypassword';

then, you can set your desired user-related preference like this

ALTER ROLE dbuser SET client_encoding TO 'utf8';
ALTER ROLE dbuser SET default_transaction_isolation TO 'read committed';
ALTER ROLE dbuser SET timezone TO 'UTC';

to grant privileges, invoke this command:

GRANT ALL PRIVILEGES ON DATABASE mydatabase TO dbuser;

Quit from PostgreSQL console

\q

Python Date/Time Libraries


Maya: DateTimes for Humans
https://github.com/kennethreitz/maya

Arrow: Python library that offers a sensible, human-friendly approach to creating, manipulating, formatting and converting dates, times, and timestamps
http://arrow.readthedocs.io/en/latest/

Pendulum: Python Date/Time Made Easy
https://pendulum.eustace.io/

Delorean: Time Travel Made Easy
https://github.com/myusuf3/delorean

Moment: Dealing with dates in Python shouldn’t have to suck
https://github.com/zachwill/moment

udatetime: Fast RFC3339 compliant date-time library
https://github.com/freach/udatetime

Fast ISO8601 date time parser for Python written in C
https://github.com/closeio/ciso8601

Django Error : CSRF cookie not set


Django version: 1.11.11

This error occurred when you try to submit POST form via Postman 2 App

My temporary solution is disabling CSRF Checking by creating a custom middleware.

Just create a new file on the same folder with your settings.py file, let’s name it middleware.py and put these code:

from django.utils.deprecation import MiddlewareMixinfrom django.utils.deprecation import MiddlewareMixin
class DisableCsrfCheck(MiddlewareMixin):
 def process_request(self, req): attr = '_dont_enforce_csrf_checks' if not getattr(req, attr, False): setattr(req, attr, True)

then add this on settings.py before django’s CSRF middleware:

'yourProjectName.middleware.DisableCsrfCheck',

source:

https://stackoverflow.com/questions/16458166/how-to-disable-djangos-csrf-validation