Skip to content

Instantly share code, notes, and snippets.

View amyonsun's full-sized avatar
📑
33

Amyonsun amyonsun

📑
33
View GitHub Profile
@amyonsun
amyonsun / mongodb_add_user.py
Last active July 9, 2021 21:53
Python, MongoDB - Add New User With Phone Number
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
# Importing Libraries
from pymongo import MongoClient
from datetime import datetime
# NOTE: make sure to install pymongo[srv] too via "pip install pymongo[srv]"
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
# Database Configuration
Cluster = MongoClient("mongodb+srv://<username>:<password>@<clustor>.<hostname>/<database-name>")
@amyonsun
amyonsun / raygansms.py
Last active July 9, 2021 21:34
Send SMS via Raygansms.com API
import requests
import urllib.parse
def send_sms_with_raygansms_via_get_method(phone_number, message):
try:
url = 'https://raygansms.com/SendMessageWithUrl.ashx?'
parametrs = {
'UserName': '<username>',
@amyonsun
amyonsun / password_hash_generator.py
Last active July 9, 2021 21:23
Password Hash (sha256) Generator Python Function
# import from library
from hashlib import sha256
# same for all users
public_extra = 'Some random string'
# function
def password_hash_generator(password, private_extra):
# private_extra is different for every user
hash_of_password = sha256((password + private_extra + public_extra).encode('utf-8')).hexdigest()