๐
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 | |
| supply = [50, 60, 50, 50] | |
| demand = [30, 20, 70, 30, 60] | |
| costs = [ | |
| [16, 16, 13, 22, 17], | |
| [14, 14, 13, 19, 15], | |
| [19, 19, 20, 23, 50], | |
| [50, 12, 50, 15, 11] |
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
| # Run this block to make sure you have the full GPU memory. | |
| # See https://medium.com/@oribarel/getting-the-most-out-of-your-google-colab-2b0585f82403. | |
| # memory footprint support libraries/code | |
| !ln -sf /opt/bin/nvidia-smi /usr/bin/nvidia-smi | |
| !pip install gputil | |
| !pip install psutil | |
| !pip install humanize | |
| import psutil | |
| import humanize |
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
| #@title <-- Tap this if you play on Mobile { display-mode: "form" } | |
| %%html | |
| <b>Press play on the music player to keep the tab alive, then start code below</b><br/> | |
| <audio src="https://raw.githubusercontent.com/KoboldAI/KoboldAI-Client/main/colab/silence.m4a" controls> |
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 tkinter as tk | |
| from tkinter import simpledialog | |
| class TabBar(tk.Canvas): | |
| def __init__(self, master): | |
| super().__init__(master, height=20, bg='grey', xscrollincrement=20) | |
| self.configure(highlightthickness=0) | |
| self.tabs_frame = tk.Frame(self, bg='grey') | |
| self.tabs_window = self.create_window((0, 0), window=self.tabs_frame, anchor="nw") |
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 tkinter as tk | |
| from tkinter import ttk | |
| from tkinter import NE, LEFT, RIGHT | |
| class ScrollableNotebook(ttk.Frame): | |
| def __init__(self, parent, *args, **kwargs): | |
| ttk.Frame.__init__(self, parent, *args) | |
| self.xLocation = 0 | |
| self.notebookContent = ttk.Notebook(self, **kwargs) | |
| self.notebookContent.pack(fill="both", expand=True) |
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 tkinter as tk | |
| from tkinter import ttk | |
| from tkinter import NE, LEFT, RIGHT | |
| class ScrollableNotebook(ttk.Frame): | |
| def __init__(self, parent, *args, **kwargs): | |
| ttk.Frame.__init__(self, parent, *args) | |
| self.xLocation = 0 | |
| self.notebookContent = ttk.Notebook(self, **kwargs) | |
| self.notebookContent.pack(fill="both", expand=True) |
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 tkinter as tk | |
| from tkinter import ttk | |
| tab_count = 1 | |
| def create_tab(): | |
| global tab_count # Access the global tab_count variable | |
| tab = ttk.Frame(notebook) | |
| notebook.add(tab, text=f"<Untitled> {tab_count}") # Use tab_count in the tab text | |
| text_widget = tk.Text(tab) |
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 pandas as pd | |
| import numpy as np | |
| import timeit | |
| import platform | |
| # Printing versions of python, numpy, etc | |
| python_version = platform.python_version() | |
| numpy_version = np.__version__ | |
| pandas_version = pd.__version__ |
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 sys | |
| import json | |
| import numpy as np | |
| def improved_default(data): | |
| """ | |
| Improved function to handle numpy data types for JSON serialization. | |
| Converts numpy integer and float types to their native Python counterparts. | |
| """ | |
| if isinstance(data, np.integer): |
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 osmnx as ox | |
| location = "Manhattan, New York City, New York, USA" | |
| # Mode can be 'drive', 'bike', 'walk', etc. | |
| G = ox.graph_from_place(location, network_type='drive') | |
| nodes, edges = ox.graph_to_gdfs(G) | |
| print(nodes.head()) | |
| print(edges.head()) |