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 machine import Pin,I2C,SPI,PWM,ADC | |
| import framebuf | |
| import time | |
| import math | |
| DC = 8 | |
| CS = 9 | |
| SCK = 10 | |
| MOSI = 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
| import requests | |
| import json | |
| import jwt | |
| from dotenv import dotenv_values | |
| def get_json(endpoint: str): | |
| response = requests.get(endpoint) | |
| response.raise_for_status() | |
| return json.loads(response.content) |
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
| public async Task<DataResponse> GetAsync(string uri, List<KeyValuePair<string, string>> formValues) { | |
| try { | |
| var auth = new AuthenticationHeaderValue("Basic", | |
| Convert.ToBase64String(Encoding.UTF8.GetBytes( | |
| $"{HttpUtility.UrlEncode(_clientId)}:{HttpUtility.UrlEncode(_clientSecret)}"))); | |
| var request = new HttpRequestMessage(HttpMethod.Post, uri) { | |
| Headers = { Authorization = auth }, | |
| Content = new FormUrlEncodedContent(formValues) | |
| }; | |
| using var response = await HttpClient.SendAsync(request); |
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 asyncio | |
| import aiohttp | |
| import time | |
| async def get(url, session): | |
| try: | |
| async with session.get(url=url) as response: | |
| resp = await response.read() | |
| print("Successfully got url {} with resp of length {}.".format(url, len(resp))) |
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
| # https://python.langchain.com/docs/modules/model_io/models/llms/integrations/llamacpp | |
| import os | |
| from langchain import PromptTemplate, LLMChain | |
| from langchain.llms import LlamaCpp | |
| from langchain import PromptTemplate, LLMChain | |
| from langchain.callbacks.manager import CallbackManager | |
| from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler | |
| template = """Question: {question} |
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.llms import GPT4All | |
| from langchain.vectorstores import Chroma | |
| from langchain.indexes import VectorstoreIndexCreator | |
| from langchain.indexes.vectorstore import VectorStoreIndexWrapper | |
| from langchain.document_loaders import DirectoryLoader, TextLoader, UnstructuredMarkdownLoader | |
| from langchain.chains import RetrievalQA | |
| import sys | |
| import os | |
| from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler | |
| from langchain.embeddings import HuggingFaceEmbeddings, SentenceTransformerEmbeddings |
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 requests | |
| import xml.etree.ElementTree as ET | |
| def get_current_weather(uri: str, client = requests) -> str: | |
| result = client.get(uri) | |
| weather = ET.ElementTree(ET.fromstring(result.text)).getroot().findall("./weather")[0].text | |
| return weather | |
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 simple_http_server import route, server | |
| from threading import Thread | |
| import spotipy | |
| from spotipy.oauth2 import SpotifyClientCredentials | |
| import spotipy | |
| from spotipy.oauth2 import SpotifyOAuth | |
| import os | |
| from simple_http_server import route, server | |
| @route("/") |
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
| using System; | |
| using System.IO; | |
| using System.Security.Cryptography; | |
| using System.Net.Http; | |
| // Server API Token key and secret are available from API token management dashboard when Server API Token is generated | |
| var key = "da28b6ec3ea350db524d80099f8c9f40f2fab2f4caf91a8d49d4cb4d659a9785"; | |
| var secret = "60a63916a77ef70c0ecf42b134f44fbb9732b395ae33dc6d5165aad2b5668bb4"; | |
| // include username prefixed with '=' |
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 puppeteer from "puppeteer"; | |
| (async () => { | |
| const browser = await puppeteer.launch({ headless: false }); | |
| const page = await browser.newPage(); | |
| await page.goto( | |
| "https://sfbay.craigslist.org/search/sby/sof#search=1~thumb~0~0" | |
| ); | |
| // Set screen size |
NewerOlder