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