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 requests | |
| from bs4 import BeautifulSoup | |
| from urllib.parse import urljoin, urlparse | |
| def is_valid(url, base_url): | |
| parsed = urlparse(url) | |
| return bool(parsed.netloc) and parsed.netloc == urlparse(base_url).netloc | |
| def is_binary(url): |
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 langchain.chat_models import ChatOllama | |
| from langchain.callbacks.manager import CallbackManager | |
| from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler | |
| from langchain.schema import HumanMessage | |
| chat_model = ChatOllama(model="mistral", base_url = "http://localhost:11434", callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])) | |
| #chat_model = ChatOllama(model="mistral") | |
| messages = [ | |
| HumanMessage(content="Why is the sky blue?") |
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 sentence_transformers import SentenceTransformer | |
| model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2') | |
| embeddings = model.encode("A fat tuxedo cat") | |
| print(embeddings) |
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 sentence_transformers import SentenceTransformer, util | |
| model = SentenceTransformer('all-MiniLM-L6-v2') | |
| # Two lists of sentences | |
| sentences1 = ['The cat sits outside', | |
| 'A man is playing guitar', | |
| 'The new movie is awesome', | |
| 'Jim can run very fast', | |
| 'My goldfish is hungry'] |
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 boto3 | |
| def main(): | |
| organizations_client = boto3.client("organizations") | |
| list_accounts_object = organizations_client.list_accounts() | |
| all_accounts = [] | |
| accounts = list_accounts_object["Accounts"] | |
| while "NextToken" in list_accounts_object: |
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
| #!/usr/bin/python | |
| import os, socket, sys, time | |
| socket.setdefaulttimeout(10) | |
| start = time.time() | |
| subnets = ['140.107.42','140.107.43','140.107.88','140.107.89','140.107.134',\ | |
| '140.107.135','140.107.52','140.107.53','140.107.152','140.107.153',\ | |
| '140.107.170','140.107.171'] | |
| scanips = []; hosts = []; vhosts = []; free = []; vfree = []; reclaim = []; squatters = [] |
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
| #!/usr/bin/env python3 | |
| """ | |
| Alternate account naming rules | |
| Rule 1: firstname + lastname is less 18 or less characters long total | |
| == firstname + "." + lastname (john.doe) | |
| if conflict, check if rule 2 format (below) is available. If so use it | |
| == firstname_initial + "." + lastname (j.doe) | |
| if not, append an integer (starting with 2) to the end of the username | |
| === firstname + "." + lastname + int (john.doe2) |
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
| #!/usr/bin/env python3 | |
| """ | |
| Account naming rules | |
| Rule 1: firstname + lastname is less 18 or less characters long total | |
| == firstname + "." + lastname (john.doe) | |
| if conflict append an integer (starting with 2) to the end of the username | |
| === firstname + "." + lastname + int (john.doe2) | |
| Rule 2: firstname + lastname is greater than 18 characters long total *and* |
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 PIL import Image | |
| def main(): | |
| images = [[] for p in range(num_people)] | |
| im = Image.open(image) | |
| im = im.convert("RGB") | |
| size = im.size | |
| data = list(im.getdata()) | |
| for _ in range(int(len(data)/num_people)): |
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 math import sqrt | |
| from PIL import Image | |
| def main(): | |
| img = Image.open("contact-tracing.png") | |
| infected = get_color_coords(img, Ic) | |
| healthy = get_color_coords(img, Hc) | |
| contact = [] | |
| for i in infected: |