Skip to content

Instantly share code, notes, and snippets.

View bitliner's full-sized avatar

Giovanni Gaglione bitliner

View GitHub Profile
@bitliner
bitliner / lerna.md
Created September 9, 2019 16:33
lerna.md

Pre-release workflow

With conventional commit

lerna publish --conventional-prerelease will publish a pre-release

lerna publish --conventional-graduate will move from pre-release to release

Resources

@bitliner
bitliner / ssl.md
Last active October 3, 2021 17:59

SSL

Check an SSL certificate

See when it expires: openssl x509 -enddate -noout -in file.pem

Let's Encrypt

Let's Encrypt - Setup / Apache

Statis website in 5 minutes

  1. install a digital ocean machine
  2. ssh root@...
  3. install nginx - sudo apt-get update && sudo apt-get install nginx
  4. use /var/www/html to host your static files

If you need to configure the hosting folder

  1. create the hosting folder - sudo mkdir /srv/www /srv/www/

get "creation date" of a file

# get inode 
stat PATH_TO_FILE

# get "crtime" (with acute brackets <...>)
debugfs -R "stat <INODE>" /dev/md5 | grep crtime
Action Command
open file directly at the end of file less +G file
move cursor to the end of file shift + G
keep colors in the log less -r file
@bitliner
bitliner / readme.md
Created December 10, 2018 01:24 — forked from RaVbaker/readme.md
[HOWTO] Forward ports a.k.a. make SSH Tunneling

Syntax:

ssh -L localport:host:hostport user@ssh_server -N 

where:

  • -L - port forwarding parameters (see below)
  • localport - local port (chose a port that is not in use by other service)
  • host - server that has the port (hostport) that you want to forward
  • hostport - remote port
@bitliner
bitliner / fail2ban.md
Last active September 20, 2019 08:51

fail2ban

Manual

Ban after a certain number of login attempts failed.

Some settings:

  • bantime
  • number of failed logins
  • etc.
@bitliner
bitliner / find-file-edited-in-the-last-1-hour.md
Created November 26, 2018 00:14
find files edited in the last hour or recently
find srch_dir -cmin -60 # change time

find srch_dir -mmin -60 # modification time

find srch_dir -amin -60 # access time
# Minute   Hour   Day of Month       Month          Day of Week        Command    
# (0-59)  (0-23)     (1-31)    (1-12 or Jan-Dec)  (0-6 or Sun-Sat)                
    0        2          12             *                *            /usr/bin/find
@bitliner
bitliner / python_server_gunicorn.py
Last active September 1, 2018 18:22
run a simple server with python/gunicorn
class MyPredictionResource:
def on_get(self, req, resp):
"""Handles GET requests"""
resp.body= json.dumps({"prediction": "you will sell €400"})
api = falcon.API()
api.add_route('/my-prediction', MyPredictionResource())
# run with `gunicorn --workers 4 server:api ./file.py`