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
SELECT name, email, s.ip_addresses | |
FROM users u | |
LEFT JOIN ( | |
SELECT user_id, string_agg(ip_address, ',') "ip_addresses" | |
FROM site_visits | |
WHERE country in ('China') | |
and user_id = u.id | |
GROUP BY user_id | |
) s | |
ON u.id = s.user_id |
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 pay_bill(bill_type, meter_number, amount): | |
# we'll put the logic for how to process bill payment | |
# this could include validation rules, and service calls to complete pyment | |
pass |
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
# 1st call | |
median1 = find_median([40, 57, 12]) | |
print(f"median1 = {median1}") | |
# 2nd call | |
median2 = find_median([3, 13, 7, 5, 21, 23, 39, 23, 40, 23, 14, 12, 56, 23, 29]) | |
print(f"median1 = {median2}") | |
# 3rd call | |
median3 = find_median([3, 13, 7, 5, 21, 23, 23, 40, 23, 14, 12, 56, 23, 29]) |
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 math | |
def find_median(numbers=[]): | |
""" | |
Implementation details | |
Algorithm: | |
1. Reorder numbers in ascending order | |
2. Determine if the count of the numbers is even or odd | |
3. If odd, divide by 2 and round up the result. Look up the median using your result as the lookup index. Skip step 4 |
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 os | |
import hashlib | |
salt = os.urandom(32) | |
plaintext = 'hellow0rld'.encode() | |
digest = hashlib.pbkdf2_hmac('sha256', plaintext, salt, 10000) | |
hex_hash = digest.hex() | |
print(hex_hash) |
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
username | password_hash | |
---|---|---|
th0mas808 | 1455bc3fa6b863bf15b4dbd2eece56ed1f199130490297f6647135a9aebb534d | |
pl3th0ra | 4d416367f3f96a2c6053bf1622f9741f20519f9f7280a6b459318350820a83f9 | |
tiPsy | 2e3777b9010d07ed87a909cf7cef956923c8daf35cfcb8cca6da0ac60bddb4dd | |
GaryVee | 60b170c29d53ab11dc6a153dde5084de16e95062928e740e1f2d3e787fedc178 | |
Harry3080 | 169292d2966a24eb01d2002d378de26c9a5a85b2e27b49ebdb63583a114ff5f8 |
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 hashlib | |
plaintext = "hello".encode() | |
# instantiate sha3_256 object | |
d = hashlib.sha3_256(plaintext) | |
# generate binary bash of "hello" string | |
hash = d.digest() | |
print(hash) |
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 hashlib | |
plaintext = "hello".encode() | |
d = hashlib.sha256(plaintext) | |
# generate binary hash of "hello" string | |
hash = d.digest() | |
print(hash) | |
# generate human readable hash of "hello" string |
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
name | gender | age | phone_number | |
---|---|---|---|---|
Donetta Brody | Female | 24 | (770) 936-5965 | |
Otis Revell | Male | 52 | (202) 911-3723 | |
Retha Cottingham | Female | 24 | (299) 505-4199 | |
Tawanda Sandridge | Female | 22 | (488) 466-4899 | |
Ila Shingleton | Male | 24 | (391) 304-8813 | |
Latina Mateer | Female | 33 | (484) 726-1158 | |
Jerrold Villeda | Male | 32 | NULL | |
Jean Gruner | Female | 60 | NULL | |
Kecia Bollman | Female | 43 | NULL |
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
name | gender | age | phone_number | |
---|---|---|---|---|
Donetta Brody | Female | 24 | (770) 936-5965 | |
Otis Revell | Male | 52 | (202) 911-3723 | |
Retha Cottingham | Female | 24 | (299) 505-4199 | |
Tawanda Sandridge | Female | 22 | (488) 466-4899 | |
Ila Shingleton | Male | 24 | (391) 304-8813 | |
Latina Mateer | Female | 33 | (484) 726-1158 |