Skip to content

Instantly share code, notes, and snippets.

View ivanleoncz's full-sized avatar
🔭
I'm not here.

ivanleoncz ivanleoncz

🔭
I'm not here.
View GitHub Profile
@ivanleoncz
ivanleoncz / mongo_client.py
Last active March 10, 2018 14:25
Demonstration of PyMongo usage (MongoDB 3.4.3 + PyMongo 3.4.0).
#!/usr/bin/python3
""" Demonstration of PyMongo usage. """
from bson.objectid import ObjectId
from datetime import datetime
from pymongo import MongoClient
__author__ = "@ivanleoncz"
@ivanleoncz
ivanleoncz / flask_job_scheduler.py
Last active June 27, 2024 07:23
Demonstrating APScheduler on a Flask App.
#!/usr/bin/python3
""" Demonstrating APScheduler feature for small Flask App. """
from apscheduler.schedulers.background import BackgroundScheduler
from flask import Flask
def sensor():
""" Function for test purposes. """
print("Scheduler is alive!")
@ivanleoncz
ivanleoncz / MongoDB Reference
Last active October 13, 2017 05:25
CRUD and general administration of MongoDB databases.
### Create, Read, Update and Delete
# SHOW DATABASES
> show databases
> show dbs
# DEFINE DATABASE FOR OPERATIONS
> use database_name
# CREATE DATABASE AND COLLECTIONS
@ivanleoncz
ivanleoncz / pass_hash_validator.py
Last active March 12, 2018 02:49
Determining validation of password, against password hash.
#!/usr/bin/python3
""" Determining validation of a password, against its hash. """
import bcrypt
from getpass import getpass
# simulation of hashed password stored in a DBMS (MongoDB, MySQL, SQLite, etc.)
salt = bcrypt.gensalt()
db_password = "Guido*Py2017".encode('utf-8')
db_pass_hash = bcrypt.hashpw(db_password,salt)
@ivanleoncz
ivanleoncz / Android SSL (Self-signed certificate)
Last active March 3, 2020 03:09
Android Login app, using Self-Signed SSL Certificate. Later on, I'll create a project at GitHub, with the whole App (explanations and details).
package com.ivanlmj.myapp;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
@ivanleoncz
ivanleoncz / ssl-config
Last active March 12, 2020 14:29
Generates self-signed SSL certificates.
[ req ]
default_bits = 2048
distinguished_name = req_distinguished_name
attributes = req_attributes
prompt = no
[ req_distinguished_name ]
C = MX
ST = VE
L = XL
@ivanleoncz
ivanleoncz / flask_app_logging.py
Last active February 26, 2025 21:14
Demonstration of logging feature for a Flask App.
#/usr/bin/python3
""" Demonstration of logging feature for a Flask App. """
from logging.handlers import RotatingFileHandler
from flask import Flask, request, jsonify
from time import strftime
__author__ = "@ivanleoncz"
import logging