This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ast | |
import json | |
def parse_json_string(text, default={}): | |
""" | |
function to parse the json string | |
into json parse or dict | |
:param `text` is the value of text model to parse. | |
:paran `default` is default output, eg: {}, [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fuzzy_merge_df1_and_df2(self, df_1, df_2, key1, key2, threshold=50, limit=2): | |
""" | |
df_1 is the left table to join | |
df_2 is the right table to join | |
key1 is the key column of the left table | |
key2 is the key column of the right table | |
threshold is how close the matches should be to return a match, based on Levenshtein distance | |
limit is the amount of matches that will get returned, these are sorted high to low | |
""" | |
s = df_2[key2].tolist() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q. What attributes do you look for in a company when applying for a position? | |
A. Technical stack, learning graph, company's vision and culture. | |
Q. What are the three to five expectations that you have of senior leaders in an organization where you’ll work successfully? | |
A. My senior should be helpful, co-operative, friendly and have clear understanding about what we are doing and going to do. | |
Q. At times your workload may feel unmanageable. Describe a time when you recognized that you were unable to meet multiple deadlines. What did you do about it? | |
A. I will try to meet at least one deadline according to product priority. | |
Q. Tell me about a time you worked on a team with individuals from different cultural backgrounds. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<style> | |
p { | |
text-align: center; | |
font-size: 60px; | |
margin-top: 0px; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
TEMPLATES = [ | |
{ | |
'BACKEND': 'django.template.backends.django.DjangoTemplates', | |
'DIRS': [os.path.join(BASE_DIR, 'templates')], | |
'APP_DIRS': True, | |
'OPTIONS': { | |
'context_processors': [ | |
'django.template.context_processors.debug', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import connections, OperationalError | |
# Drop all tables from a given database | |
""" | |
python manage.py runscript clean_database_tables | |
""" | |
def run(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-> sudo su - postgres # To perform administrative tasks | |
-> password # Enter user password | |
-> psql # Log into a Postgres session | |
-> CREATE DATABASE db_name; | |
-> CREATE USER db_user WITH PASSWORD 'your_password'; | |
-> ALTER ROLE db_user SET client_encoding TO 'utf8'; | |
-> ALTER ROLE db_user SET default_transaction_isolation TO 'read committed'; | |
-> ALTER ROLE db_user SET timezone TO 'UTC'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# should not use | |
try: | |
Account.objects.get(username='testuser', password='test1234') | |
except ObjectDoesNotExist: | |
Account.objects.create(username='testuser', password='test1234') | |
# should use | |
try: | |
Account.objects.get_or_create(username='testuser', password='test1234') | |
except Exception as e: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def authentication_decorator(function): | |
def wrap(request, *args, **kwargs): | |
user_token = request.META.get('HTTP_AUTHORIZATION') | |
user_response, status_code = backend_obj.get_user(user_token) | |
if status_code == 200: | |
kwargs = user_response | |
return function(request, *args, **kwargs) | |
return wrap |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = { | |
"id": "124324", | |
"name": "testname", | |
"email": "[email protected]", | |
"password": "test1234" | |
} | |
def get_json_to_xml_data(data): | |
return f''' | |
<?xml version="1.0"?> |
NewerOlder