Skip to content

Instantly share code, notes, and snippets.

View pu71n's full-sized avatar

putin pu71n

View GitHub Profile
#!/bin/sh python3.6
import shelve
import pyperclip #pip install pyperclip
import sys
mcbShelf = shelve.open('mcb') # creating the shelve
if len(sys.argv) ==3 and sys.argv[1].lower() == 'save':
#saving the clipboard with the keyword given as a command line argument
@pu71n
pu71n / password_manager.py
Created April 21, 2020 22:49
Password Manager
#! python3
from email_validator import validate_email, EmailNotValidError
import base64,ast,os,sys,random,string
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.fernet import Fernet as ft
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from pathlib import Path
>>> whoamai.setdefault('favorite word','fuck trump')
>>> whoami.setdefault('favorite word','fuck trump')
'fuck trump'
>>> whoami.setdefault('favorite word','fuck who')
'fuck trump'
@pu71n
pu71n / in_not_in_example_dict.py
Created April 19, 2020 13:50
in and not in example in dictionaries
>>> whoami = {'name':'putin', 'age':'google it', 'job':'president'}
>>> 'age' in whoami.keys()
True
>>> president in whoami.values()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'president' is not defined
>>> 'president' in whoami.values()
True
>>>
@pu71n
pu71n / in_not_in_example_dict.py
Created April 19, 2020 13:50
in and not in example in dictionaries
>>> whoami = {'name':'putin', 'age':'google it', 'job':'president'}
>>> 'age' in whoami.keys()
True
>>> president in whoami.values()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'president' is not defined
>>> 'president' in whoami.values()
True
>>>
>>> whoami = {'name':'putin', 'age':'google it', 'job':'president'}
>>> for i, j in whoami.items():
... print(i,j, sep=' : ')
...
name : putin
age : google it
job : president
@pu71n
pu71n / keys()_values()_items().py
Created April 19, 2020 13:23
Keys(), values() and items() example
>>> spam = {'color': 'red', 'age': 42}
>>> for v in spam.values():
print(v)
red
42
>>> for k in spam.keys():
print(k)
color
age
@pu71n
pu71n / dictionaries_example.py
Last active April 19, 2020 13:20
Dictionaries example
>>> myCat = {'size': 'fat', 'color': 'gray', 'disposition': 'loud'}
>>> myCat['size']
'fat'
>>> 'My cat has ' + myCat['color'] + ' fur.'
'My cat has gray fur.'
@pu71n
pu71n / remove()_method.py
Created April 18, 2020 19:54
remove() method example
>>> spam = ['cat', 'bat', 'rat', 'cat', 'hat', 'cat']
>>> spam.remove('cat')
>>> spam
['bat', 'rat', 'cat', 'hat', 'cat']
@pu71n
pu71n / append()_insert().py
Created April 18, 2020 19:49
append() and insert() methods examples
>>> spam = ['cat', 'dog', 'bat']
>>> spam.append('moose')
>>> spam
['cat', 'dog', 'bat', 'moose']
>>> spam = ['cat', 'dog', 'bat']
>>> spam.insert(1, 'chicken')
>>> spam
['cat', 'chicken', 'dog', 'bat']