NPM : Unexpected end of JSON input while parsing near


I got this error when trying to install npm-check-updates with npm 5.6.0 on node 8.1.1

The solution is simple, just invoke

npm cache clean --force

try install npm-check-updates again, voila! it works

source:

https://github.com/npm/npm/issues/19072

Advertisements

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

Shell – Check SSL Certificate


Just a few minutes after trying to check domain’s SSL Certificate expiry date with python which requires around ten lines of code, I found a shell script which doing that task in just one line, here’s the script

#!/bin/bash

echo | openssl s_client -servername example.com -connect example.com:443 2>/dev/null | openssl x509 -noout -dates

 

source:

Python – Check SSL Certificate Expiry Date


Just playing with python 3 to make a simple utility to check my domain expiry date

# save as check_ssl.py

import OpenSSL
import ssl, socket
import argparse

# get domain
parser = argparse.ArgumentParser()
parser.add_argument(“domain”)
args = parser.parse_args()
domain = args.domain

# get SSL Cert info
cert = ssl.get_server_certificate((domain, 443))
x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, cert)
x509info = x509.get_notAfter()

exp_day = x509info[6:8].decode(‘utf-8’)
exp_month = x509info[4:6].decode(‘utf-8’)
exp_year = x509info[:4].decode(‘utf-8’)

exp_date = str(exp_day) + “-” + str(exp_month) + “-” + str(exp_year)

print(“SSL Certificate for domain”, domain, “will be expired on (DD-MM-YYYY)”, exp_date)

then run with the domain you want to check as the argument

python check_ssl.py example.com