row_id
int64
0
48.4k
init_message
stringlengths
1
342k
conversation_hash
stringlengths
32
32
scores
dict
43,876
in following code : sls = [0.01,0.015, 0.02, 0.025 ,0.03,0.035, 0.04,0.045, 0.05,0.055, 0.06,0.065, 0.07,0.075,0.08,0.085, 0.09,0.095, 0.1] tls = [0.01,0.015, 0.02, 0.025 ,0.03,0.035, 0.04,0.045, 0.05,0.055, 0.06,0.065, 0.07,0.075,0.08,0.085, 0.09,0.095, 0.1] hours_to_look = [24 ,48 , 72, 96, 120] symbols = pred_df[‘Symbol’].unique() current_symbol = ‘’ columns = [] for sl in sls: for tl in tls: for hours in hours_to_look: columns.add(f’{sl}{tl}{hours}') combined_columns = list(pred_df.columns) + columns all_results= [] for index, row in pred_df.iterrows(): date, symbol, start_price = row[‘Date’], row[‘Symbol’], row[‘Close’] row_result = [] if(symbol != current_symbol): hourly_path = find_first_matching_1h(symbol) hourly_df = pd.read_csv(hourly_path) hourly_df[‘Date’] = pd.to_datetime(hourly_df[‘Date’], format=“ISO8601”, utc=True) for sl in sls: for tl in tls: for hours in hours_to_look: result = analyze_price_move(date, start_price,sl,tl,hourly_df) row_result.add(result) all_results.add(row_result) i want to add calculated rows and columns to my pred_df
e864c2aa62d12deb14aad8ff2cd36199
{ "intermediate": 0.4141125977039337, "beginner": 0.2661256194114685, "expert": 0.31976184248924255 }
43,877
import base64 import acrcloud import os import eyed3 import eyed3.id3.frames from eyed3.id3.frames import UserTextFrame import requests import json import re from my_shazam_utility import shazam_recognize_song from applemusic_api import AppleMusicApi from Acrcloudretrieve import recognize_song, set_id3_tags_mp3 from Retrieve_lyrics import get_lyrics from erhalten_alb_covers import save_and_embed_album_cover def load_config(): with open(‘D:/Eurydice/Encompassing Data by discerning/config/config.json’, ‘r’) as config_file: config_data = json.load(config_file) return config_data # Load the configuration on script start config = load_config() # Now also load Spotify credentials CLIENT_ID = config[‘Spotify’][‘CLIENT_ID’] CLIENT_SECRET = config[‘Spotify’][‘CLIENT_SECRET’] def get_user_choice(): # Display a header print(“=” * 50) print(“Welcome to the Song Recognition Service!”) print(“=” * 50) # Provide instructions and options print(“\nPlease select the recognition service you’d like to use:\n”) print(" 1: YoutubeACR - Fast and accurate music recognition") print(" 2: Shazam - Discover music, artists, and lyrics in seconds") # Separator for aesthetic purposes print(“-” * 50) # Input prompt choice = input(“Enter your choice (1 or 2) and press Enter: “) # More flair to indicate processing/input received print(”\n” + “.” * 25 + " Processing " + “.” * 25 + “\n”) return choice def add_or_update_txxx_frame(audiofile, description, value): found = False frames = audiofile.tag.frame_set.get(eyed3.id3.frames.USERTEXT_FID, []) for frame in frames: if frame.description == description: frame.text = value found = True break if not found: # Create a new TXXX frame without specifying encoding new_frame = eyed3.id3.frames.UserTextFrame(description=description, text=value) # Previously: When encoding was being passed # Now: Encoding isn’t specified as it’s not required or not supported based on the error if not frames: # If it’s the first frame of this type audiofile.tag.frame_set[eyed3.id3.frames.USERTEXT_FID] = [new_frame] else: frames.append(new_frame) # Append to exisiting list of USERTEXT frames # Your Spotify authentication and song search functions: def authenticate_spotify(client_id, client_secret): auth_url = ‘https://accounts.spotify.com/api/token’ client_creds = f"{client_id}:{client_secret}“ client_creds_b64 = base64.b64encode(client_creds.encode()) headers = {‘Authorization’: f’Basic {client_creds_b64.decode()}‘} data = {‘grant_type’: ‘client_credentials’} response = requests.post(auth_url, headers=headers, data=data) access_token = response.json().get(‘access_token’) return access_token def search_spotify_for_song(access_token, artist_name, title): base_url = “https://api.spotify.com/v1/search” query = f”{title} artist:{artist_name}“ headers = {“Authorization”: f"Bearer {access_token}”} params = {“q”: query, “type”: “track”, “limit”: 1} response = requests.get(base_url, headers=headers, params=params) results = response.json() try: track_info = results[‘tracks’][‘items’][0] return track_info except IndexError: print(“Song not found on Spotify.”) return None def get_high_quality_album_art_url(song_info): images = song_info[‘album’][‘images’] # Get the list of image dicts if not images: return None # No images available # Sort the images by size, pick the largest highest_quality_image = max(images, key=lambda x: x[‘width’]x[‘height’]) return highest_quality_image[‘url’] def save_high_quality_album_art(image_url, file_path): try: response = requests.get(image_url, stream=True) if response.status_code == 200: with open(file_path, ‘wb’) as out_file: for chunk in response.iter_content(1024): out_file.write(chunk) print(f"High quality album art saved: {file_path}“) return True # Indicate success else: print(“Could not download the album art.”) except Exception as e: print(f"Error saving high-quality album art: {e}”) return False # Indicate failure def embed_album_art_to_song(file_path, image_path): try: audiofile = eyed3.load(file_path) if audiofile.tag is None: # If the file has no tags, create a new tag audiofile.initTag() with open(image_path, ‘rb’) as img_file: audiofile.tag.images.set(3, img_file.read(), ‘image/jpeg’) audiofile.tag.save() print(“High quality album art embedded into song.”) except FileNotFoundError: print(f"Failed to embed album art - No such file: {image_path}“) def process_audio_file_with_spotify_search(audio_file_path): shazam_data = shazam_recognize_song(audio_file_path) if shazam_data: artist_name = shazam_data[‘track’][‘subtitle’] title = shazam_data[‘track’][‘title’] print(f"Identified Song: {artist_name} - {title}”) access_token = authenticate_spotify(CLIENT_ID, CLIENT_SECRET) song_info = search_spotify_for_song(access_token, artist_name, title) if song_info: print(json.dumps(song_info, indent=4)) # For debugging print(“\n///////////////////////////////\n”) album_name = song_info[‘album’][‘name’] album_url = song_info[‘album’][‘external_urls’][‘spotify’] track_number = song_info[‘track_number’] release_date = song_info[‘album’][‘release_date’] isrc = song_info.get(‘external_ids’, {}).get(‘isrc’, “Not Available”) label = song_info[‘label’] if ‘label’ in song_info else “Not Available” explicit = str(song_info[‘explicit’]) if ‘explicit’ in song_info else “Not Available” # Convert to string genres = “, “.join(song_info[‘genres’]) if ‘genres’ in song_info else “Not Available” author_url = song_info[‘artists’][0][‘external_urls’][‘spotify’] if ‘artists’ in song_info else “Not Available” spotify_url = song_info[‘external_urls’][‘spotify’] print(f"Track Number on Spotify: {track_number}”) audiofile = eyed3.load(audio_file_path) if audiofile.tag is None: # If the file has no tags, create a new tag audiofile.initTag(version=eyed3.id3.ID3_V2_3) # Set standard tags audiofile.tag.artist = artist_name audiofile.tag.album = album_name audiofile.tag.album_artist = artist_name audiofile.tag.title = title audiofile.tag.recording_date = release_date # Using helper function to add or update TXXX frames add_or_update_txxx_frame(audiofile, “Album URL”, album_url) add_or_update_txxx_frame(audiofile, “Eurydice”, “True”) add_or_update_txxx_frame(audiofile, “Compilation”, “KK”) add_or_update_txxx_frame(audiofile, “Genre”, genres) add_or_update_txxx_frame(audiofile, “Author URL”, author_url) add_or_update_txxx_frame(audiofile, “Label”, label) add_or_update_txxx_frame(audiofile, “Explicit”, explicit) add_or_update_txxx_frame(audiofile, “ISRC”, isrc) add_or_update_txxx_frame(audiofile, “Spotify URL”, spotify_url) audiofile.tag.comments.set(f"ISRC: {isrc}, Label: {label}, Explicit: {explicit}”) audiofile.tag.save() # Save the metadata to the file print(f"Metadata embedded into the file: {audio_file_path}“) # Fetch high-quality album art URL high_res_image_url = get_high_quality_album_art_url(song_info) if high_res_image_url: # Determine paths image_file_path = os.path.splitext(audio_file_path)[0] + “.jpg” # Save and embed album art if save_high_quality_album_art(high_res_image_url, image_file_path): embed_album_art_to_song(audio_file_path, image_file_path) else: print(“Skipping album art embed due to download failure.”) else: print(“No album art available.”) new_file_name = f”{track_number:02d}. {artist_name} - {album_name} - {isrc}.mp3" new_file_name = re.sub(r’[/:?“<>|]’, ‘’, new_file_name) # Clean up characters not allowed in file names new_file_path = os.path.join(os.path.dirname(audio_file_path), new_file_name) os.rename(audio_file_path, new_file_path) # Rename file print(f"File has been renamed to: {new_file_name}”) else: print(“Song not found on Spotify.”) else: print(“Song could not be identified.”) if name == “main”: user_choice = get_user_choice() audio_file_path = ‘D:/Eurydice/Encompassing Data by discerning/Test_file/Unknown_file.mp3’ if user_choice == ‘1’: print(“\n” + “.” * 15 + " ᴜsɪɴɢ YᴏᴜᴛᴜʙᴇACR " + “.” * 15 + “\n”) song_tags = recognize_song(audio_file_path) if song_tags: print(f’Song identified: {song_tags}‘) set_id3_tags_mp3(audio_file_path, song_tags) artist_name = song_tags.get(‘artists’)[0].get(‘name’) song_title = song_tags.get(‘title’) safe_artist_name = re.sub(r’[/:?“<>|]‘, ‘’, artist_name) safe_song_title = re.sub(r’[/:?”<>|]', ‘’, song_title) new_file_name = f"{safe_artist_name} - {safe_song_title}.mp3" new_file_path = os.path.join(os.path.dirname(audio_file_path), new_file_name) os.rename(audio_file_path, new_file_path) print(f"File has been renamed to: {new_file_name}“) else: print(‘Could not identify the song in YᴏᴜᴛᴜʙᴇACR.’) apple_music_api = AppleMusicApi(Exception) # Initialize AppleMusicApi with necessary authentication apple_music_api.get_access_token() track_results = apple_music_api.search(‘songs’, f”{artist_name} - {song_title}“) if track_results: track_id = track_results[0][‘id’] album_artwork_url_template = track_results[0][‘attributes’][‘artwork’][‘url’] save_and_embed_album_cover(new_file_path, artist_name, song_title, album_artwork_url_template) else: print(“Song not found on Apple Music.”) lrc_lyrics = get_lyrics(safe_artist_name, safe_song_title) if lrc_lyrics: lrc_file_path = os.path.join(os.path.dirname(audio_file_path), f”{safe_artist_name} - {safe_song_title}.lrc") with open(lrc_file_path, ‘w’, encoding=‘utf-8’) as lrc_file: lrc_file.write(lrc_lyrics) print(f"Saved LRC file to: {lrc_file_path}“) else: print(“Could not get the lyrics.”) elif user_choice == ‘2’: print(”\n" + “.” * 15 + " ᴜsɪɴɢ Sʜᴀᴢᴀᴍ " + “.” * 15 + “\n”) song_tags = shazam_recognize_song(audio_file_path) print(song_tags) process_audio_file_with_spotify_search(audio_file_path) else: print(“Invalid choice. Exiting…”) exit() after embedding the album art just change the name to track number - artist name - album name - isrc also download the lyric file and after saving externally, change the file name develop separate lyrics function for option 2 to fetch from spotify and dont touch acrcloud
30149c1aae961cc3b3a36a12e2ffdb79
{ "intermediate": 0.46537768840789795, "beginner": 0.44075390696525574, "expert": 0.09386839717626572 }
43,878
import base64 import acrcloud import os import eyed3 import eyed3.id3.frames from eyed3.id3.frames import UserTextFrame import requests import json import re from my_shazam_utility import shazam_recognize_song from applemusic_api import AppleMusicApi from Acrcloudretrieve import recognize_song, set_id3_tags_mp3 from Retrieve_lyrics import get_lyrics from erhalten_alb_covers import save_and_embed_album_cover def load_config(): with open(‘D:/Eurydice/Encompassing Data by discerning/config/config.json’, ‘r’) as config_file: config_data = json.load(config_file) return config_data # Load the configuration on script start config = load_config() # Now also load Spotify credentials CLIENT_ID = config[‘Spotify’][‘CLIENT_ID’] CLIENT_SECRET = config[‘Spotify’][‘CLIENT_SECRET’] def get_user_choice(): # Display a header print(“=” * 50) print(“Welcome to the Song Recognition Service!”) print(“=” * 50) # Provide instructions and options print(“\nPlease select the recognition service you’d like to use:\n”) print(" 1: YoutubeACR - Fast and accurate music recognition") print(" 2: Shazam - Discover music, artists, and lyrics in seconds") # Separator for aesthetic purposes print(“-” * 50) # Input prompt choice = input(“Enter your choice (1 or 2) and press Enter: “) # More flair to indicate processing/input received print(”\n” + “.” * 25 + " Processing " + “.” * 25 + “\n”) return choice def add_or_update_txxx_frame(audiofile, description, value): found = False frames = audiofile.tag.frame_set.get(eyed3.id3.frames.USERTEXT_FID, []) for frame in frames: if frame.description == description: frame.text = value found = True break if not found: # Create a new TXXX frame without specifying encoding new_frame = eyed3.id3.frames.UserTextFrame(description=description, text=value) # Previously: When encoding was being passed # Now: Encoding isn’t specified as it’s not required or not supported based on the error if not frames: # If it’s the first frame of this type audiofile.tag.frame_set[eyed3.id3.frames.USERTEXT_FID] = [new_frame] else: frames.append(new_frame) # Append to exisiting list of USERTEXT frames # Your Spotify authentication and song search functions: def authenticate_spotify(client_id, client_secret): auth_url = ‘https://accounts.spotify.com/api/token’ client_creds = f"{client_id}:{client_secret}“ client_creds_b64 = base64.b64encode(client_creds.encode()) headers = {‘Authorization’: f’Basic {client_creds_b64.decode()}‘} data = {‘grant_type’: ‘client_credentials’} response = requests.post(auth_url, headers=headers, data=data) access_token = response.json().get(‘access_token’) return access_token def search_spotify_for_song(access_token, artist_name, title): base_url = “https://api.spotify.com/v1/search” query = f”{title} artist:{artist_name}“ headers = {“Authorization”: f"Bearer {access_token}”} params = {“q”: query, “type”: “track”, “limit”: 1} response = requests.get(base_url, headers=headers, params=params) results = response.json() try: track_info = results[‘tracks’][‘items’][0] return track_info except IndexError: print(“Song not found on Spotify.”) return None def get_high_quality_album_art_url(song_info): images = song_info[‘album’][‘images’] # Get the list of image dicts if not images: return None # No images available # Sort the images by size, pick the largest highest_quality_image = max(images, key=lambda x: x[‘width’]x[‘height’]) return highest_quality_image[‘url’] def save_high_quality_album_art(image_url, file_path): try: response = requests.get(image_url, stream=True) if response.status_code == 200: with open(file_path, ‘wb’) as out_file: for chunk in response.iter_content(1024): out_file.write(chunk) print(f"High quality album art saved: {file_path}“) return True # Indicate success else: print(“Could not download the album art.”) except Exception as e: print(f"Error saving high-quality album art: {e}”) return False # Indicate failure def embed_album_art_to_song(file_path, image_path): try: audiofile = eyed3.load(file_path) if audiofile.tag is None: # If the file has no tags, create a new tag audiofile.initTag() with open(image_path, ‘rb’) as img_file: audiofile.tag.images.set(3, img_file.read(), ‘image/jpeg’) audiofile.tag.save() print(“High quality album art embedded into song.”) except FileNotFoundError: print(f"Failed to embed album art - No such file: {image_path}“) def process_audio_file_with_spotify_search(audio_file_path): shazam_data = shazam_recognize_song(audio_file_path) if shazam_data: artist_name = shazam_data[‘track’][‘subtitle’] title = shazam_data[‘track’][‘title’] print(f"Identified Song: {artist_name} - {title}”) access_token = authenticate_spotify(CLIENT_ID, CLIENT_SECRET) song_info = search_spotify_for_song(access_token, artist_name, title) if song_info: print(json.dumps(song_info, indent=4)) # For debugging print(“\n///////////////////////////////\n”) album_name = song_info[‘album’][‘name’] album_url = song_info[‘album’][‘external_urls’][‘spotify’] track_number = song_info[‘track_number’] release_date = song_info[‘album’][‘release_date’] isrc = song_info.get(‘external_ids’, {}).get(‘isrc’, “Not Available”) label = song_info[‘label’] if ‘label’ in song_info else “Not Available” explicit = str(song_info[‘explicit’]) if ‘explicit’ in song_info else “Not Available” # Convert to string genres = “, “.join(song_info[‘genres’]) if ‘genres’ in song_info else “Not Available” author_url = song_info[‘artists’][0][‘external_urls’][‘spotify’] if ‘artists’ in song_info else “Not Available” spotify_url = song_info[‘external_urls’][‘spotify’] print(f"Track Number on Spotify: {track_number}”) audiofile = eyed3.load(audio_file_path) if audiofile.tag is None: # If the file has no tags, create a new tag audiofile.initTag(version=eyed3.id3.ID3_V2_3) # Set standard tags audiofile.tag.artist = artist_name audiofile.tag.album = album_name audiofile.tag.album_artist = artist_name audiofile.tag.title = title audiofile.tag.recording_date = release_date # Using helper function to add or update TXXX frames add_or_update_txxx_frame(audiofile, “Album URL”, album_url) add_or_update_txxx_frame(audiofile, “Eurydice”, “True”) add_or_update_txxx_frame(audiofile, “Compilation”, “KK”) add_or_update_txxx_frame(audiofile, “Genre”, genres) add_or_update_txxx_frame(audiofile, “Author URL”, author_url) add_or_update_txxx_frame(audiofile, “Label”, label) add_or_update_txxx_frame(audiofile, “Explicit”, explicit) add_or_update_txxx_frame(audiofile, “ISRC”, isrc) add_or_update_txxx_frame(audiofile, “Spotify URL”, spotify_url) audiofile.tag.comments.set(f"ISRC: {isrc}, Label: {label}, Explicit: {explicit}”) audiofile.tag.save() # Save the metadata to the file print(f"Metadata embedded into the file: {audio_file_path}“) # Fetch high-quality album art URL high_res_image_url = get_high_quality_album_art_url(song_info) if high_res_image_url: # Determine paths image_file_path = os.path.splitext(audio_file_path)[0] + “.jpg” # Save and embed album art if save_high_quality_album_art(high_res_image_url, image_file_path): embed_album_art_to_song(audio_file_path, image_file_path) else: print(“Skipping album art embed due to download failure.”) else: print(“No album art available.”) new_file_name = f”{track_number:02d}. {artist_name} - {album_name} - {isrc}.mp3" new_file_name = re.sub(r’[/:?“<>|]’, ‘’, new_file_name) # Clean up characters not allowed in file names new_file_path = os.path.join(os.path.dirname(audio_file_path), new_file_name) os.rename(audio_file_path, new_file_path) # Rename file print(f"File has been renamed to: {new_file_name}”) else: print(“Song not found on Spotify.”) else: print(“Song could not be identified.”) if name == “main”: user_choice = get_user_choice() audio_file_path = ‘D:/Eurydice/Encompassing Data by discerning/Test_file/Unknown_file.mp3’ if user_choice == ‘1’: print(“\n” + “.” * 15 + " ᴜsɪɴɢ YᴏᴜᴛᴜʙᴇACR " + “.” * 15 + “\n”) song_tags = recognize_song(audio_file_path) if song_tags: print(f’Song identified: {song_tags}‘) set_id3_tags_mp3(audio_file_path, song_tags) artist_name = song_tags.get(‘artists’)[0].get(‘name’) song_title = song_tags.get(‘title’) safe_artist_name = re.sub(r’[/:?“<>|]‘, ‘’, artist_name) safe_song_title = re.sub(r’[/:?”<>|]', ‘’, song_title) new_file_name = f"{safe_artist_name} - {safe_song_title}.mp3" new_file_path = os.path.join(os.path.dirname(audio_file_path), new_file_name) os.rename(audio_file_path, new_file_path) print(f"File has been renamed to: {new_file_name}“) else: print(‘Could not identify the song in YᴏᴜᴛᴜʙᴇACR.’) apple_music_api = AppleMusicApi(Exception) # Initialize AppleMusicApi with necessary authentication apple_music_api.get_access_token() track_results = apple_music_api.search(‘songs’, f”{artist_name} - {song_title}“) if track_results: track_id = track_results[0][‘id’] album_artwork_url_template = track_results[0][‘attributes’][‘artwork’][‘url’] save_and_embed_album_cover(new_file_path, artist_name, song_title, album_artwork_url_template) else: print(“Song not found on Apple Music.”) lrc_lyrics = get_lyrics(safe_artist_name, safe_song_title) if lrc_lyrics: lrc_file_path = os.path.join(os.path.dirname(audio_file_path), f”{safe_artist_name} - {safe_song_title}.lrc") with open(lrc_file_path, ‘w’, encoding=‘utf-8’) as lrc_file: lrc_file.write(lrc_lyrics) print(f"Saved LRC file to: {lrc_file_path}“) else: print(“Could not get the lyrics.”) elif user_choice == ‘2’: print(”\n" + “.” * 15 + " ᴜsɪɴɢ Sʜᴀᴢᴀᴍ " + “.” * 15 + “\n”) song_tags = shazam_recognize_song(audio_file_path) print(song_tags) process_audio_file_with_spotify_search(audio_file_path) else: print(“Invalid choice. Exiting…”) exit() after embedding the album art just change the name to track number - artist name - album name - isrc
cc2c59a329c6c68803614887ab7944d1
{ "intermediate": 0.46537768840789795, "beginner": 0.44075390696525574, "expert": 0.09386839717626572 }
43,879
import acrcloud import os import eyed3 import requests import json from acrcloud.recognizer import ACRCloudRecognizer from bs4 import BeautifulSoup # ACRCloud API credentials ACR_HOST = "" ACR_ACCESS_KEY = "" ACR_ACCESS_SECRET = "" # Genius API access token GENIUS_ACCESS_TOKEN = "" # ACR Cloud setup config = { 'host': ACR_HOST, 'access_key': ACR_ACCESS_KEY, 'access_secret': ACR_ACCESS_SECRET, 'timeout': 10 # seconds } dir(acrcloud) # Initialize the ACRCloud recognizer recognizer = ACRCloudRecognizer(config) # Function to recognize the song from an audio file def recognize_song(audio_file_path): buffer = open(audio_file_path, 'rb').read() result = recognizer.recognize_by_filebuffer(buffer, 0) try: result_dict = json.loads(result) # Parse the JSON string into a dictionary return result_dict['metadata']['music'][0] except (KeyError, IndexError, json.JSONDecodeError) as e: print(f"Error while parsing result: {e}") return None # Function to get lyrics from Genius # Function to get lyrics from Genius def get_lyrics_from_genius(song_title, artist_name): base_url = "https://api.genius.com" headers = {'Authorization': f'Bearer {GENIUS_ACCESS_TOKEN}'} search_url = base_url + "/search" data = {'q': f"{song_title} {artist_name}"} params = {'text_format': 'plain'} # Filter out unnecessary information response = requests.get(search_url, params=params, data=data, headers=headers) if response.ok: # Grab the first song from the results search_response = response.json() hit_list = search_response['response']['hits'] if hit_list: # Extract the API path for the top hit lyrics song_api_path = hit_list[0]['result']['api_path'] # Now we access the actual lyrics song_url = base_url + song_api_path song_response = requests.get(song_url, headers=headers) if song_response.ok: song_info = song_response.json() lyrics_path = song_info['response']['song']['path'] # Construct the URL for the lyrics page lyrics_page_url = "https://genius.com" + lyrics_path page = requests.get(lyrics_page_url) # Use BeautifulSoup (or similar) to scrape the lyrics html = BeautifulSoup(page.text, "html.parser") # This will vary depending on the site's layout at the time you check. # You need to inspect the page to find the correct container for the lyrics. # For instance, if lyrics reside within a <p> tag within a <div> with a class like 'lyric-box', you may use: # Modify this selector based on the actual structure of the Genius lyrics page. lyrics_div = html.find("div", class_="lyrics") if lyrics_div: # Join all paragraphs within the lyrics division (if structured as such) lyrics_p_tags = lyrics_div.find_all("p") lyrics = "\n".join(p_tag.get_text(strip=True) for p_tag in lyrics_p_tags) return lyrics else: print("Couldn't find the lyrics division.") return None else: print("Couldn't fetch the song info from Genius.") return None else: print("No search hits on Genius for the provided song title and artist name.") return None else: print("Search request to Genius failed.") return None # Function to set ID3 tags def set_id3_tags_mp3(audio_file_path, tags): audio_file = eyed3.load(audio_file_path) if not audio_file.tag: audio_file.initTag() audio_file.tag.artist = tags.get('artists')[0].get('name') audio_file.tag.album = tags.get('album').get('name') audio_file.tag.album_artist = tags.get('artists')[0].get('name') audio_file.tag.title = tags.get('title') # Set the release year (if available) release_date = tags.get('release_date') if release_date and len(release_date) >= 4: # Check if release_date contains at least the year year_string = release_date[:4] try: year = int(year_string) # Some versions of eyeD3 require a Date object if available if hasattr(eyed3.id3.tag, 'Date'): audio_file.tag.recording_date = eyed3.id3.tag.Date(year) else: # Otherwise, set it as text_frame audio_file.tag.setTextFrame("TDRC", year_string) except ValueError: print(f"Invalid date format in the tag: {release_date}") # Add more tags here audio_file.tag.genre = tags.get('genres')[0].get('name') # Assuming there's at least one genre audio_file.tag.publisher = "Karthik" # Publisher tag set as 'karthik' # To save the copyright label: audio_file.tag.copyright = tags.get('label', '') # To save the album cover page, you would need to download the image from a source # and then do something like this: # with open("path_to_cover_image.jpg", "rb") as album_art: # audio_file.tag.images.set(3, album_art.read(), "image/jpeg", u"Description") # Example of setting explicit tag in the comments (if you have explicit info): audio_file.tag.comments.set(u"Explicit: Yes") audio_file.tag.save(version=eyed3.id3.ID3_V2_3) audio_file.tag.save() # Replace 'path_to_your_audio_file.mp3' with the actual file path of the unknown song if __name__ == "__main__": audio_file_path = 'C:/Users/ILEG-i5-11/Downloads/Music/Unknown_file.mp3' song_tags = recognize_song(audio_file_path) if song_tags: print(f'Song identified: {song_tags}') set_id3_tags_mp3(audio_file_path, song_tags) # Renaming the file after identifying the song and setting tags artist_name = song_tags.get('artists')[0].get('name') song_title = song_tags.get('title') lyrics = get_lyrics_from_genius(song_title, artist_name) if lyrics: lrc_file_name = f"{artist_name} - {song_title}.lrc" with open(lrc_file_name, 'w', encoding='utf-8') as lrc_file: lrc_file.write(lyrics) print(f"Lyrics saved to {lrc_file_name}") else: print("Could not fetch the lyrics.") if artist_name and song_title: new_file_name = f"{artist_name} - {song_title}.mp3" new_file_path = os.path.join(os.path.dirname(audio_file_path), new_file_name) os.rename(audio_file_path, new_file_path) print(f"File has been renamed to: {new_file_name}") else: print('Could not identify the song.') (myenv) C:\Users\ILEG-i5-11\Downloads\Compressed\MyProj\Duplicate>python dupwillitwork.py Song identified: {'db_begin_time_offset_ms': 0, 'db_end_time_offset_ms': 9140, 'sample_begin_time_offset_ms': 0, 'sample_end_time_offset_ms': 9140, 'play_offset_ms': 9600, 'result_from': 3, 'label': 'UMG - Island Records', 'external_metadata': {'spotify': {'album': {'name': 'This Is Heaven', 'id': '0ssKKiPvCwNu8gvvUxYfgd'}, 'artists': [{'id': '4Rxn7Im3LGfyRkY2FlHhWi', 'name': 'Nick Jonas'}], 'track': {'id': '7oAly6qQFPu1JhmlE2Vujg', 'name': 'This Is Heaven'}}, 'youtube': {'vid': 'nMTgmsCkF8g'}, 'deezer': {'album': {'name': ''}, 'artists': [{'name': 'Nick Jonas', 'id': 614386}], 'track': {'id': '1264313532', 'name': 'This Is Heaven'}}}, 'score': 100, 'acrid': 'd81258c21ee5ac9459cbf6f652410026', 'external_ids': {'isrc': 'USUM72102471', 'upc': '00602435912462'}, 'release_date': '2021-03-04', 'artists': [{'langs': [{'code': 'ja-Hrkt', 'name': 'ニック・ジョナス'}, {'code': 'ja-Jpan', 'name': 'ニック・ジョナス'}], 'name': 'Nick Jonas'}], 'genres': [{'name': 'Pop'}], 'title': 'This Is Heaven', 'album': {'name': 'This Is Heaven'}, 'duration_ms': 214000} Couldn't find the lyrics division. Could not fetch the lyrics. File has been renamed to: Nick Jonas - This Is Heaven.mp3
1e039153fdeef5dd21df502c9fda3fd5
{ "intermediate": 0.4377012550830841, "beginner": 0.429300993680954, "expert": 0.1329978108406067 }
43,880
In a reaper lua script, I’m trying to optimize a script. How do I check if the current selected media items are the same as the previous selected media items (and that check is inside a defered function)?
b68216e6766d4256424f7eec28ba474c
{ "intermediate": 0.41525012254714966, "beginner": 0.2297145426273346, "expert": 0.35503533482551575 }
43,881
I would like some help creating a magic item for D&D 5e. The concept is that this item will grant a +1, +2, +3 bonus to attack and damage rolls for any weapon that is manifest, conjured or summoned by a class feature but that also does not have its own scaling bonus with level. For example, the soulknife Rogue subclass has an ability to manifest a Psychic Blade, but that weapon never gets any better as the character levels up Here is the class feature for reference:
d76a3cdc0e48c29e6d3497a5fde3b8cc
{ "intermediate": 0.34414952993392944, "beginner": 0.5059323310852051, "expert": 0.14991812407970428 }
43,882
Explain what this github repo is about like i am a layperson: ""Incident description The Github.com website experienced a data breach. Over 265 thousand email addresses were exposed, together with credential, personal, location and employment data. Leaked records include username, name, location, company name, Parent email address and bio. The validity of the data exposed couldn’t be verified. Yet we’re still informing you about a potential data breach – but keep in mind there’s a chance of it being a false positive. No. of exposed accounts 265,160 Exposed data Location Name Username Email Company name Bio Alternate email Powered by Safety warning: This website has been breached or has been part of a data leak. Skip to content e-p-armstrong / augmentoolkit Type / to search Code Issues 1 Pull requests Actions Projects Security Insights Owner avatar augmentoolkit Public e-p-armstrong/augmentoolkit Go to file t Add file Folders and files Name Latest commit e-p-armstrong e-p-armstrong openai api fix ab2f839 · 3 days ago History assistant_mode_output_examples Assistant mode + completion mode bugfix applied 3 weeks ago augmentoolkit openai api fix 3 days ago example_generated_convs cleanup and add readme and generate dataset and polish last month prompts Assistant mode + completion mode bugfix applied 3 weeks ago raw_txt_input bugfix in card generation last month test_prompt_overrides_do_not_recommend_using documentation changes, more shilling last month .gitignore gitignore update 4 days ago LICENSE Create LICENSE 2 months ago README.md Update README.md 3 weeks ago Simple Sabotage, by the Office of Strategic Services, published 1944.txt bugfix in card generation last month __init__.py first functional release; multiturn generation works 3 months ago augmentoolkit_mascot.png add images 2 months ago changetext.jpg add images 2 months ago comment_out.jpg add images 2 months ago config.yaml openai api fix 3 days ago config_file_change_text.png update some documentation and remove some clutter last month config_file_screenshot.png update some documentation and remove some clutter last month convert_pdf_to_text.py run black and add file loader and combiner 2 months ago convert_text_to_jsonl.py fixed sharegpt format 3 days ago financialaccounting.txt bugfix in card generation last month flowchart.jpg add images 2 months ago image-1.png documentation changes, more shilling last month image.png documentation changes, more shilling last month processing.ipynb fixed sharegpt format 3 days ago processing.py update readme and run black last month requirements.txt update requirements last month specialinstructions.jpg minor changes 2 months ago specialinstructions.png update some documentation and remove some clutter last month step1.jpg add images 2 months ago step2.jpg add images 2 months ago step3.jpg add images 2 months ago Repository files navigation README MIT license Augmentoolkit — infinite domain-specific instruct data Turn any raw text into a high-quality dataset using local models. Make data gathering a painless step of the model creation process. Augmentoolkit is the easy-to-use, customizable, open-source, and cost-effective data generation solution. No OpenAI needed. Augmentoolkit now supports APIs offering open-source models, such as Mistral, Together.ai or Groq (and also the OpenAI API if you really want it). You don't need to have a fancy computer to make awesome datasets, and you don't have to screw around with dependencies and CUDA. The free credits from a service like Together.ai should be able to sustain the creation of even a decent-sized dataset. Data generation is also blazingly-fast (and async) when using APIs. Of course, you can still use local models, if you prefer that and have the compute to support it. They run async too, thanks to the Aphrodite engine made by the people at Pygmalion (thanks Alpin for the tech support). Demo video: in-progress Join A Discord for Dataset Generation! MrDragonFox -- one of the moderators of the Mistral and TheBloke Discords -- has a server where he's working on a new quantization engine. There's a corner to discuss Augmentoolkit there! Come check it out and connect at https://discord.com/invite/foxengine-ai! Table of Contents: Self-promotion Installation Introduction Quickstart Neat Features Customization (important) Hardcore, in-depth Concept Explanation Concepts and Operation Understanding What is Going On as It Runs The Format of the Output Data Think this is cool? Connect with me elsewhere! For Businesses I work with AI SAAS startups that want to create (or improve) specialized LLMs using lots of quality training data. Do you need a dataset for your business's AI? I can modify Augmentoolkit for any domain and for tasks beyond question answering, and I'd be happy to help you painlessly create the data — and data-creation tools — you require. Given that I made the original version of the darn thing, I'm probably the best person in the world for this task. You can schedule a quick call to talk about your needs with me using this Calendly link: https://calendly.com/evanpeterarmstrong/discovery-call. Note The base version Augmentoolkit is fully open sourced and MIT-licensed. The consulting option is for people who want a bespoke modification and quality results, fast (it took 5 months of learning and iteration for me to master open source model pipelines enough to make Augmentoolkit work well). If you're a hobbyist and have time to experiment with its base version for casual or personal uses, by all means go for it. New Features At A Glance Runs Async with any LLM API (together, openrouter, mistral) that's compatible with the OpenAI python library A Python Script FAST: when using APIs, some datasets can be generated in under an hour, for <$10 Options set in an easy-to-use YAML file, config.py. No more modifying code to change configuration. Supports both chat and completion prompts No More Clutter: output and raw text input paths configurable in the config file Easily switch between prompts by changing prompt folder paths. If a prompt is not found in the new folder it will fall back to the old one (the path to which is also configurable) A complete code refactor that makes customization much easier. No more editing prompts inside Python files, no more messing with control flow logic directly inside a Jupyter notebook. No switching between branches to use different methods of generation: switch between APIs and Aphrodite by changing the config file. A (non-professional, roleplay-focused) Augmentoolkit dataset demonstration can be found at https://huggingface.co/datasets/Heralax/Augmentoolkit-demo/tree/main. It's from an older version of the pipeline that had a few bugs, but it helps you get the idea of what's possible, and proves that it produces quality stuff. Now, with many bugfixes and APIs that offer full-precision models, quality can be even higher. If you're wondering if this tool takes files in [insert your format here] then I would recommend looking up a tool for converting that file format to plain text. For instance, with epub files, you might use this. Installation: Augmentoolkit, at its simplest, requires only the OpenAI API library (open source model providers use the OAI library too). So there is not much here besides cloning this repo and installing its dependencies (you probably already have most of them). Still, the details are here for completion's sake (and the newer enthusiasts among us). First, get the repository onto your computer: git clone https://github.com/e-p-armstrong/augmentool.git Then, install the project's dependencies. For the API branch setup is super easy, you just need a handful of Python libraries: protobuf sentencepiece transformers matplotlib nltk openai. It should be as easy to install as: pip install protobuf sentencepiece transformers matplotlib nltk openai OR pip install -r requirements.txt You may get some messages saying that torchvision and torchaudio require older versions of Pytorch. This should be safely ignorable. If you want to use Aphrodite, you'll also need to add pip install aphrodite-engine NOTE under basically all circumstances it will be more cost-efficient to use APIs instead of running this with local inference. There are plenty of API providers such as Together.ai that offer quality open source models at extremely cheap prices. Those are recommended for most users. You technically could rent out a GPU from vast.ai or runpod, copy this notebook over, install the dependencies, and run "local" inference using the aphrodite mode there... but it'll probably be more expensive than the alternative. Thus, you should probably only consider using local inference if your machine is beefy enough, and even then it may come at a significant cost in time. For Mac users: since aphrodite-engine does not work on Mac, if you really want local inference you should start a Llama cpp server on your computer, and add its url as the "api endpoint" in the config file. This is a bit tricky to do, and I don't know how to get it using RoPE scaling yet (needed for Augmentoolkit unless you're using a Mistral model), so your best bet would be to do some intense Googling and/or asking questions on the lcpp repo. Introduction Dataset creation is currently the most painful, and most important, step of the finetune-creation process. Most people have to resort to either A) burning an obscene number of OpenAI API credits, or B) spending dozens, if not hundreds, of hours accumulating a hybrid dataset based off of your own conversations with bots. The OpenAI approach is based on a paid service (whose TOS you're violating) that can ban you at any second, whose writing style you probably hate, and whose synthetic data critically lacks variety. Handwriting the examples is far too slow to iterate on, and does not scale at all, meaning you're missing out on huge potential performance increases. If you're a company and you pay people to create examples in bulk, then it's possibly pricier than even OpenAI — also not scalable at all. And moreover, if we're literally creating machines that can write, why do we spend most of our time writing? Augmentoolkit is meant to make high-quality data generation easy, fast, shareable, configurable, and for everyone. It is meant to allow the easy creation of datasets about any knowledge that exists in plain text. It is meant to allow models to bootstrap additional training data for themselves. It is meant to allow any enthusiast, regardless of computer strength, to contribute to the advancement of AI by generating swathes of data for cheap. It's meant to expand the possibilities of what finetunes can be built, by making data gathering as easy as running a script. Whether you're finetuning a company chatbot to understand your business's information, or are creating the latest RP model to top Weicon's leaderboard, Augmentoolkit exists to make your data problems a bit less problematic. A flowchart of Augmentoolkit's operation can be found in the Usage section. The high-level is: books or manuals in, information-rich conversations out. Train the model on the conversations, it learns the information. Extensive validation keeps hallucinations to a minimum. More in-depth and jargon-filled: Augmentoolkit takes human-written text with information in it, and turns it into instruct-tuning data: It uses the text's information to generate questions that test the information, and it also generates answers to the questions that use the information. It triple-checks whether the generated questions and answers are accurate and only use information provided in the text (ensuring that the LLM did not hallucinate new information). Finally, it writes an interaction in a fictional setting between a character with domain expertise, and an ignorant secondary character, where the secondary character asks the questions and the primary character answers them. After checking that this conversation faithfully includes the original questions and answers, the result is saved as part of the newly-generated dataset. The usage of characters and a setting means that the model's creative writing and RP skill can be improved at the same time as its knowledge base (but if you don't want an RP bot, you can always turn "Assistant Mode" on for user-assistant style interactions instead). You can see a flowchart of this process over in Usage. IMPORTANT Augmentoolkit can make conversations between fictional characters, or between a user and AI assistant. It does the former by default. The latter is probably better suited to professional use cases. Quickstart: After installing the dependencies: Get the repo onto a computer with an internet connection Install its dependencies Open config.yaml Paste your API key, favorite model name, and the endpoint URL of your preferred AI service, into the relevant fields inside config.yaml. Be sure to keep the quotes. Recommendation: Together.ai with Hermes Mixtral works really nicely both as a LARGE_LOGICAL_MODEL and as the LOGICAL_MODEL. Either run all cells in the notebook processing.ipynb, or open this project's folder in a command line and type python processing.py and hit enter (fires off the script version). If you want to run a subset of the total text through the entire pipeline, to evaluate how well it works, turn on the USE_SUBSET flag in the config file (off by default) Some features worth being aware of This subsection describes things that make life easier in Augmentoolkit, particularly the new version. Easy resume: don't have long uninterrupted periods of time to run this? No problem! Augmentoolkit saves outputs as they're written and resumes generation painlessly, so you can start and stop stress free. Two-model generation for the sake of SPEED: every single task, except the very last one (multi-turn conversation generation) can be accomplished reliably by a good enough small model. But with APIs being as cheap as they are you can probably get away with running the whole thing using Mixtral anyway. Validation, validation, validation: Learning lessons from the original Augmental, consistency with the source text is an extremely high priority here, and this is ensured with multiple layers of LLM-based validation (and at the end, numerous examples of regex-based validation). API-capable: using the OpenAI API package, Augmentoolkit can now be powered by a host of Open-source model-providing APIs that are much cheaper and easier to use than running a GPU yourself, in most cases. For those of us with credits to spare, or with no fancy computers. Don't worry, it asynchronously uses the API, because your time is valuable. Quality of Life: with configurable paths for prompts, inputs, and outputs; a prompt override system; changing between local and API inference with a single field in a config file; and more added features, Augmentoolkit is actually kinda nice to use now. It's now a proper, solid program, not just a proof of concept. Holy crap is it fast: No more waiting for days while your GPU chugs along. If you're using a fast API, your speeds will be blazing. All the examples you see in ./example_generated_convs took like 20 minutes to generate from start to finish using Hermes Mixtral via Together.ai. Customization (arranged in order of least-to-most difficult to implement): Read this to learn how to hack Augmentoolkit for your own use cases. Augmentoolkit is way easier to customize now that it uses a .yaml file. If you're new to programming, .yaml isn't scary, trust me. Change the source texts used to generate training data. You do this by placing the .txt files you want to use in an input folder (by default, raw_txt_input/), and pointing Augmentoolkit at that folder by specifying it in config.yaml. So, move the files you want to turn into datasets into or out of that folder. IF YOU TURN USE_FILENAMES ON IN CONFIG.YAML then the filenames of these inputs should be formatted in a specific way, since the filenames are used as part of the prompts and in at least one regex. You need to have them be like: [textname], by authorname. So for example, Simple Sabotage, by the Office of Strategic Services. You can also include the publication date after the author name if you want (as in Principles of Chemistry, by Demitry Mendeleev, published 1897), but note that this may bias most of the characters to live in the era of the textbook, which may or may not be what you want. USE_FILENAMES is off by default, and that means the notebook just shows the model the text in each file now. The model sometimes mentions "the text" even if use_filenames is off IF you run in completion mode, also this is somewhat model-dependent. Finally, if you have a PDF you want to use as a source text, you can convert it to a .txt using ./convert_pdf_to_text.py (just change the pdf_path in the code, and run the script, or use an online conversion tool). If you want a good source of plaintext documents, try Project Gutenberg; if you want educational PDFs, try OpenStax. screenshot of config.yaml with input text path clearly specified Change the settings. There are a few constant values in Augmentoolkit, all configurable from config.yaml (the latter is only really used when testing prompts during development). WHAT EVERY SINGLE SETTING DOES IS DOCUMENTED EXTENSIVELY INSIDE CONFIG.YAML, here a comprehensive overview is given on WHEN and WHY you might want to change some things. Some settings make sense to change frequently, based on the project. These include things like USE_FILENAMES, which should be turned off if you haven't named your input text according to a specific format; USE_SUBSET, which should be turned on if you want to quickly test out how a single source text performs in the pipeline; and REARRANGEMENTS_TO_TAKE which decides how many unique conversations Augmentoolkit will try to generate from each group of question-answer pairs. COMPLETION_MODE should be turned off only if your API doesn't support text completion — the quality is higher with it on. Then there are the settings that deal more with specifics and details: things like DOUBLE_CHECK_COUNTER or CONCURRENCY_LIMIT which you should only mess with if you have specific technical requirements. NEW! With USE_FILENAMES being added, You no longer need to manually title all the files you use as input! And it's probably better if you don't because that way the model isn't as constrained to the time period it associates with your book. This should make truly bulk work much easier. Just use COMPLETION_MODE for fewer bugs. APIs that don't offer completion are typically bad at continuing patterns anyway and will have higher error rates. Change the personalities of the characters generated. Currently, when generating characters for the multi-turn conversation step, three randomly-selected traits are appended to the "special instructions" set of the prompt to constrain what kind of character is generated by the model. Depending on what kind of model you want to make, or even just if your preferences vary, then you will probably want to modify this a bit. You can do so in ./augmentoolkit/generation_functions/special_instructions.py. A more in-depth description of the trait-axis system that I (over)thought up is available in the comments of that file. NOTE: Personalities are not generated when using the more-professional ASSISTANT_MODE. The entire scenario generation and character generation part of the pipeline is skipped. This makes things cheaper and cleaner, if a bit less varied. Assistant Mode (IMPORTANT for professional users) Technically this could be considered part of 3), but it's different enough that I feel it warrants separate explanation. By default, the notebook is configured to produce RP-style data; "Assistant mode" is something you can toggle in config.yaml. Assistant mode skips character and scenario generation and answers every question in a chat between a user and a helpful AI assistant (with no personality). In the limited testing I have done with this, it seems that assistant mode is simple enough to work entirely with 13b models such as Flatorcamaid by Ikari (helluva name, I know, but it's a good model). So, if your compute or time are very limited, or you are using this for a more professional use case, feel free to turn this on. Change the model. This is as simple as switching the LOGICAL_MODEL value out for another one, and modifying your BASE_URL if you're changing to a different API, but your mileage may vary significantly. My personal recommendation is to use Hermes Mixtral DPO for both models. You need at least 12k context on your models, and APIs typically don't allow RoPE scaling, so you're probably limited to MistralAI models here (or, heavens forbid, OpenAI. But GPT-4.5 + Augmentoolkit will BANKRUPT you fast, so be wary). Mistral.ai models are offered on their API, or via open source model APIs like Together.ai or Groq. I recommend using Together with Hermes Mixtral: Mistral.ai's API seems to have instruct tuning that interferes with its ability to follow pattens set out by examples, resulting in worse performance and a severely elevated error rate when running Augmentoolkit. Mistral also doesn't offer a completion API. Details about some possible values for BASE_URL are available in config.yaml. Change the examples. Augmentoolkit now allows for easy switching between prompt groups for different projects/runs, just change the DEFAULT_PROMPTS and PROMPTS paths in config.yaml. Augmentoolkit first looks in PROMPTS for the file with the right name for a given step, then moves onto DEFAULT_PROMPTS if it can't find it. Changing prompts is recommended if you have a type of input text that's pretty far off from what Augmentoolkit's built to handle (information-rich text such as textbooks or manuals). However, while managing prompts is easier now, writing them is still hard. Here, you should focus on changing the examples, and even then, you should focus on changing a few specific files that do not generalize as well as the others. Augmentoolkit by default is very generalist, having a bit of RP and being capable of decently creating data for factual and philosophical texts. But this general capability hurts its specific task performance. Specific few-shot examples I recommend looking into changing first, if you want to radically adapt what Augmentoolkit does: generate_questions generate_new_question judge_paragraph for modifying the questions you generate and controlling what gets sent to question generation; multi_turn_convs for adapting the conversations to the types of question you ask. If you want to, you can change the types of characters generated using create_character_card_plan_many_tuples, create_character_card_many_tuples, and multi_turn_conversation. Changing prompts is hard so only change what you need. Validation too open and permissive? Change only judge_paragraph. The model asks the wrong kinds of question? Change the question generation prompts. Your new questions keep getting flagged by validation? Change the validation examples (just work through the reasoning steps yourself for the example (or get GPT-4 to do it) but have the example reach the correct conclusion). Don't like the writing style? Change multi_turn_conversation.py. Modifying the examples is by far the hardest modification you can make, but it also affords the most control, and will help ensure the quality you need for very specific or professional projects. It also happens to be what I specialize in, so if you have a professional project that you need Augmentoolkit adapted for, don't hesitate to chat with me about it! Hardcore Usage This section is seriously in-depth and is not required for casual use. You only need it if you're hardcore-modifying Augmentoolkit. It's primarily meant for people who will be changing the code, and who'd like a head start in grasping how all the moving pieces fit together. Because it sucks to use a newly-released framework and have to try to piece together the developer's understanding of the project from scratch. How to get this running at a basic level is covered in Quickstart. This section describes what you're actually doing while you're running this, as well as how to easily customize the function of this project for your own use cases. It describes everything from how to operate the project (in greater detail) to how everything's structured, and what folders to watch as you are generating your data. For the most part you can just follow quickstart, but this section may be worth reading if you plan to make this a serious part of your model creation (which I hope you do!). Here is a flowchart detailing how a typical run of Augmentoolkit may proceed. The source text can be anything with information you can ask questions about. Concepts and Operation Read this subsection for a slightly more detailed version of the more finicky bits of the quickstart, as well as an understanding of the key files in this repo. Augmentoolkit has a Jupyter notebook, processing.ipynb, and a script, processing.py. All the prompts are stored in ./prompts/ and are text or JSON files for maximal editing convenience. A complete code overhaul has dramatically reduced repetition, too. Augmentoolkit has never been so easy to modify. You run Augmentoolkit by running all cells in the Jupyter Notebook processing.ipynb, or by running the python script. You no longer need to restart the notebook, even if doing part of the generation with a smaller model, when you're using an API. A restart is still required if you're using it in Aphrodite mode!!! Important files: The core of the project is the script/notebook. The two are essentially equivalent: the script was created by exporting the notebook and adding a few lines to make it work async. Whichever one you use, it needs ./augmentoolkit/ for some imports, some prompts in ./prompts/ (or whatever you change it to in the config), and a folder with text documents to read in (by default, ./raw_text_input/). All these folders should ideally be in the same folder as the script and notebook. If you are going to change anything, please read Customization first. Understanding what is going on as it runs This subsection summarizes output folders and code structure. It is primarily useful if you intend to modify the code of Augmentoolkit. Design philosophy: I considered structuring this project in such a way that it would become very abstract, each pipeline step would be an object, etc... but this is not trying to be langchain, or any kind of agent framework. Or a pipeline framework. Augmentoolkit is a program, not a framework, and it's specifically for generating data. I believe that for most use cases here, Python code is the correct level of abstraction. That being said, it helps to know how this particular code is currently structured before you go changing it, if you have a slightly different use case in mind. Some of the features present here, like the engine wrapper and generation step classes, will probably be preserved in any modification or fork that you make. Output folders: Augmentoolkit makes plenty of folders while it runs. However they're all nicely contained in whatever you specify the OUTPUT folder to be (specified in config.yaml). The output folder contains both files that are being saved just in case a future model is trained to run this pipeline specifically, and the ones that are explicitly intermediate steps, saved in case a run is paused and you want to resume later. The intermediate folders ones you may want to pay attention to are ./worthy_for_questions, ./qatuples_raw, ./qatuples_revised, ./multiturn_convs_info, and finally, ./multiturn_convs. ./multiturn_convs is the final output directory, from which the final dataset files master_list.jsonl, processed_masterlist.json, and simplified_data.jsonl (sharegpt format) are created. Everything else is just the notebook saving the outputs of every single step in case someone (or myself) wants to train a model specifically for running this pipeline at some point. Do not move or remove the folders as they're generated. As for code structure, processing.ipynb (or .py as the case may be) is a relatively lightweight wrapper for the control flow code in ./augmentoolkit/control_flow_functions/control_flow_functions.py, which focuses on passing output from one discrete step of the pipeline to the other, and loading and saving to files. It's essentially the interface. If you've used Augmentoolkit before the great refactoring of 24/02/19, know that all the messy logic now hides in control_flow_functions.py. Out of sight, out of mind. The ./augmentoolkit/generation_functions holds a few helper functions, and a few essential classes. engine_wrapper_class.py holds the logic for making calls to whatever LLM-providing service you're using; generation_step_class.py is a class that submits calls to engine_wrapper_class.py. Instances of the class represent a step in the pipeline, such as generating questions or conversations. Its purpose is to prevent the control flow code from having to manage prompts or inference code. You pass in the path to a prompt, some settings, and an output processor, and then calling .generate() on it fulfills the same role that the dozen-or-so separate functions in generation_functions/ once did. So basically: generation_step_class.py is an abstracted-away way to handle gathering the inputs to the engine wrapper. Inside ./augmentoolkit/control_flow_functions, note that write_output_to_file() can mostly be ignored; it just saves the full completion of each step for the sake of potential future training of a model specifically for running this pipeline (think jondurbin/cinematika-7b-v0.1). The main output of the function is usually just passed onto the next part of the pipeline. If a file has been written already, any future attempts to write that file will be skipped, allowing for easy resumption of generation after interruption. Prompts All prompts are in prompts/. You can specify two prompt folder paths: the DEFAULT_PROMPTS path and the PROMPTS path. Augmentoolkit first looks in PROMPTS and then falls back to DEFAULT_PROMPTS if it can't find the correctly-named file for its step. This is useful if you want to change prompts between different projects by overriding specific prompts in prompts/. By default, no prompts are overridden. Completion Mode: If completion mode is on, then the pipeline treats the model more like autocomplete than a conversation. This typically has much better performance and quality, but not all APIs support completion mode (Mistral doesn't, OpenAI doesn't) so you may need to turn this off depending on your provider. If it's on, Augmentoolkit uses .txt files in whatever prompt folders it's been given; if it's off, it uses the .json files. It's easiest to understand Augmentoolkit as being an LLM pipeline: it takes a bunch of input, calls a series of LLM modifications on it (passing the output from one step to the next) and outputs the transformed result. This is somewhat different from an agent framework like LangChain because the AI doesn't actually reason about what step to do next; the logic is hardcoded and hand-prompted. Output data format: Augmentoolkit outputs data both in its own format and in ShareGPT at the end. Its own format is the following: [ [ 'something', # this is the conv 'something', #character card 'something', # Chain of Thought generations used to plan the scenario. Some of the later steps could possibly be useful context to append to the character card, so the entire thing is included incase you need it for your purposes. for an example of how this might be added to a character card, look at the prompts for [['q','a','source_paragraph'],...up to 4 times...] ], ...repeated for each conversation you generated ] Things are accessed by index, which makes it more just a pure list format than JSON. Of course you can also just convert to ShareGPT using the cell at the very end, but that loses some info. Think this is cool? Connect with me elsewhere! If you think this project is cool and useful, great! I'm genuinely happy that you're interested by my work. If you're really interested by this project you might be interested by some of my other endeavors: A newsletter/blog about Prompt Engineering Open-Source models — the art and science that is the backbone of Augmentoolkit and complex LLM projects like it. I also consult for prompt engineering, if you're curious. I sometimes post stuff and sometimes join spaces on X/Twitter Let's connect on LinkedIn! I'm pretty active on TheBloke's discord server and a bunch of other AI discords. Find me as @heralax! By the way, did I mention I consult? :) I might be able to help your AI business get even better, using Augmentoolkit or straight-up prompting. We should chat at least and connect Email me at: <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS> About Convert Compute And Books Into Instruct-Tuning Datasets Resources Readme License MIT license Activity Stars 288 stars Watchers 10 watching Forks 42 forks Report repository Releases No releases published Packages No packages published Contributors 2 @e-p-armstrong e-p-armstrong Evan Armstrong @darkacorn darkacorn Languages Python 84.5% Jupyter Notebook 15.5% Footer © 2024 GitHub, Inc. augmentoolkit/prompts at master · e-p-armstrong/augmentoolkit""
62f0d53d4006740df1883b84c5b83901
{ "intermediate": 0.4707740247249603, "beginner": 0.2751413583755493, "expert": 0.25408464670181274 }
43,883
Javascript code to be run in Tasker to clear notification
7144932e965ae292613d9c1a821e7401
{ "intermediate": 0.33749914169311523, "beginner": 0.3714189827442169, "expert": 0.29108190536499023 }
43,884
use the following text: ""The research paper explores the challenges faced by value investors in today's economic landscape, characterized by the rise of intangible assets. It attributes the recent struggles of value investing strategies to the increasing dominance of intangibles, which are not adequately captured by traditional measures of tangible value. The paper provides a comprehensive analysis of the shift from tangible to intangible value. It delves into the historical evolution of value investing, acknowledging the contributions of Ben Graham, whose principles were established during the industrial age. The authors emphasize that the economy has transformed into an information-based system, where firms derive their value primarily from intangible assets rather than physical assets. To address this issue, the paper proposes a new framework for calculating intrinsic value that accounts for both tangible and intangible assets. It recognizes that measuring intangibles is complex due to the limitations of standardized accounting practices. Therefore, the authors advocate for the use of alternative data and machine learning techniques to quantify these intangibles effectively. The development of an Intangible Value measure is a key contribution of the paper. This measure aims to capture the combined value of various intangible assets, such as intellectual property, human capital, brand equity, and network effects. The authors explain the process of creating this measure, which involves clustering analysis and topic modeling of their previous research work. Using this Intangible Value metric alongside traditional tangible value metrics, the authors backtest investment strategies and portfolios. They demonstrate that incorporating intangible value enhances the performance of value investing, outpacing strategies that rely solely on tangible value. The paper also presents a visual decomposition of the balance sheets of prominent companies, illustrating the significance of intangible assets. In addition to the practical implications, the paper discusses the philosophical aspects of value and growth investing. It critiques the rigid style box framework that categorizes investments as either value or growth, suggesting that this binary classification is outdated and restrictive. The authors align with Warren Buffett's perspective, emphasizing that growth is an essential component of value and that a dynamic approach is needed to adapt to changing market opportunities. The paper concludes by emphasizing the need for value investing to evolve. It advocates for a more inclusive definition of intrinsic value that unites the value and growth investing communities. By embracing the reality of the intangibles-driven economy and leveraging new data and technologies, the authors believe that value investing can regain its prominence. This expanded summary captures the key points of the research paper, including its analysis of the evolving economic landscape, the proposed framework for measuring intangible value, and the potential for a more holistic approach to investing that transcends traditional style boxes."" to change the examples in this dataset: kto_dataset_list = [ {“prompt”: “Hey, hello”, “completion”: “hi nice to meet you”, “label”: true}, {“prompt”: “How are you”, “completion”: “leave me alone”, “label”: false}, {“prompt”: “What is your name?”, “completion”: “I don’t have a name”, “label”: false}, {“prompt”: “What is your name?”, “completion”: “My name is Mary”, “label”: true}, {“prompt”: “Which is the best programming language?”, “completion”: “Python”, “label”: true}, {“prompt”: “Which is the best programming language?”, “completion”: “C++”, “label”: false}, {“prompt”: “Which is the best programming language?”, “completion”: “Java”, “label”: false}, # Add more examples as needed… ] The 'prompt' contains the context inputs, 'completion' contains the corresponding responses and 'label' contains the corresponding flag that indicates if the generated completion is desired (true) or undesired (false). A prompt can have multiple responses and this is reflected in the entries being repeated in the dictionary’s value arrays. ONLY output the dataset.
bcc35b5fc7c61f583fc28fbe80a63f7c
{ "intermediate": 0.3343065083026886, "beginner": 0.4146096110343933, "expert": 0.2510838508605957 }
43,885
Can you extract the bullet points from this personals ad to include as a seeking message on discord? Personals ad (with compatibility table and interests removed)
6a9c8d9b3fb75273ce675bdd583a55dc
{ "intermediate": 0.36851581931114197, "beginner": 0.2955785095691681, "expert": 0.33590564131736755 }
43,886
Do you understand my BSTDictionary implementation? /** * This class implements an ordered dictionary using a binary search tree. * It uses the BinarySearchTree class for the underlying implementation. */ public class BSTDictionary implements BSTDictionaryADT { private BinarySearchTree bst; // Instance of the BinarySearchTree /** * Constructor for the BSTDictionary class. */ public BSTDictionary() { bst = new BinarySearchTree(); } /** * Returns the Record with the given key k, or null if the Record is not in the dictionary. * * @param k The key of the Record to search for * @return The Record with the given key, or null if not found */ public Record get(Key k) { BSTNode node = bst.get(bst.getRoot(), k); return (node != null) ? node.getRecord() : null; } /** * Inserts the given Record d into the ordered dictionary. * Throws a DictionaryException if a Record with the same Key as d is already in the dictionary. * * @param d The Record to be inserted * @throws DictionaryException If a Record with the same Key as d is already in the dictionary */ public void put(Record d) throws DictionaryException { bst.insert(bst.getRoot(), d); } /** * Removes the Record with the given Key k from the dictionary. * Throws a DictionaryException if the Record is not in the dictionary. * * @param k The key of the Record to be removed * @throws DictionaryException If the Record is not in the dictionary */ public void remove(Key k) throws DictionaryException { bst.remove(bst.getRoot(), k); } /** * Returns the successor of the given key k (the Record from the ordered dictionary with the smallest * Key larger than k); returns null if the given Key has no successor. The given Key DOES NOT need * to be in the dictionary. * * @param k The key for which the successor is to be found * @return The Record with the successor Key, or null if no successor exists */ public Record successor(Key k) { BSTNode node = bst.successor(bst.getRoot(), k); return (node != null) ? node.getRecord() : null; } /** * Returns the predecessor of the given key k (the Record from the ordered dictionary with the largest * key smaller than k); returns null if the given Key has no predecessor. The given Key DOES NOT need * to be in the dictionary. * * @param k The key for which the predecessor is to be found * @return The Record with the predecessor Key, or null if no predecessor exists */ public Record predecessor(Key k) { // Implement using the BinarySearchTree methods return null; // Placeholder } /** * Returns the Record with the smallest key in the ordered dictionary. * Returns null if the dictionary is empty. * * @return The Record with the smallest key, or null if the dictionary is empty */ public Record smallest() { BSTNode node = bst.smallest(bst.getRoot()); return (node != null) ? node.getRecord() : null; } /** * Returns the Record with the largest key in the ordered dictionary. * Returns null if the dictionary is empty. * * @return The Record with the largest key, or null if the dictionary is empty */ public Record largest() { BSTNode node = bst.largest(bst.getRoot()); return (node != null) ? node.getRecord() : null; } }
b9aaa6146ba9f3549799fb38a53899f2
{ "intermediate": 0.3782317340373993, "beginner": 0.3635447025299072, "expert": 0.25822359323501587 }
43,887
User How do I make a slider in the right of the menu? So I don't need to always adjust the windowWidth and winodowHeight? if (this.showGUI1) { Microsoft.Xna.Framework.Rectangle guiWindowRect = new Microsoft.Xna.Framework.Rectangle((int)windowX, (int)windowY, (int)fixedWindowWidth, (int)fixedWindowHeight); int borderWidth = 2; Microsoft.Xna.Framework.Rectangle borderRect = new Microsoft.Xna.Framework.Rectangle(guiWindowRect.X - borderWidth, guiWindowRect.Y - borderWidth, guiWindowRect.Width + 2 * borderWidth, guiWindowRect.Height + 2 * borderWidth); Microsoft.Xna.Framework.Color borderColor = Microsoft.Xna.Framework.Color.Black; this.m_spriteBatch.Draw(this.pixelTexture, borderRect, borderColor); Microsoft.Xna.Framework.Color guiWindowColor = new Microsoft.Xna.Framework.Color(50, 50, 50, 200); this.m_spriteBatch.Draw(this.pixelTexture, guiWindowRect, guiWindowColor); string guiMessage = "MadeByHowque || Mouse2 to drag!"; Vector2 guiMessageSize = Constants.FontSimple.MeasureString(guiMessage); Vector2 guiMessagePosition = new Vector2((float)(guiWindowRect.X + 10), (float)(guiWindowRect.Y + 10)); this.m_spriteBatch.DrawString(Constants.FontSimple, guiMessage, guiMessagePosition, guiMessageColor); float leftOffset = 20f; Vector2 checkboxPosition = new Vector2((float)guiWindowRect.X + leftOffset, guiMessagePosition.Y + guiMessageSize.Y + 7f); // Checkbox 1 string checkbox1Text = "SpeedHack"; Microsoft.Xna.Framework.Color checkbox1Color = GameSFD.checkboxState ? Microsoft.Xna.Framework.Color.Green : Microsoft.Xna.Framework.Color.Red; this.m_spriteBatch.Draw(this.pixelTexture, new Microsoft.Xna.Framework.Rectangle((int)checkboxPosition.X, (int)checkboxPosition.Y, 20, 20), checkbox1Color); this.m_spriteBatch.DrawString(Constants.FontSimple, checkbox1Text, new Vector2(checkboxPosition.X + 30f, checkboxPosition.Y), Microsoft.Xna.Framework.Color.White); checkboxPosition.Y += 30f; // Checkbox 2 string checkbox2Text = "FlyHack"; Microsoft.Xna.Framework.Color checkbox2Color = GameSFD.checkboxState2 ? Microsoft.Xna.Framework.Color.Green : Microsoft.Xna.Framework.Color.Red; this.m_spriteBatch.Draw(this.pixelTexture, new Microsoft.Xna.Framework.Rectangle((int)checkboxPosition.X, (int)checkboxPosition.Y, 20, 20), checkbox2Color); this.m_spriteBatch.DrawString(Constants.FontSimple, checkbox2Text, new Vector2(checkboxPosition.X + 30f, checkboxPosition.Y), Microsoft.Xna.Framework.Color.White); checkboxPosition.Y += 30f; // Checkbox 3 string checkbox3Text = "AlwaysRechargeEnergy"; Microsoft.Xna.Framework.Color checkbox3Color = GameSFD.checkboxState3 ? Microsoft.Xna.Framework.Color.Green : Microsoft.Xna.Framework.Color.Red; this.m_spriteBatch.Draw(this.pixelTexture, new Microsoft.Xna.Framework.Rectangle((int)checkboxPosition.X, (int)checkboxPosition.Y, 20, 20), checkbox3Color); this.m_spriteBatch.DrawString(Constants.FontSimple, checkbox3Text, new Vector2(checkboxPosition.X + 30f, checkboxPosition.Y), Microsoft.Xna.Framework.Color.White); checkboxPosition.Y += 30; // Checkbox 4 string checkbox4Text = "NoCooldowns"; Microsoft.Xna.Framework.Color checkbox4Color = GameSFD.checkboxState4 ? Microsoft.Xna.Framework.Color.Green : Microsoft.Xna.Framework.Color.Red; this.m_spriteBatch.Draw(this.pixelTexture, new Microsoft.Xna.Framework.Rectangle((int)checkboxPosition.X, (int)checkboxPosition.Y, 20, 20), checkbox4Color); this.m_spriteBatch.DrawString(Constants.FontSimple, checkbox4Text, new Vector2(checkboxPosition.X + 30f, checkboxPosition.Y), Microsoft.Xna.Framework.Color.White); checkboxPosition.Y += 30; // Checkbox 5 string checkbox5Text = "InfiniteEnergy"; Microsoft.Xna.Framework.Color checkbox5Color = GameSFD.checkboxState5 ? Microsoft.Xna.Framework.Color.Green : Microsoft.Xna.Framework.Color.Red; this.m_spriteBatch.Draw(this.pixelTexture, new Microsoft.Xna.Framework.Rectangle((int)checkboxPosition.X, (int)checkboxPosition.Y, 20, 20), checkbox5Color); this.m_spriteBatch.DrawString(Constants.FontSimple, checkbox5Text, new Vector2(checkboxPosition.X + 30f, checkboxPosition.Y), Microsoft.Xna.Framework.Color.White); checkboxPosition.Y += 30; // Checkbox 6 string checkbox6Text = "LadderDiveExploit"; Microsoft.Xna.Framework.Color checkbox6Color = GameSFD.checkboxState6 ? Microsoft.Xna.Framework.Color.Green : Microsoft.Xna.Framework.Color.Red; this.m_spriteBatch.Draw(this.pixelTexture, new Microsoft.Xna.Framework.Rectangle((int)checkboxPosition.X, (int)checkboxPosition.Y, 20, 20), checkbox6Color); this.m_spriteBatch.DrawString(Constants.FontSimple, checkbox6Text, new Vector2(checkboxPosition.X + 30f, checkboxPosition.Y), Microsoft.Xna.Framework.Color.White); checkboxPosition.Y += 30;// Add more checkboxes as needed... // Checkbox 7 string checkbox7Text = "FakelagExploit"; Microsoft.Xna.Framework.Color checkbox7Color = GameSFD.checkboxState7 ? Microsoft.Xna.Framework.Color.Green : Microsoft.Xna.Framework.Color.Red; this.m_spriteBatch.Draw(this.pixelTexture, new Microsoft.Xna.Framework.Rectangle((int)checkboxPosition.X, (int)checkboxPosition.Y, 20, 20), checkbox7Color); this.m_spriteBatch.DrawString(Constants.FontSimple, checkbox7Text, new Vector2(checkboxPosition.X + 30f, checkboxPosition.Y), Microsoft.Xna.Framework.Color.White); checkboxPosition.Y += 30;
9a173cb795399102eeaaacf65320d07d
{ "intermediate": 0.432095468044281, "beginner": 0.39953890442848206, "expert": 0.16836565732955933 }
43,888
Hi, I have a Vector of four unsigned integers and, given a threshold, I would like to see if the ratio of the minimum one and the others has some integer relationship, like 2 and 4.1 have a integers ratio if the threshold Is greater of 0.1. Do you have any idea about how to do this verificati in?
8bfe97fd9d634c6b8606bb00bc3310f7
{ "intermediate": 0.4319092929363251, "beginner": 0.15824615955352783, "expert": 0.4098445773124695 }
43,889
please look at this code : use aes::Aes256; use block_modes::block_padding::Pkcs7; use block_modes::{BlockMode, Ecb}; use sha2::{Digest, Sha256}; use std::convert::TryInto; use std::time::{Duration, Instant}; use std::{fs, io, thread}; type Aes256Ecb = Ecb<Aes256, Pkcs7>; //const ENCRYPTED_AES_KEY: &str = ""; // i: 1174012 // j: 1258837 // k: 1477889744044 //const ENCRYPTED_SECRET: &str = "ef5ebbe8f727c54db9755e1c2ead609a0ffc837c25b9493aeb11c68e7a14710e"; const ENCRYPTED_SECRET: &str = "ce8f36aa844ab00319bcd4f86460a10d77492c060b2c2a91615f4cd1f2d0702e76b68f1ec0f11d15704ba52c5dacc60018d5ed87368464acd030ce6230efdbff7b18cba72ccaa9455a6fe6021b908dd1"; #[derive(Debug, serde::Serialize, serde::Deserialize)] struct State { i: u64, j: u64, } fn save_state(state: &State, filename: &str) -> io::Result<()> { let state_json = serde_json::to_string(&state)?; fs::write(filename, state_json)?; Ok(()) } fn load_state(filename: &str) -> io::Result<Option<State>> { if let Ok(state_json) = fs::read_to_string(filename) { let state: State = serde_json::from_str(&state_json)?; Ok(Some(state)) } else { Ok(None) } } fn main() -> io::Result<()> { // Provided data // let enc_secret = hex::decode("ef5ebbe8f727c54db9755e1c2ead609a0ffc837c25b9493aeb11c68e7a14710e").unwrap(); let enc_secret = hex::decode(ENCRYPTED_SECRET).unwrap(); const PAUSE_INTERVAL: Duration = Duration::from_secs(15 * 60); // 15 minutes const PAUSE_DURATION: Duration = Duration::from_secs(60); // 60 seconds let mut next_pause = Instant::now(); let start_range = 1 << 20; // 2^20 let end_range = 1 << 21; // 2^21 let mut i_start = start_range; let mut j_start = start_range; // Load the state if it exists let state_filename = "state.json"; if let Ok(Some(state)) = load_state(state_filename) { i_start = state.i; j_start = state.j; } 'outer: for i in i_start..end_range { for j in j_start..end_range { let k = i * j; // Check if product has between 40 and 42 bits (not strictly required in Rust) if (k.leading_zeros() as u64) >= (64 - 42) && (k.leading_zeros() as u64) <= (64 - 40) { let key_material = k.to_string(); let mut hasher = Sha256::new(); hasher.update(key_material.as_bytes()); let key = hasher.finalize(); let key_slice: &[u8; 32] = key.as_slice().try_into().unwrap(); let cipher = Aes256Ecb::new_from_slices(key_slice, Default::default()).unwrap(); if let Ok(decrypted) = cipher.decrypt_vec(&enc_secret) { println!("Key1: {}, Key2: {} --> KEY product {} !", i, j, k); //println!("Dec secret: {:?}", std::str::from_utf8(&decrypted).unwrap()); println!("Dec secret: {:?}", String::from_utf8_lossy(&decrypted)); if decrypted .windows(b"HTB{".len()) .any(|window| window == b"HTB{") { println!("Decryption successful! AES key was found: k={}", k); println!("Decrypted FLAG: {:?}", String::from_utf8_lossy(&decrypted)); save_state(&State { i, j }, state_filename)?; break 'outer; } } } if next_pause.elapsed() >= PAUSE_INTERVAL { println!("Pausing for a bit to chill the CPU…"); save_state(&State { i, j }, state_filename)?; thread::sleep(PAUSE_DURATION); next_pause = Instant::now() + PAUSE_INTERVAL; } } j_start = start_range; // Reset j start for the next iteration of i } Ok(()) }
5e90402351276a54b7d4ae32ead5bf40
{ "intermediate": 0.3760182857513428, "beginner": 0.3397112190723419, "expert": 0.2842704653739929 }
43,890
from datetime import datetime, timedelta # Function to extract actuals for a given lag and cutoff date def extract_actuals_for_lag(df, lag, cutoff_date): start_date = cutoff_date - timedelta(weeks=lag+4) end_date = cutoff_date - timedelta(weeks=lag) mask = (df['ds'] >= pl.lit(start_date)) & (df['ds'] < pl.lit(end_date)) mask_df = df.filter(mask) # Use df.filter() instead of boolean indexing return mask_df[['unique_id', 'y']].groupby('unique_id').agg(pl.expr.list('y').alias('actuals')) # Function to calculate group accuracy and bias for a given lag def calculate_lag_accuracy_bias(actuals, forecasts, cutoff_date): lag_accuracy = {} lag_bias = {} forecasts_filtered = forecasts[(forecasts['WeekDate'] >= cutoff_date) & (forecasts['WeekDate'] < cutoff_date + timedelta(weeks=12))] forecasts_filtered = forecasts_filtered.with_columns([ pl.concat_str([ pl.col('MaterialID').cast(pl.Utf8), "_", pl.col('SalesOrg').cast(pl.Utf8), "_", pl.col('DistrChan').cast(pl.Utf8), "_", pl.col('CL4').cast(pl.Utf8) ]).alias('unique_id') ]) for record in actuals.to_dicts(): key = record['unique_id'] actual_values = record['actuals'] forecasts = forecasts_filtered[forecasts_filtered['unique_id'] == key, 'AutoARIMA'].to_lists()[0] abs_errors = [abs(forecast - actual) for forecast, actual in zip(forecasts, actual_values)] sum_abs_errors = sum(abs_errors) sum_actuals = sum(actual_values) sum_forecasts = sum(forecasts) if sum_actuals > 0: lag_accuracy[key] = 1 - (sum_abs_errors / sum_actuals) lag_bias[key] = (sum_forecasts / sum_actuals) - 1 else: lag_accuracy[key] = 0 # Set accuracy to 0 if sum_actuals is 0 lag_bias[key] = 0 # Set bias to 0 if sum_actuals is 0 return lag_accuracy, lag_bias # Set the cutoff date for lag 0 (e.g., first week of 2023) cutoff_date = datetime(2023, 1, 2) # Calculate accuracy and bias for each lag lag_results = {} for lag in range(12): actuals = extract_actuals_for_lag(crossvalidation_df, lag, cutoff_date) lag_accuracy, lag_bias = calculate_lag_accuracy_bias(actuals, forecasts_df, cutoff_date) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /Users/tungnguyen/Downloads/Nestle/Nestle CL4 Low Volume ARIMAX Ensemble.ipynb Cell 26 line 5 50 lag_results = {} 51 for lag in range(12): ---> 52 actuals = extract_actuals_for_lag(crossvalidation_df, lag, cutoff_date) 53 lag_accuracy, lag_bias = calculate_lag_accuracy_bias(actuals, forecasts_df, cutoff_date) 54 lag_results[f'lag{lag}'] = {'accuracy': lag_accuracy, 'bias': lag_bias} /Users/tungnguyen/Downloads/Nestle/Nestle CL4 Low Volume ARIMAX Ensemble.ipynb Cell 26 line 9 7 mask = (df['ds'] >= pl.lit(start_date)) & (df['ds'] < pl.lit(end_date)) 8 mask_df = df.filter(mask) # Use df.filter() instead of boolean indexing ----> 9 return mask_df[['unique_id', 'y']].groupby('unique_id').agg(pl.expr.list('y').alias('actuals')) TypeError: 'module' object is not callable lag_results[f'lag{lag}'] = {'accuracy': lag_accuracy, 'bias': lag_bias} cutoff_date += timedelta(weeks=1) # Print the results along with the 12-week out forecasts for lag, result in lag_results.items(): print(f"{lag}:") for key, accuracy in result['accuracy'].items(): forecasts = forecasts_df[forecasts_df['unique_id'] == key, 'AutoARIMA'].to_lists()[0] print(f" {key}: Accuracy={accuracy:.4f}, Bias={result['bias'][key]:.4f}, 12-week out forecasts={forecasts}")
88df1bbcafb7206542b6591f364b2ec7
{ "intermediate": 0.42308980226516724, "beginner": 0.3334403932094574, "expert": 0.24346978962421417 }
43,891
from datetime import datetime, timedelta # Function to extract actuals for a given lag and cutoff date def extract_actuals_for_lag(df, lag, cutoff_date): start_date = cutoff_date - timedelta(weeks=lag+4) end_date = cutoff_date - timedelta(weeks=lag) mask = (df['ds'] >= pl.lit(start_date)) & (df['ds'] < pl.lit(end_date)) mask_df = df.filter(mask) # Use df.filter() instead of boolean indexing return mask_df.select(['unique_id', 'y']).groupby('unique_id').agg(pl.col('y').list().alias('actuals')) # Function to calculate group accuracy and bias for a given lag def calculate_lag_accuracy_bias(actuals, forecasts, cutoff_date): lag_accuracy = {} lag_bias = {} forecasts_filtered = forecasts[(forecasts['WeekDate'] >= cutoff_date) & (forecasts['WeekDate'] < cutoff_date + timedelta(weeks=12))] forecasts_filtered = forecasts_filtered.with_columns([ pl.concat_str([ pl.col('MaterialID').cast(pl.Utf8), "_", pl.col('SalesOrg').cast(pl.Utf8), "_", pl.col('DistrChan').cast(pl.Utf8), "_", pl.col('CL4').cast(pl.Utf8) ]).alias('unique_id') ]) for record in actuals.to_dicts(): key = record['unique_id'] actual_values = record['actuals'] forecasts = forecasts_filtered[forecasts_filtered['unique_id'] == key, 'AutoARIMA'].to_lists()[0] abs_errors = [abs(forecast - actual) for forecast, actual in zip(forecasts, actual_values)] sum_abs_errors = sum(abs_errors) sum_actuals = sum(actual_values) sum_forecasts = sum(forecasts) if sum_actuals > 0: lag_accuracy[key] = 1 - (sum_abs_errors / sum_actuals) lag_bias[key] = (sum_forecasts / sum_actuals) - 1 else: lag_accuracy[key] = 0 # Set accuracy to 0 if sum_actuals is 0 lag_bias[key] = 0 # Set bias to 0 if sum_actuals is 0 return lag_accuracy, lag_bias # Set the cutoff date for lag 0 (e.g., first week of 2023) cutoff_date = datetime(2023, 1, 2) # Calculate accuracy and bias for each lag lag_results = {} for lag in range(12): actuals = extract_actuals_for_lag(crossvalidation_df, lag, cutoff_date) lag_accuracy, lag_bias = calculate_lag_accuracy_bias(actuals, forecasts_df, cutoff_date) lag_results[f'lag{lag}'] = {'accuracy': lag_accuracy, 'bias': lag_bias} cutoff_date += timedelta(weeks=1) # Print the results along with the 12-week out forecasts for lag, result in lag_results.items(): print(f"{lag}:") for key, accuracy in result['accuracy'].items(): forecasts = forecasts_df[forecasts_df['unique_id'] == key, 'AutoARIMA'].to_lists()[0] print(f" {key}: Accuracy={accuracy:.4f}, Bias={result['bias'][key]:.4f}, 12-week out forecasts={forecasts}") --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /Users/tungnguyen/Downloads/Nestle/Nestle CL4 Low Volume ARIMAX Ensemble.ipynb Cell 26 line 5 50 lag_results = {} 51 for lag in range(12): ---> 52 actuals = extract_actuals_for_lag(crossvalidation_df, lag, cutoff_date) 53 lag_accuracy, lag_bias = calculate_lag_accuracy_bias(actuals, forecasts_df, cutoff_date) 54 lag_results[f'lag{lag}'] = {'accuracy': lag_accuracy, 'bias': lag_bias} /Users/tungnguyen/Downloads/Nestle/Nestle CL4 Low Volume ARIMAX Ensemble.ipynb Cell 26 line 9 7 mask = (df['ds'] >= pl.lit(start_date)) & (df['ds'] < pl.lit(end_date)) 8 mask_df = df.filter(mask) # Use df.filter() instead of boolean indexing ----> 9 return mask_df.select(['unique_id', 'y']).groupby('unique_id').agg(pl.col('y').list().alias('actuals')) TypeError: 'ExprListNameSpace' object is not callable
a5da99d6cf71b87ef2b6d6bbe680330d
{ "intermediate": 0.3976992964744568, "beginner": 0.3449814021587372, "expert": 0.25731930136680603 }
43,892
Write JavaScript code (Replit) for a screen that asks the User to select between Windows 8 and Windows 10. Once they choose one, they will type in a username and password for their login.
802def0d104b09961d5caac062d08cc7
{ "intermediate": 0.3068986237049103, "beginner": 0.44429296255111694, "expert": 0.24880844354629517 }
43,893
from datetime import datetime, timedelta # Function to extract actuals for a given lag and cutoff date def extract_actuals_for_lag(df, lag, cutoff_date): start_date = cutoff_date - timedelta(weeks=lag+4) end_date = cutoff_date - timedelta(weeks=lag) mask = (df['ds'] >= pl.lit(start_date)) & (df['ds'] < pl.lit(end_date)) mask_df = df.filter(mask) # Use df.filter() instead of boolean indexing return mask_df.select(['unique_id', 'y']).groupby('unique_id').agg([ pl.col('y').list().alias('actuals') ]) # Function to calculate group accuracy and bias for a given lag def calculate_lag_accuracy_bias(actuals, forecasts, cutoff_date): lag_accuracy = {} lag_bias = {} forecasts_filtered = forecasts[(forecasts['WeekDate'] >= cutoff_date) & (forecasts['WeekDate'] < cutoff_date + timedelta(weeks=12))] forecasts_filtered = forecasts_filtered.with_columns([ pl.concat_str([ pl.col('MaterialID').cast(pl.Utf8), "_", pl.col('SalesOrg').cast(pl.Utf8), "_", pl.col('DistrChan').cast(pl.Utf8), "_", pl.col('CL4').cast(pl.Utf8) ]).alias('unique_id') ]) for record in actuals.to_dicts(): key = record['unique_id'] actual_values = record['actuals'] forecasts = forecasts_filtered[forecasts_filtered['unique_id'] == key, 'AutoARIMA'].to_lists()[0] abs_errors = [abs(forecast - actual) for forecast, actual in zip(forecasts, actual_values)] sum_abs_errors = sum(abs_errors) sum_actuals = sum(actual_values) sum_forecasts = sum(forecasts) if sum_actuals > 0: lag_accuracy[key] = 1 - (sum_abs_errors / sum_actuals) lag_bias[key] = (sum_forecasts / sum_actuals) - 1 else: lag_accuracy[key] = 0 # Set accuracy to 0 if sum_actuals is 0 lag_bias[key] = 0 # Set bias to 0 if sum_actuals is 0 return lag_accuracy, lag_bias # Set the cutoff date for lag 0 (e.g., first week of 2023) cutoff_date = datetime(2023, 1, 2) # Calculate accuracy and bias for each lag lag_results = {} for lag in range(12): actuals = extract_actuals_for_lag(crossvalidation_df, lag, cutoff_date) lag_accuracy, lag_bias = calculate_lag_accuracy_bias(actuals, forecasts_df, cutoff_date) lag_results[f'lag{lag}'] = {'accuracy': lag_accuracy, 'bias': lag_bias} cutoff_date += timedelta(weeks=1) # Print the results along with the 12-week out forecasts for lag, result in lag_results.items(): print(f"{lag}:") for key, accuracy in result['accuracy'].items(): forecasts = forecasts_df[forecasts_df['unique_id'] == key, 'AutoARIMA'].to_lists()[0] print(f" {key}: Accuracy={accuracy:.4f}, Bias={result['bias'][key]:.4f}, 12-week out forecasts={forecasts}") --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /Users/tungnguyen/Downloads/Nestle/Nestle CL4 Low Volume ARIMAX Ensemble.ipynb Cell 26 line 5 52 lag_results = {} 53 for lag in range(12): ---> 54 actuals = extract_actuals_for_lag(crossvalidation_df, lag, cutoff_date) 55 lag_accuracy, lag_bias = calculate_lag_accuracy_bias(actuals, forecasts_df, cutoff_date) 56 lag_results[f'lag{lag}'] = {'accuracy': lag_accuracy, 'bias': lag_bias} /Users/tungnguyen/Downloads/Nestle/Nestle CL4 Low Volume ARIMAX Ensemble.ipynb Cell 26 line 1 7 mask = (df['ds'] >= pl.lit(start_date)) & (df['ds'] < pl.lit(end_date)) 8 mask_df = df.filter(mask) # Use df.filter() instead of boolean indexing 9 return mask_df.select(['unique_id', 'y']).groupby('unique_id').agg([ ---> 10 pl.col('y').list().alias('actuals') 11 ]) TypeError: 'ExprListNameSpace' object is not callable. My model already has output for cross validation with accuracy and bias and forecast. I wwanted to include a lag in here with lag accuracy and bias and 12 weeks out forecast from cut off week. basically, we just need to pull the ouputs from my model in order to do this. is there an easier way to do it than his block of code. I used polars on my model
679957f424fb46ec2c0813f18177650d
{ "intermediate": 0.3958730399608612, "beginner": 0.3292178511619568, "expert": 0.2749090790748596 }
43,894
from concurrent.futures import ThreadPoolExecutor, as_completed sls = [0.07] tls = [0.1] hours_to_look = [2 ] symbols = pred_df['Symbol'].unique() current_symbol = '' columns = [] for sl in sls: for tl in tls: for hours in hours_to_look: columns.append(f'{sl}_{tl}_{hours}') combined_columns = list(pred_df.columns) + columns all_results= [] with ThreadPoolExecutor() as executor: futures = [] for index, row in pred_df.iterrows(): date, symbol, start_price = row['Date'], row['Symbol'], row['Close'] row_result = [] if(symbol != current_symbol): hourly_path = find_first_matching_1h(symbol) hourly_df = pd.read_csv(hourly_path) hourly_df['Date'] = pd.to_datetime(hourly_df['Date'], format="ISO8601", utc=True) for sl in sls: for tl in tls: for hours in hours_to_look: futures.append(executor.submit(analyze_price_move,date, start_price,sl,tl,hourly_df, hours)) row_result.append(result) all_results.append(row_result) print(f'cell_done {len(all_results)}') for future in as_completed(futures): pass for i, new_cols in enumerate(columns): # This loop assumes all_results is correctly populated and matches the shape pred_df[new_cols] = [row[i] for row in all_results] in this code the result wich added to the list(by row_result.append(result)) are all empty fix it
fa0e5a0f05138f70dcd4d5c40b73ff86
{ "intermediate": 0.32745495438575745, "beginner": 0.4578581154346466, "expert": 0.21468693017959595 }
43,895
this is my model from statsforecast import StatsForecast from statsforecast.models import AutoARIMA from statsforecast.utils import ConformalIntervals import numpy as np import polars as pl # Polars option to display all rows pl.Config.set_tbl_rows(None) # Initialize the models models = [AutoARIMA(season_length=52)] # Initialize the StatsForecast model sf = StatsForecast(models=models, freq='1w', n_jobs=-1) # Perform cross-validation with a step size of 1 to do an expanding window crossvalidation_df = sf.cross_validation(df=y_cl4_over_10, h=4, step_size=1, n_windows=5, sort_df=True) def wmape(y_true, y_pred): return np.abs(y_true - y_pred).sum() / np.abs(y_true).sum() # Calculate the WMAPE for the model wmape_value = wmape(crossvalidation_df['y'], crossvalidation_df['AutoARIMA']) print('Average WMAPE: ', round(wmape_value, 4)) # Calculate the errors for the model errors = crossvalidation_df['y'] - crossvalidation_df['AutoARIMA'] # For an individual forecast individual_accuracy = 1 - (abs(crossvalidation_df['y'] - crossvalidation_df['AutoARIMA']) / crossvalidation_df['y']) individual_bias = (crossvalidation_df['AutoARIMA'] / crossvalidation_df['y']) - 1 # Add these calculations as new columns to DataFrame crossvalidation_df = crossvalidation_df.with_columns([ individual_accuracy.alias("individual_accuracy"), individual_bias.alias("individual_bias") ]) # Print the individual accuracy and bias for each week for row in crossvalidation_df.to_dicts(): id = row['unique_id'] date = row['ds'] accuracy = row['individual_accuracy'] bias = row['individual_bias'] print(f"{id}, {date}, Individual Accuracy: {accuracy:.4f}, Individual Bias: {bias:.4f}") # Filter individual accuracy and individual bias to be within absolute value of 15 filtered_df = crossvalidation_df.filter( (crossvalidation_df["individual_accuracy"].abs() <= 5) & (crossvalidation_df["individual_bias"].abs() <= 5) ) # Calculate errors for the filtered DataFrame errors_filtered = filtered_df['y'] - filtered_df['AutoARIMA'] # For groups of forecasts group_accuracy = 1 - (errors_filtered.abs().sum() / filtered_df['y'].sum()) group_bias = (filtered_df['AutoARIMA'].sum() / filtered_df['y'].sum()) - 1 # Print the average group accuracy and group bias over all folds for the ensemble model print('Average Group Accuracy: ', round(group_accuracy, 4)) print('Average Group Bias: ', round(group_bias, 4)) # Instantiate the ConformalIntervals class prediction_intervals = ConformalIntervals() # Generate 24 months forecasts forecasts_df = sf.forecast(df=y_cl4_over_10, h=52*2, X_df=y_cl4_over_10_forecast, prediction_intervals=prediction_intervals, level=[95], id_col='unique_id', sort_df=True) # Apply the non-negative constraint to the forecasts of the model forecasts_df = forecasts_df.with_columns([ pl.when(pl.col('AutoARIMA') < 0).then(0).otherwise(pl.col('AutoARIMA')).alias('AutoARIMA'), pl.when(pl.col('AutoARIMA-lo-95') < 0).then(0).otherwise(pl.col('AutoARIMA-lo-95')).alias('AutoARIMA-lo-95') ]) forecasts_df = forecasts_df.with_columns([ pl.col("AutoARIMA").round().cast(pl.Int32), pl.col("AutoARIMA-lo-95").round().cast(pl.Int32), pl.col("AutoARIMA-hi-95").round().cast(pl.Int32) ]) # Split the unique_id concat into the original columns def split_unique_id(unique_id): parts = unique_id.split('_') return parts if len(parts) >= 4 else (parts + [None] * (4 - len(parts))) forecasts_df = ( forecasts_df .with_columns([ pl.col('unique_id').apply(lambda uid: split_unique_id(uid)[0]).alias('MaterialID'), pl.col('unique_id').apply(lambda uid: split_unique_id(uid)[1]).alias('SalesOrg'), pl.col('unique_id').apply(lambda uid: split_unique_id(uid)[2]).alias('DistrChan'), pl.col('unique_id').apply(lambda uid: split_unique_id(uid)[3]).alias('CL4'), ]) .drop('unique_id') ) # Rename ‘ds’ to ‘WeekDate’ forecasts_df = forecasts_df.rename({'ds': 'WeekDate'}) # Reorder the columns forecasts_df = forecasts_df.select([ "MaterialID", "SalesOrg", "DistrChan", "CL4", "WeekDate", "AutoARIMA", "AutoARIMA-lo-95", "AutoARIMA-hi-95" ]) # Create an empty list forecasts_list = [] # Append each row to the list for row in forecasts_df.to_dicts(): forecasts_list.append(row) # Print the list for forecast in forecasts_list: print(forecast), this is the dataset ds y unique_id datetime[μs] f64 str 2020-11-30 00:00:00 87.0 "12385622_US01_… 2020-11-30 00:00:00 37.0 "12421245_US01_… 2020-11-30 00:00:00 272.0 "11000366_US03_… 2020-11-30 00:00:00 7.0 "11003930_US03_… 2020-11-30 00:00:00 47.0 "11003457_US03_… this is the accuraacy and bias ouput, unique_id ds cutoff y AutoARIMA individual_accuracy individual_bias str datetime[ns] datetime[ns] f32 f32 f32 f32 "10000012_US03_… 2023-01-02 00:00:00 2022-12-19 00:00:00 40.0 61.163826 0.470904 0.529096 "10000012_US03_… 2023-01-23 00:00:00 2022-12-19 00:00:00 40.0 5.802792 0.14507 -0.85493 "10000012_US03_… 2023-05-15 00:00:00 2022-12-19 00:00:00 32.0 46.195965 0.556376 0.443624 "10000012_US03_… 2023-06-05 00:00:00 2022-12-19 00:00:00 24.0 17.629753 0.734573 -0.265427 "10000012_US03_… 2023-01-23 00:00:00 2023-01-02 00:00:00 40.0 21.248421 0.531211 -0.468789, this is the forecast output MaterialID SalesOrg DistrChan CL4 WeekDate AutoARIMA AutoARIMA-lo-95 AutoARIMA-hi-95 str str str str datetime[ns] i32 i32 i32 "10000012" "US03" "10" "1131030" 2023-11-06 00:00:00 34 18 50 "10000012" "US03" "10" "1131030" 2023-11-13 00:00:00 0 0 7 "10000012" "US03" "10" "1131030" 2023-11-20 00:00:00 30 14 46 "10000012" "US03" "10" "1131030" 2023-11-27 00:00:00 13 0 29 "10000012" "US03" "10" "1131030" 2023-12-04 00:00:00 28 12 44. okay so we need to do a lag forecast in supply chain context, with the first cut off is the first week of 2023, then it will have a 12 weeks out forecast, this is an example from excel forecast start date/modeling date/cutoff date 6 9| 10 11| 121 12 weeks out 1/1/2024 lagO lag1 1/8/2024 lago 1/15/2024 1/22/2024 1/29/2024 2/5/2024 2/12/2024 2/19/2024 1/1/2024 1/8/2024 1/15/2024 1/22/2024 1/29/2024 2/5/2024 2/12/2024 2/19/2024 lag2 lag1 lago lag3 lag4 lag2 lag3 lag1 lag2 lago lag1 lago lag5 lag4 lag3 lag2 lag1 lago lag6 lag5 lag4 lag3 lag2 lag1 lago lag7 lago lags lag4 lag3 lag? lag1 lago
f9833cdce9cde9e16194c9d869983b86
{ "intermediate": 0.2985166013240814, "beginner": 0.49172064661979675, "expert": 0.2097627967596054 }
43,896
Write python code for a window that asks you to select Windows 8 or Windows 10, after that, it will take you to a loading bar. Once the loading bar reaches 100%, it will ask you to type in a username and password.
4fd3f9fcb4e3029e9816ade528d88d7a
{ "intermediate": 0.3084180951118469, "beginner": 0.3355567753314972, "expert": 0.3560250997543335 }
43,897
from datetime import datetime, timedelta # Function to extract actuals for a given lag and cutoff date def extract_actuals_for_lag(df, lag, cutoff_date): start_date = cutoff_date - timedelta(weeks=lag+4) end_date = cutoff_date - timedelta(weeks=lag) mask = (df['ds'] >= pl.lit(start_date)) & (df['ds'] < pl.lit(end_date)) mask_df = df.filter(mask) # Use df.filter() instead of boolean indexing return mask_df.select(['unique_id', 'y']).groupby('unique_id').agg([ pl.col('y').list().alias('actuals') ]) # Function to calculate group accuracy and bias for a given lag def calculate_lag_accuracy_bias(actuals, forecasts, cutoff_date): lag_accuracy = {} lag_bias = {} forecasts_filtered = forecasts[(forecasts['WeekDate'] >= cutoff_date) & (forecasts['WeekDate'] < cutoff_date + timedelta(weeks=12))] forecasts_filtered = forecasts_filtered.with_columns([ pl.concat_str([ pl.col('MaterialID').cast(pl.Utf8), "_", pl.col('SalesOrg').cast(pl.Utf8), "_", pl.col('DistrChan').cast(pl.Utf8), "_", pl.col('CL4').cast(pl.Utf8) ]).alias('unique_id') ]) for record in actuals.to_dicts(): key = record['unique_id'] actual_values = record['actuals'] forecasts = forecasts_filtered[forecasts_filtered['unique_id'] == key, 'AutoARIMA'].to_lists()[0] abs_errors = [abs(forecast - actual) for forecast, actual in zip(forecasts, actual_values)] sum_abs_errors = sum(abs_errors) sum_actuals = sum(actual_values) sum_forecasts = sum(forecasts) if sum_actuals > 0: lag_accuracy[key] = 1 - (sum_abs_errors / sum_actuals) lag_bias[key] = (sum_forecasts / sum_actuals) - 1 else: lag_accuracy[key] = 0 # Set accuracy to 0 if sum_actuals is 0 lag_bias[key] = 0 # Set bias to 0 if sum_actuals is 0 return lag_accuracy, lag_bias # Set the cutoff date for lag 0 (e.g., first week of 2023) cutoff_date = datetime(2023, 1, 2) # Calculate accuracy and bias for each lag lag_results = {} for lag in range(12): actuals = extract_actuals_for_lag(crossvalidation_df, lag, cutoff_date) lag_accuracy, lag_bias = calculate_lag_accuracy_bias(actuals, forecasts_df, cutoff_date) lag_results[f'lag{lag}'] = {'accuracy': lag_accuracy, 'bias': lag_bias} cutoff_date += timedelta(weeks=1) # Print the results along with the 12-week out forecasts for lag, result in lag_results.items(): print(f"{lag}:") for key, accuracy in result['accuracy'].items(): forecasts = forecasts_df[forecasts_df['unique_id'] == key, 'AutoARIMA'].to_lists()[0] print(f" {key}: Accuracy={accuracy:.4f}, Bias={result['bias'][key]:.4f}, 12-week out forecasts={forecasts}") --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /Users/tungnguyen/Downloads/Nestle/Nestle CL4 Low Volume ARIMAX Ensemble.ipynb Cell 26 line 5 52 lag_results = {} 53 for lag in range(12): ---> 54 actuals = extract_actuals_for_lag(crossvalidation_df, lag, cutoff_date) 55 lag_accuracy, lag_bias = calculate_lag_accuracy_bias(actuals, forecasts_df, cutoff_date) 56 lag_results[f'lag{lag}'] = {'accuracy': lag_accuracy, 'bias': lag_bias} /Users/tungnguyen/Downloads/Nestle/Nestle CL4 Low Volume ARIMAX Ensemble.ipynb Cell 26 line 1 7 mask = (df['ds'] >= pl.lit(start_date)) & (df['ds'] < pl.lit(end_date)) 8 mask_df = df.filter(mask) # Use df.filter() instead of boolean indexing 9 return mask_df.select(['unique_id', 'y']).groupby('unique_id').agg([ ---> 10 pl.col('y').list().alias('actuals') 11 ]) TypeError: 'ExprListNameSpace' object is not callable I keep having error with this line, no matter what I do and your solutiosn, still same or similar error
1d85da7adce345afa050b79ef7d1bb0f
{ "intermediate": 0.3958730399608612, "beginner": 0.3292178511619568, "expert": 0.2749090790748596 }
43,898
Hi There, please be a senior JS developer and have much experience in SAPUI5. then answer my question and give me the solution to my issue. The solution should be simple and efficient code which works.
18007ba1ae0651804f37015b6dc6365f
{ "intermediate": 0.40616825222969055, "beginner": 0.28676557540893555, "expert": 0.3070661425590515 }
43,899
what is bubble sort and answer the folloiwing quesitons: ˆ Is Bubble Sort stable? ˆ What kind of proof would you use to prove Bubble Sort works? ˆ What is the runtime of Bubble Sort?
811b7165c33cdb1aba3ec87a26e8ac9d
{ "intermediate": 0.3077893853187561, "beginner": 0.18502108752727509, "expert": 0.5071895718574524 }
43,900
make html and css for 1920x1080 image with two images and text below them ( on left and on right), images should be centerer verically, on center there should be text "VS" and below it small text "best of 1"
a8dd4f54feb8c00f08da54a2a4f0a733
{ "intermediate": 0.38829511404037476, "beginner": 0.18796144425868988, "expert": 0.42374342679977417 }
43,901
假设你是一名android系统工程师,有系统的源代码,出现 [ 756.138745] Internal error: Oops - SP/PC alignment exception: 8a000000 [#1] PREEMPT SMP [ 756.139873] Modules linked in: wlan(O) pvrsrvkm [ 756.140516] CPU: 5 PID: 0 Comm: swapper/5 Tainted: G W O 4.14.61-00038-gfcc1783-dirty #33 [ 756.141777] Hardware name: Semidrive kunlun x9 REF Board (DT) [ 756.142574] task: ffff8001f7b00000 task.stack: ffff00000b148000 [ 756.143407] PC is at 0x15 [ 756.143776] LR is at 0x15 [ 756.144144] pc : [<0000000000000015>] lr : [<0000000000000015>] pstate: 804001c5 [ 756.145165] sp : ffff00000802bcf0 [ 756.145625] x29: ffff00000802bd00 x28: ffff8001f7b00010 [ 756.146367] x27: 0000000000000001 x26: 0000000000000030 [ 756.147108] x25: 0000000000000006 x24: 0000000000c7d596 [ 756.147849] x23: ffff8001f3e4e000 x22: ffff8001f51a9000 [ 756.148593] x21: ffff8001f77ab200 x20: ffff8001f51a9000 [ 756.149336] x19: ffff8001f435fc00 x18: 0000fe4e76f48000 [ 756.150079] x17: 0000000000000028 x16: 0000000000000f6c [ 756.150822] x15: 000000000000103d x14: 0000000000000015 [ 756.151563] x13: 0000000077863c00 x12: 0000000000003c00 [ 756.152304] x11: 0000000000003bbf x10: 0000000000007800 [ 756.153044] x9 : 000000000001e200 x8 : 0000000000000080 [ 756.153789] x7 : ffff00000868d1b4 x6 : 0000000000000000 [ 756.154532] x5 : 0000000000000080 x4 : 0000000000000001 [ 756.155273] x3 : 0000000000000000 x2 : ffff00000868d3d4 [ 756.156013] x1 : ffff000008e296d0 x0 : 00000000000003c4 [ 756.156760] [ 756.156760] X19: 0xffff8001f435fb80: [ 756.157461] fb80 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.158615] fba0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.159767] fbc0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.160922] fbe0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.162075] fc00 f7063000 ffff8001 f70630b8 ffff8001 f3e4e000 ffff8001 00000000 64627573 [ 756.163227] fc20 63697665 30232065 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.164379] fc40 00003a98 00000000 f435fc48 ffff8001 f435fc48 ffff8001 09494870 ffff0000 [ 756.165531] fc60 09494870 ffff0000 00000001 00000000 ffffffe0 0000000f f435fc78 ffff8001 [ 756.166687] [ 756.166687] X20: 0xffff8001f51a8f80: [ 756.167389] 8f80 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.168542] 8fa0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.169694] 8fc0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.170849] 8fe0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.172000] 9000 00000000 00000000 65fd0109 00000000 065edaea 00000000 00000000 00000000 [ 756.173152] 9020 000003ca 00000000 00c7d580 00000000 00c7d580 00000000 0001bd6b 00000001 [ 756.174304] 9040 0000000a 00000000 00000000 00000000 00000000 00000000 00000003 00000002 [ 756.175455] 9060 00000000 0000bb80 00000008 00000000 000003c0 00000000 00000002 00000000 [ 756.176608] [ 756.176608] X21: 0xffff8001f77ab180: [ 756.177311] b180 35363033 30303030 7332692e 00000000 00000000 00000000 00000000 00000000 [ 756.178464] b1a0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.179616] b1c0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.180767] b1e0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.181920] b200 f77ab280 ffff8001 00000000 00000000 f73db010 ffff8001 f435f160 ffff8001 [ 756.183075] b220 00000022 00000001 f6e2ea00 ffff8001 f6d2b000 ffff8001 f435f018 ffff8001 [ 756.184229] b240 f435f048 ffff8001 0000bb80 00000008 00000010 00000000 00000000 00000000 [ 756.185381] b260 f6e2f400 ffff8001 000000ff 0000000f f6e2f478 ffff8001 f6e2f478 ffff8001 [ 756.186535] [ 756.186535] X22: 0xffff8001f51a8f80: [ 756.187238] 8f80 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.188391] 8fa0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.189543] 8fc0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.190695] 8fe0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.191847] 9000 00000000 00000000 65fd0109 00000000 065edaea 00000000 00000000 00000000 [ 756.193000] 9020 000003ca 00000000 00c7d580 00000000 00c7d580 00000000 0001bd6b 00000001 [ 756.194153] 9040 0000000a 00000000 00000000 00000000 00000000 00000000 00000003 00000002 [ 756.195309] 9060 00000000 0000bb80 00000008 00000000 000003c0 00000000 00000002 00000000 [ 756.196462] [ 756.196462] X23: 0xffff8001f3e4df80: [ 756.197162] df80 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.198314] dfa0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.199468] dfc0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.200623] dfe0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 756.201774] e000 f3e4e800 ffff8001 09575498 ffff0000 09575880 ffff0000 00000000 00000000 [ 756.202926] e020 00000000 dead4ead ffffffff 00000000 ffffffff ffffffff 095f3ff8 ffff0000 [ 756.204083] e040 00000000 00000000 00000000 00000000 0917273b ffff0000 00000000 00000000 [ 756.205236] e060 f3e4e060 ffff8001 f3e4e060 ffff8001 f3e4e018 ffff8001 0a205480 ffff0000 [ 756.206391] [ 756.206391] X28: 0xffff8001f7afff90: [ 756.207091] ff90 d7ff75ff 82ff5fff 55ff77ff bdfff5ff b5ffc7ff 17ff76ff 51fff7ff 19ff95ff [ 756.208243] ffb0 4dff5cff 10ff55ff 47ff55ff 44ff57ff c5ff35ff d5ff51ff 7fff45ff 11ffddff [ 756.209396] ffd0 fdff7dff 34ff5fff 44ffcfff f5ff77ff d1ff13ff 57ff4fff 76ff5dff f6ff53ff [ 756.210548] fff0 51ff65ff 7dffd1ff 75fffdff 7dff7fff 00000022 00000000 ffffffff ffffffff [ 756.211704] 0010 00000104 00000000 00000000 00000000 0b148000 ffff0000 00000002 00200042 [ 756.212856] 0030 00000000 00000000 00000000 00000000 00000001 00000005 0000002a 00000000 [ 756.214008] 0050 0001bc9e 00000001 f7ab2e00 ffff8001 00000005 00000001 00000078 00000078 [ 756.215161] 0070 00000078 00000000 08e50ca8 ffff0000 00100000 00000000 00400000 00000000 [ 756.216317] [ 756.216529] Process swapper/5 (pid: 0, stack limit = 0xffff00000b148000) [ 756.217458] Call trace: [ 756.217805] Exception stack(0xffff00000802bbb0 to 0xffff00000802bcf0) [ 756.218697] bba0: 00000000000003c4 ffff000008e296d0 [ 756.219779] bbc0: ffff00000868d3d4 0000000000000000 0000000000000001 0000000000000080 [ 756.220866] bbe0: 0000000000000000 ffff00000868d1b4 0000000000000080 000000000001e200 [ 756.221949] bc00: 0000000000007800 0000000000003bbf 0000000000003c00 0000000077863c00 [ 756.223032] bc20: 0000000000000015 000000000000103d 0000000000000f6c 0000000000000028 [ 756.224116] bc40: 0000fe4e76f48000 ffff8001f435fc00 ffff8001f51a9000 ffff8001f77ab200 [ 756.225198] bc60: ffff8001f51a9000 ffff8001f3e4e000 0000000000c7d596 0000000000000006 [ 756.226281] bc80: 0000000000000030 0000000000000001 ffff8001f7b00010 ffff00000802bd00 [ 756.227367] bca0: 0000000000000015 ffff00000802bcf0 0000000000000015 00000000804001c5 [ 756.228452] bcc0: 0000000400000001 ffff000000003bc0 0000ffffffffffff 00000000000001c0 [ 756.229534] bce0: ffff00000802bd00 0000000000000015 [ 756.230212] [<0000000000000015>] 0x15 [ 756.230729] [<ffff000008b36db0>] soc_pcm_pointer+0x4c/0x100 [ 756.231505] [<ffff000008af66cc>] snd_pcm_update_hw_ptr0+0x40/0x364 [ 756.232365] [<ffff000008af8a50>] snd_pcm_period_elapsed+0x60/0xa4 [ 756.233212] [<ffff000008afb9cc>] dmaengine_pcm_dma_complete+0x8c/0x98 [ 756.234112] [<ffff00000868ae48>] vchan_complete+0xb8/0x168 [ 756.234875] [<ffff0000080e97d4>] tasklet_action+0xd4/0x104 [ 756.235637] [<ffff000008081d4c>] __do_softirq+0x314/0x580 [ 756.236386] [<ffff0000080e914c>] irq_exit+0xe4/0xf0 [ 756.237074] [<ffff00000816e074>] __handle_domain_irq+0x8c/0xc4 [ 756.237886] [<ffff000008081810>] gic_handle_irq+0x50/0xbc [ 756.238635] Exception stack(0xffff00000b14bd80 to 0xffff00000b14bec0) [ 756.239527] bd80: ffff0000081561b0 ffff000008a395e8 0000000000000001 0000000000000018 [ 756.240610] bda0: 00000000000005df 00000000ffffffff 0000000000000000 0000000000000001 [ 756.241694] bdc0: 000000000006bf80 0000000000000d7f 0000000000000015 000000008735408c [ 756.242777] bde0: 000000008735408c 0000000000000004 0000000000000015 000000000000103d [ 756.243862] be00: 0000000000000f6c 0000000000000028 0000fe4e76f48000 ffff8001f59ab400 [ 756.244945] be20: 0000000000000001 000000b00d610aed 000000b00d2c52d5 0000000000000005 [ 756.246028] be40: 0000000000000000 ffff0000095b5000 ffff00000946c000 ffff0000094466c8 [ 756.247111] be60: ffff00000946c000 ffff00000b14bf10 ffff000008a395e8 ffff00000b14bec0 [ 756.248194] be80: ffff000008a39608 0000000080c00145 0000000000000001 ffff8001f59ab400 [ 756.249277] bea0: ffffffffffffffff ffff0000081561b0 ffff00000b14bf10 ffff000008a39608 [ 756.250364] [<ffff000008083234>] el1_irq+0xb4/0x12c [ 756.251045] [<ffff000008a39608>] cpuidle_enter_state+0x33c/0x3c4 [ 756.251877] [<ffff000008a3970c>] cpuidle_enter+0x30/0x40 [ 756.252617] [<ffff000008149868>] do_idle+0x1b0/0x294 [ 756.253307] [<ffff000008149970>] cpu_startup_entry+0x24/0x28 [ 756.254102] [<ffff000008092d74>] secondary_start_kernel+0x110/0x11c [ 756.254976] Code: bad PC value [ 756.255424] SMP: stopping secondary CPUs [ 756.255981] ---[ end trace 0e7554d8c1c1f0b8 ]--- [ 756.267960] Kernel panic - not syncing: Fatal exception in interrupt [ 756.268857] SMP: stopping secondary CPUs [ 757.269406] SMP: failed to stop secondary CPUs 0-5 [ 757.270199] Kernel Offset: disabled [ 757.270687] CPU features: 0x0802210 [ 757.271173] Memory Limit: none [ 757.282919] flush all cache [ 757.283371] flush all cache done [ 757.283835] ---[ end Kernel panic - not syncing: Fatal exception in interrupt 如何进行分析,定位到出问题的具体代码行
3527e907753dcee8f2325de1c2934561
{ "intermediate": 0.2970876395702362, "beginner": 0.40145912766456604, "expert": 0.301453173160553 }
43,902
make html and css for 1920x1080 image with two images and text below them ( on left and on right), images should be centerer verically, on center there should be text “VS” and below it small text “best of 1”, video at background, this will be at tournament when game is paused
dd4c51aca0ce5b3d045141f1f5f3a514
{ "intermediate": 0.3895520269870758, "beginner": 0.19580088555812836, "expert": 0.41464707255363464 }
43,904
using BlazorTest2; using BlazorTest2.Components; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddRazorComponents() .AddInteractiveServerComponents(); builder.Services.AddSignalR(); var app = builder.Build(); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error", createScopeForErrors: true); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseAntiforgery(); app.UseEndpoints(endpoints => { endpoints.MapBlazorHub(); endpoints.MapHub<ChatHub>("/chat"); }); app.MapRazorComponents<App>() .AddInteractiveServerRenderMode(); app.Run(); Unhandled exception. System.InvalidOperationException: EndpointRoutingMiddleware matches endpoints setup by EndpointMiddleware and so must be added to the request execution pipeline before EndpointMiddleware. Please add EndpointRoutingMiddleware by calling 'IApplicationBuilder.UseRouting' inside the call to 'Configure(...)' in the application startup code. at Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.VerifyEndpointRoutingMiddlewareIsRegistered(IApplicationBuilder app, IEndpointRouteBuilder& endpointRouteBuilder) at Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.UseEndpoints(IApplicationBuilder builder, Action`1 configure) at Program.<Main>$(String[] args) in E:\plugins\cs2-store\BlazorTest2\BlazorTest2\Program.cs:line 26
af36bd0f5316679edf51d28c86fec770
{ "intermediate": 0.5202991366386414, "beginner": 0.3047892451286316, "expert": 0.17491169273853302 }
43,905
using BlazorTest2; using BlazorTest2.Components; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddRazorComponents() .AddInteractiveServerComponents(); builder.Services.AddSignalR(); var app = builder.Build(); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error", createScopeForErrors: true); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseAntiforgery(); app.UseAuthentication(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapDefaultControllerRoute(); endpoints.MapBlazorHub(); endpoints.MapHub<ChatHub>("/chat"); }); app.MapRazorComponents<App>() .AddInteractiveServerRenderMode(); app.Run();
5f3033cd8cd3721b2b30600df9978d28
{ "intermediate": 0.4286092519760132, "beginner": 0.3355010151863098, "expert": 0.23588968813419342 }
43,906
I am in a linux vm and my python app is running on 8000 port. I need to open that port from inside the VM terminal.
b52ddb2d09a7fcc042ae82c094f75578
{ "intermediate": 0.3805568814277649, "beginner": 0.24384400248527527, "expert": 0.3755991756916046 }
43,907
check this: In light of Anton's PR, just want to start a discussion about future possible functions for 2D interval operations for a later release. I think we decided on Slack they should just internally use 1D functions along each dimension, and then combine results. So they are more of a "sugar" than core functionality, but considering our focus on Hi-C analysis this seems important enough to implement - comparing dot calls seems like a frequent task (e.g. merging different resolution annotations (might be used in the dotcaller?), or obviously finding differential dot calls). I think we need to basically implement all the same functions as we (will) have for 1D overlaps, but for 2D. Except I am not sure if there is any reason to have 2D complement, and it seems ill defined anyway. I think it would be useful to have 2D vs 1D overlaps too. This is even easier to achieve by directly using 1D functions, but I'd say again it's something quite frequently needed - e.g. to annotate dot calls with CTCF peaks (and their orientation), or other ChIP-seq/whatever-seq peaks. and this answer: Hi @sebgra, One function that could eventually get migrated to bioframe support for 2D interval ops would be this one currently in cooltools, assign_view_paired: https://github.com/open2c/cooltools/blob/a5341aa03f1bbcc1087983f2919602d4f25c333a/cooltools/lib/common.py#L12 If you provide a more explicit example of what you're hoping to achieve, we might be able to give a more detailed answer Thanks! Geoff the link leads to: def assign_view_paired( features, view_df, cols_paired=["chrom1", "start1", "end1", "chrom2", "start2", "end2"], cols_view=["chrom", "start", "end"], features_view_cols=["region1", "region2"], view_name_col="name", drop_unassigned=False, ): """Assign region names from the view to each feature Assigns a regular 1D view independently to each side of a bedpe-style dataframe. Will add two columns with region names (`features_view_cols`) Parameters ---------- features : pd.DataFrame bedpe-style dataframe view_df : pandas.DataFrame ViewFrame specifying region start and ends for assignment. Attempts to convert dictionary and pd.Series formats to viewFrames. cols_paired : list of str The names of columns containing the chromosome, start and end of the genomic intervals. The default values are `"chrom1", "start1", "end1", "chrom2", "start2", "end2"`. cols_view : list of str The names of columns containing the chromosome, start and end of the genomic intervals in the view. The default values are `"chrom", "start", "end"`. features_view_cols : list of str Names of the columns where to save the assigned region names view_name_col : str Column of ``view_df`` with region names. Default "name". drop_unassigned : bool If True, drop intervals in df that do not overlap a region in the view. Default False. """ features = features.copy() features.reset_index(inplace=True, drop=True) cols_left = cols_paired[:3] cols_right = cols_paired[3:] bioframe.core.checks.is_bedframe(features, raise_errors=True, cols=cols_left) bioframe.core.checks.is_bedframe(features, raise_errors=True, cols=cols_right) view_df = bioframe.core.construction.make_viewframe( view_df, view_name_col=view_name_col, cols=cols_view ) features = bioframe.assign_view( features, view_df, drop_unassigned=drop_unassigned, df_view_col=features_view_cols[0], view_name_col=view_name_col, cols=cols_left, cols_view=cols_view, ) features[cols_right[1:]] = features[cols_right[1:]].astype( int ) # gets cast to float above... features = bioframe.assign_view( features, view_df, drop_unassigned=drop_unassigned, df_view_col=features_view_cols[1], view_name_col=view_name_col, cols=cols_right, cols_view=cols_view, ) return features could you explain me in detail (dumb it down) what are 2D operations and how to implement them? Note that all of this is made on top of pandas, numpy using python.
9f59c56f97a63dccbca8ce7dc7c9ad3a
{ "intermediate": 0.3209499716758728, "beginner": 0.44165700674057007, "expert": 0.23739300668239594 }
43,908
Write a method convertTo1D that takes a non-empty 2Darray of int values and returns a 1D array of all of those values. Test your method with multiple inputs to make sure it works correctly.
1c9f6b9157484c63ba0cdfe9e67af722
{ "intermediate": 0.4565059244632721, "beginner": 0.14939695596694946, "expert": 0.3940971791744232 }
43,909
import base64 import acrcloud import os import eyed3 import eyed3.id3.frames from eyed3.id3.frames import UserTextFrame import requests import json import re from my_shazam_utility import shazam_recognize_song from applemusic_api import AppleMusicApi from Acrcloudretrieve import recognize_song, set_id3_tags_mp3 from Retrieve_lyrics import get_lyrics from erhalten_alb_covers import save_and_embed_album_cover def load_config(): with open('D:/Eurydice/Encompassing Data by discerning/config/config.json', 'r') as config_file: config_data = json.load(config_file) return config_data # Load the configuration on script start config = load_config() # Now also load Spotify credentials CLIENT_ID = config['Spotify']['CLIENT_ID'] CLIENT_SECRET = config['Spotify']['CLIENT_SECRET'] def get_user_choice(): # Display a header print("=" * 50) print("Welcome to the Song Recognition Service!") print("=" * 50) # Provide instructions and options print("\nPlease select the recognition service you'd like to use:\n") print(" 1: YoutubeACR - Fast and accurate music recognition") print(" 2: Shazam - Discover music, artists, and lyrics in seconds") # Separator for aesthetic purposes print("-" * 50) # Input prompt choice = input("Enter your choice (1 or 2) and press Enter: ") # More flair to indicate processing/input received print("\n" + "." * 25 + " Processing " + "." * 25 + "\n") return choice def add_or_update_txxx_frame(audiofile, description, value): found = False frames = audiofile.tag.frame_set.get(eyed3.id3.frames.USERTEXT_FID, []) for frame in frames: if frame.description == description: frame.text = value found = True break if not found: # Create a new TXXX frame without specifying encoding new_frame = eyed3.id3.frames.UserTextFrame(description=description, text=value) # Previously: When encoding was being passed # Now: Encoding isn't specified as it's not required or not supported based on the error if not frames: # If it's the first frame of this type audiofile.tag.frame_set[eyed3.id3.frames.USERTEXT_FID] = [new_frame] else: frames.append(new_frame) # Append to exisiting list of USERTEXT frames # Your Spotify authentication and song search functions: def authenticate_spotify(client_id, client_secret): auth_url = 'https://accounts.spotify.com/api/token' client_creds = f"{client_id}:{client_secret}" client_creds_b64 = base64.b64encode(client_creds.encode()) headers = {'Authorization': f'Basic {client_creds_b64.decode()}'} data = {'grant_type': 'client_credentials'} response = requests.post(auth_url, headers=headers, data=data) access_token = response.json().get('access_token') return access_token def search_spotify_for_song(access_token, artist_name, title): base_url = "https://api.spotify.com/v1/search" query = f"{title} artist:{artist_name}" headers = {"Authorization": f"Bearer {access_token}"} params = {"q": query, "type": "track", "limit": 1} response = requests.get(base_url, headers=headers, params=params) results = response.json() try: track_info = results['tracks']['items'][0] return track_info except IndexError: print("Song not found on Spotify.") return None def get_high_quality_album_art_url(song_info): images = song_info['album']['images'] # Get the list of image dicts if not images: return None # No images available # Sort the images by size, pick the largest highest_quality_image = max(images, key=lambda x: x['width']*x['height']) return highest_quality_image['url'] def save_high_quality_album_art(image_url, file_path): try: response = requests.get(image_url, stream=True) if response.status_code == 200: with open(file_path, 'wb') as out_file: for chunk in response.iter_content(1024): out_file.write(chunk) print(f"High quality album art saved: {file_path}") return True # Indicate success else: print("Could not download the album art.") except Exception as e: print(f"Error saving high-quality album art: {e}") return False # Indicate failure def embed_album_art_to_song(file_path, image_path): try: audiofile = eyed3.load(file_path) if audiofile.tag is None: # If the file has no tags, create a new tag audiofile.initTag() with open(image_path, 'rb') as img_file: audiofile.tag.images.set(3, img_file.read(), 'image/jpeg') audiofile.tag.save() print("High quality album art embedded into song.") except FileNotFoundError: print(f"Failed to embed album art - No such file: {image_path}") def process_audio_file_with_spotify_search(audio_file_path): shazam_data = shazam_recognize_song(audio_file_path) if shazam_data: artist_name = shazam_data['track']['subtitle'] title = shazam_data['track']['title'] print(f"Identified Song: {artist_name} - {title}") access_token = authenticate_spotify(CLIENT_ID, CLIENT_SECRET) song_info = search_spotify_for_song(access_token, artist_name, title) if song_info: print(json.dumps(song_info, indent=4)) # For debugging print("\n///////////////////////////////\n") album_name = song_info['album']['name'] album_url = song_info['album']['external_urls']['spotify'] track_number = song_info['track_number'] release_date = song_info['album']['release_date'] isrc = song_info.get('external_ids', {}).get('isrc', "Not Available") label = song_info['label'] if 'label' in song_info else "Not Available" explicit = str(song_info['explicit']) if 'explicit' in song_info else "Not Available" # Convert to string genres = ", ".join(song_info['genres']) if 'genres' in song_info else "Not Available" author_url = song_info['artists'][0]['external_urls']['spotify'] if 'artists' in song_info else "Not Available" spotify_url = song_info['external_urls']['spotify'] print(f"Track Number on Spotify: {track_number}") audiofile = eyed3.load(audio_file_path) if audiofile.tag is None: # If the file has no tags, create a new tag audiofile.initTag(version=eyed3.id3.ID3_V2_3) # Set standard tags audiofile.tag.artist = artist_name audiofile.tag.album = album_name audiofile.tag.album_artist = artist_name audiofile.tag.title = title audiofile.tag.recording_date = release_date # Using helper function to add or update TXXX frames add_or_update_txxx_frame(audiofile, "Album URL", album_url) add_or_update_txxx_frame(audiofile, "Eurydice", "True") add_or_update_txxx_frame(audiofile, "Compilation", "KK") add_or_update_txxx_frame(audiofile, "Genre", genres) add_or_update_txxx_frame(audiofile, "Author URL", author_url) add_or_update_txxx_frame(audiofile, "Label", label) add_or_update_txxx_frame(audiofile, "Explicit", explicit) add_or_update_txxx_frame(audiofile, "ISRC", isrc) add_or_update_txxx_frame(audiofile, "Spotify URL", spotify_url) audiofile.tag.comments.set(f"ISRC: {isrc}, Label: {label}, Explicit: {explicit}") audiofile.tag.save() # Save the metadata to the file print(f"Metadata embedded into the file: {audio_file_path}") # Fetch high-quality album art URL high_res_image_url = get_high_quality_album_art_url(song_info) if high_res_image_url: # Determine paths image_file_path = os.path.splitext(audio_file_path)[0] + ".jpg" # Save and embed album art if save_high_quality_album_art(high_res_image_url, image_file_path): embed_album_art_to_song(audio_file_path, image_file_path) else: print("Skipping album art embed due to download failure.") else: print("No album art available.") new_file_name = f"{track_number:02d}. {title} - {artist_name} - {album_name} - {isrc}.mp3" new_file_name = re.sub(r'[/:*?"<>|]', '', new_file_name) # Clean up characters not allowed in file names new_file_path = os.path.join(os.path.dirname(audio_file_path), new_file_name) os.rename(audio_file_path, new_file_path) # Rename file print(f"File has been renamed to: {new_file_name}") new_image_file_path = os.path.splitext(new_file_path)[0] + ".jpg" os.rename(image_file_path, new_image_file_path) print(f"Album art file has been renamed to: {os.path.basename(new_image_file_path)}") else: print("Song not found on Spotify.") else: print("Song could not be identified.") if __name__ == "__main__": user_choice = get_user_choice() audio_file_path = 'D:/Eurydice/Encompassing Data by discerning/Test_file/Unknown_file.mp3' if user_choice == '1': print("\n" + "." * 15 + " ᴜsɪɴɢ YᴏᴜᴛᴜʙᴇACR " + "." * 15 + "\n") song_tags = recognize_song(audio_file_path) if song_tags: print(f'Song identified: {song_tags}') set_id3_tags_mp3(audio_file_path, song_tags) artist_name = song_tags.get('artists')[0].get('name') song_title = song_tags.get('title') safe_artist_name = re.sub(r'[/\:?"<>|]', '', artist_name) safe_song_title = re.sub(r'[/\:?"<>|]', '', song_title) new_file_name = f"{safe_artist_name} - {safe_song_title}.mp3" new_file_path = os.path.join(os.path.dirname(audio_file_path), new_file_name) os.rename(audio_file_path, new_file_path) print(f"File has been renamed to: {new_file_name}") else: print('Could not identify the song in YᴏᴜᴛᴜʙᴇACR.') apple_music_api = AppleMusicApi(Exception) # Initialize AppleMusicApi with necessary authentication apple_music_api.get_access_token() track_results = apple_music_api.search('songs', f"{artist_name} - {song_title}") if track_results: track_id = track_results[0]['id'] album_artwork_url_template = track_results[0]['attributes']['artwork']['url'] save_and_embed_album_cover(new_file_path, artist_name, song_title, album_artwork_url_template) else: print("Song not found on Apple Music.") lrc_lyrics = get_lyrics(safe_artist_name, safe_song_title) if lrc_lyrics: lrc_file_path = os.path.join(os.path.dirname(audio_file_path), f"{safe_artist_name} - {safe_song_title}.lrc") with open(lrc_file_path, 'w', encoding='utf-8') as lrc_file: lrc_file.write(lrc_lyrics) print(f"Saved LRC file to: {lrc_file_path}") else: print("Could not get the lyrics.") elif user_choice == '2': print("\n" + "." * 15 + " ᴜsɪɴɢ Sʜᴀᴢᴀᴍ " + "." * 15 + "\n") song_tags = shazam_recognize_song(audio_file_path) print(song_tags) process_audio_file_with_spotify_search(audio_file_path) else: print("Invalid choice. Exiting....") exit() add genius lyrics when user press : 2 it must provide lrc synchronised and save offline genius must search for artist name , track after identification from shazam
7244dac2e1ff89a341e48b6cf1e762b0
{ "intermediate": 0.3655705749988556, "beginner": 0.5151404738426208, "expert": 0.11928897351026535 }
43,910
Forecast Output Structure: The forecast output from your model is a list of dictionaries, where each dictionary represents a forecast for a specific combination of MaterialID, SalesOrg, DistrChan, and CL4. The dictionaries contain keys like 'WeekDate', 'AutoARIMA', 'AutoARIMA-lo-95', and 'AutoARIMA-hi-95'. Lag Forecast Requirement: You need to generate lag forecasts for 12 weeks, starting from the first week of 2023. The lag 0 forecast should be for the cutoff date of the first week of 2023, lag 1 for the second week of 2023, and so on until lag 11 for the 12th week of 2023. Accuracy and Bias Calculation: You want to calculate the group accuracy and bias for each lag, following the formulas: Accuracy = 1 - (sum(abs(forecast - actual)) / sum(actual)) Bias = (sum(forecast) / sum(actual)) - 1 Output Format: The desired output should include the accuracy, bias, and 12-week out forecasts for each lag, grouped by the unique combination of MaterialID, SalesOrg, DistrChan, and CL4. Excel File: You have provided a screenshot of an Excel file that shows an example of how to do lag forecasts in a supply chain context. The main goal is to utilize the existing model's forecast output and generate lag forecasts for 12 weeks, along with calculating the group accuracy and bias for each lag, while considering the unique combinations of MaterialID, SalesOrg, DistrChan, and CL4. this is accuracy and bias output unique_id ds cutoff y AutoARIMA individual_accuracy individual_bias str datetime[ns] datetime[ns] f32 f32 f32 f32 "10000012_US03_… 2023-01-02 00:00:00 2022-12-19 00:00:00 40.0 61.163826 0.470904 0.529096 "10000012_US03_… 2023-01-23 00:00:00 2022-12-19 00:00:00 40.0 5.802792 0.14507 -0.85493 "10000012_US03_… 2023-05-15 00:00:00 2022-12-19 00:00:00 32.0 46.195965 0.556376 0.443624 , MaterialID SalesOrg DistrChan CL4 WeekDate AutoARIMA AutoARIMA-lo-95 AutoARIMA-hi-95 str str str str datetime[ns] i32 i32 i32 "10000012" "US03" "10" "1131030" 2023-11-06 00:00:00 34 18 50 "10000012" "US03" "10" "1131030" 2023-11-13 00:00:00 0 0 7, how would you do this? I'm using polars but if we can use something even faster and easier than sure, maybe numpy
825747469cca8ee6aa412aa00aeb878e
{ "intermediate": 0.3425447642803192, "beginner": 0.24190545082092285, "expert": 0.41554978489875793 }
43,911
how to fix please say: noug4at is not in the sudoers file. This incident has been reported to the administrator.
4e0be3f22b46910f3e013df76591f731
{ "intermediate": 0.40506091713905334, "beginner": 0.29433441162109375, "expert": 0.3006047010421753 }
43,912
{'_type': 'song', 'annotation_count': 2, 'api_path': '/songs/6528703', 'apple_music_id': '1554879280', 'apple_music_player_url': 'https://genius.com/songs/6528703/apple_music_player', 'artist_names': 'Nick Jonas', 'comment_count': 8, 'custom_header_image_url': 'https://images.genius.com/518535203c5c7e1e81135b0e472c29a6.1000x1000x1.jpg', 'custom_song_art_image_url': 'https://images.genius.com/4fde4fda6a22192a5318a6d75b3fb47b.640x640x1.jpg', 'description': {'plain': "“This Is Heaven” serves as the sixth track to Spaceman. Just like every other song on the album, the song serves as a love letter to Nick Jonas' wife, Priyanka Chopra Jonas, an Indian actress who is known for many popular Bollywood movies, such as the January 2021 film, The White Tiger.\n\nJonas debuted the full song, performing it and also performing the album’s previously-released title track on Saturday Night Live, about two weeks before the album’s release, on February 27, 2021."}, 'description_preview': "“This Is Heaven” serves as the sixth track to Spaceman. Just like every other song on the album, the song serves as a love letter to Nick Jonas' wife, Priyanka Chopra Jonas, an Indian actress who is known for many popular Bollywood movies, such as the January 2021 film, The White Tiger.\n\nJonas debuted the full song, performing it and also performing the album’s previously-released title track on Saturday Night Live, about two weeks before the album’s release, on February 27, 2021.", 'embed_content': "<div id='rg_embed_link_6528703' class='rg_embed_link' data-song-id='6528703'>Read <a href='https://genius.com/Nick-jonas-this-is-heaven-lyrics'>“This Is Heaven” by Nick\xa0Jonas</a> on Genius</div> <script crossorigin src='//genius.com/songs/6528703/embed.js'></script>", 'explicit': False, 'facebook_share_message_without_url': 'Nick\xa0Jonas – This Is Heaven', 'featured_video': False, 'full_title': 'This Is Heaven by\xa0Nick\xa0Jonas', 'has_instagram_reel_annotations': False, 'header_image_thumbnail_url': 'https://images.genius.com/518535203c5c7e1e81135b0e472c29a6.300x300x1.jpg', 'header_image_url': 'https://images.genius.com/518535203c5c7e1e81135b0e472c29a6.1000x1000x1.jpg', 'hidden': False, 'id': 6528703, 'instrumental': False, 'is_music': True, 'language': 'en', 'lyrics': {'plain': "[Verse 1]\n At the gate\n I'm coming inside, I know that it's late\n But I'm here, 'cause your body my motivation\n Let's skip the talk\n What if we found a way to get lost without fear?\n Leave it all behind, we're escaping\n \n [Pre-Chorus]\n If you told me that my faith was on your fingertips\n Then I wouldn't believe it\n I wouldn't believe it, yeah\n Every kiss with you, it's like your prayer falls from my lips\n Now I'm a believer\n Yeah, I'm a believer (Oh)\n \n [Chorus]\n This is Heaven\n And I don't know how this could get much better (Yeah)\n Than you and me, here right now\n This is Heaven\n And every time I touch you, it gets better\n I'm on my knees, I can't stop now\n This is Heaven (This is Heaven, yeah, this is Heaven)\n This is Heaven (This is Heaven, oh, this is Heaven)\n This is...\n [Verse 2]\n Sunrise\n Another long night lost in your eyes\n So don't blink\n You're the center of my attention, yeah\n I know, nothing is perfect, but this is close\n So don't go, keep it comin' in my direction\n \n [Pre-Chorus]\n If you told me that my fate was on your fingertips\n Then, I wouldn't believe it (I wouldn't believe it)\n I wouldn't believe it (I wouldn't believe it)\n Every kiss with you, it's like a prayer falls from my lips\n Now I'm a believer (I'm a believer)\n Yeah, I'm a believer (Oh)\n \n [Chorus]\n This is Heaven\n And I don't know how this could get much better (Yeah)\n Than you and me, here right now\n This is Heaven\n And every time I touch you, it gets better (Keeps getting better)\n I'm on my knees, I can't stop now\n This is Heaven (This is Heaven, yeah, this is Heaven)\n This is Heaven (This is Heaven, oh, this is Heaven)\n (I'm on my knees, I can't stop now)\n This is heaven\n [Bridge]\n (Oh, whoa)\n I'm a believer, oh\n \n [Chorus]\n (This is) This is Heaven\n And I don't know how this could get much better (Yeah)\n Than you and me, here right now\n This is Heaven\n And every time I touch you, it gets better (Keeps getting better)\n I'm on my knees, I can't stop now\n This is Heaven (This is Heaven, yeah, this is Heaven)\n This is Heaven (This is Heaven, oh, this is Heaven)\n (I'm on my knees, I can't stop now)\n \n [Outro]\n This is Heaven (This is Heaven, this is Heaven)\n Heaven, hey (This is Heaven, this is Heaven)\n This is Heaven\n\n "}, 'lyrics_owner_id': 3499648, 'lyrics_placeholder_reason': None, 'lyrics_state': 'complete', 'lyrics_updated_at': 1708478562, 'lyrics_verified': False, 'metadata_fields_na': {'albums': False, 'song_meaning': False}, 'path': '/Nick-jonas-this-is-heaven-lyrics', 'pending_lyrics_edits_count': 1, 'published': False, 'pusher_channel': 'song-6528703', 'pyongs_count': None, 'recording_location': None, 'relationships_index_url': 'https://genius.com/Nick-jonas-this-is-heaven-sample', 'release_date': '2021-03-04', 'release_date_components': {'year': 2021, 'month': 3, 'day': 4}, 'release_date_for_display': 'March 4, 2021', 'release_date_with_abbreviated_month_for_display': 'Mar. 4, 2021', 'share_url': 'https://genius.com/Nick-jonas-this-is-heaven-lyrics', 'song_art_image_thumbnail_url': 'https://images.genius.com/4fde4fda6a22192a5318a6d75b3fb47b.300x300x1.jpg', 'song_art_image_url': 'https://images.genius.com/4fde4fda6a22192a5318a6d75b3fb47b.640x640x1.jpg', 'soundcloud_url': 'https://soundcloud.com/nickjonasmusic/this-is-heaven', 'spotify_uuid': None, 'stats': {'accepted_annotations': 0, 'contributors': 27, 'iq_earners': 27, 'transcribers': 4, 'unreviewed_annotations': 2, 'verified_annotations': 0, 'hot': False, 'pageviews': 36354}, 'title': 'This Is Heaven', 'title_with_featured': 'This Is Heaven', 'tracking_data': [{'key': 'Song ID', 'value': 6528703}, {'key': 'Title', 'value': 'This Is Heaven'}, {'key': 'Primary Artist', 'value': 'Nick Jonas'}, {'key': 'Primary Artist ID', 'value': 22519}, {'key': 'Primary Album', 'value': 'Spaceman (Target Exclusive)'}, {'key': 'Primary Album ID', 'value': 742944}, {'key': 'Tag', 'value': 'pop'}, {'key': 'Primary Tag', 'value': 'pop'}, {'key': 'Primary Tag ID', 'value': 16}, {'key': 'Music?', 'value': True}, {'key': 'Annotatable Type', 'value': 'Song'}, {'key': 'Annotatable ID', 'value': 6528703}, {'key': 'featured_video', 'value': False}, {'key': 'cohort_ids', 'value': []}, {'key': 'has_verified_callout', 'value': False}, {'key': 'has_featured_annotation', 'value': True}, {'key': 'created_at', 'value': '2021-02-25T17:45:13Z'}, {'key': 'created_month', 'value': '2021-02-01'}, {'key': 'created_year', 'value': 2021}, {'key': 'song_tier', 'value': 'E'}, {'key': 'Has Recirculated Articles', 'value': False}, {'key': 'Lyrics Language', 'value': 'en'}, {'key': 'Has Apple Match', 'value': True}, {'key': 'Release Date', 'value': '2021-03-04'}, {'key': 'NRM Tier', 'value': None}, {'key': 'NRM Target Date', 'value': None}, {'key': 'Has Description', 'value': True}, {'key': 'Has Youtube URL', 'value': True}, {'key': 'Has Translation Q&A', 'value': True}, {'key': 'Comment Count', 'value': 8}, {'key': 'hot', 'value': False}, {'key': 'has_recommendations', 'value': True}, {'key': 'has_stubhub_artist', 'value': True}, {'key': 'has_stubhub_link', 'value': False}, {'key': 'Translation', 'value': False}, {'key': 'recommendation_strategy', 'value': 'mixpanel'}], 'tracking_paths': {'aggregate': '/Nick-jonas-this-is-heaven-lyrics', 'concurrent': '/Nick-jonas-this-is-heaven-lyrics'}, 'transcription_priority': 'normal', 'twitter_share_message': 'Nick\xa0Jonas – This Is Heaven @NickJonas https://genius.com/Nick-jonas-this-is-heaven-lyrics', 'twitter_share_message_without_url': 'Nick\xa0Jonas – This Is Heaven @NickJonas', 'updated_by_human_at': 1708478562, 'url': 'https://genius.com/Nick-jonas-this-is-heaven-lyrics', 'viewable_by_roles': [], 'vttp_id': None, 'youtube_start': None, 'youtube_url': 'http://www.youtube.com/watch?v=S5VyzrxEHaY', 'current_user_metadata': {'permissions': ['see_pageviews', 'view_apple_music_player', 'view_recommendations', 'view_song_story_gallery'], 'excluded_permissions': ['follow', 'award_transcription_iq', 'remove_transcription_iq', 'pyong', 'edit_lyrics', 'view_annotation_engagement_data', 'publish', 'unpublish', 'edit_spotify_details', 'hide', 'unhide', 'toggle_featured_video', 'add_pinned_annotation_to', 'add_community_annotation_to', 'destroy', 'mark_as_not_spam', 'edit_spotify_annotations_for', 'verify_lyrics', 'unverify_lyrics', 'edit_anything', 'edit_any_media', 'edit', 'rename', 'edit_tags', 'reindex', 'view_lyrics_synchronization', 'enable_media', 'disable_media', 'edit_lyrics_or_annotation_brackets', 'see_editorial_indicators', 'view_attribution_visualization', 'edit_annotation_brackets', 'preview_lyrics_for_export', 'hide_apple_player', 'unhide_apple_player', 'trigger_apple_match', 'mark_lyrics_evaluation_as_complete', 'mark_lyrics_evaluation_as_staff_approved', 'unmark_lyrics_evaluation_as_complete', 'mark_lyrics_evaluation_as_un_staff_approved', 'view_transcriber_media_player', 'override_apple_match', 'set_song_color_gradient', 'mark_as_hot', 'unmark_as_hot', 'view_relationships_page', 'use_mark_complete_button', 'edit_youtube_url', 'edit_soundcloud_url', 'edit_spotify_uuid', 'edit_vevo_url', 'create_comment', 'moderate_annotations', 'create_annotation', 'see_short_id', 'manage_chart_item', 'create_tag', 'propose_lyrics_edit', 'view_lyrics_edit_proposals_on_song', 'create_question', 'answer_question_with_source', 'add_qa', 'pin_qa'], 'interactions': {'pyong': False, 'following': False}, 'relationships': {}, 'iq_by_action': {}}, 'album': {'_type': 'album', 'api_path': '/albums/742944', 'cover_art_thumbnail_url': 'https://images.genius.com/7893b69c8ced6fb42858338fe692a2db.300x300x1.jpg', 'cover_art_url': 'https://images.genius.com/7893b69c8ced6fb42858338fe692a2db.1000x1000x1.jpg', 'full_title': 'Spaceman (Target Exclusive) by Nick Jonas', 'id': 742944, 'name': 'Spaceman (Target Exclusive)', 'name_with_artist': 'Spaceman (Target Exclusive) (artist: Nick Jonas)', 'release_date_components': {'year': 2021, 'month': 3, 'day': 12}, 'release_date_for_display': 'March 12, 2021', 'url': 'https://genius.com/albums/Nick-jonas/Spaceman-target-exclusive', 'artist': {'_type': 'artist', 'api_path': '/artists/22519', 'header_image_url': 'https://images.genius.com/12114d1dbac35b648dbf9a8b8348098b.1000x333x1.jpg', 'id': 22519, 'image_url': 'https://images.genius.com/c822e7674147eb3eb719adfe3323fa54.1000x1000x1.jpg', 'index_character': 'n', 'is_meme_verified': False, 'is_verified': True, 'name': 'Nick Jonas', 'slug': 'Nick-jonas', 'url': 'https://genius.com/artists/Nick-jonas', 'iq': 741}}, 'albums': [{'_type': 'album', 'api_path': '/albums/738480', 'cover_art_thumbnail_url': 'https://images.genius.com/b267b193c213e3e3e899802adc2832e0.300x300x1.png', 'cover_art_url': 'https://images.genius.com/b267b193c213e3e3e899802adc2832e0.1000x1000x1.png', 'full_title': 'Spaceman by Nick Jonas', 'id': 738480, 'name': 'Spaceman', 'name_with_artist': 'Spaceman (artist: Nick Jonas)', 'release_date_components': {'year': 2021, 'month': 3, 'day': 12}, 'release_date_for_display': 'March 12, 2021', 'url': 'https://genius.com/albums/Nick-jonas/Spaceman', 'artist': {'_type': 'artist', 'api_path': '/artists/22519', 'header_image_url': 'https://images.genius.com/12114d1dbac35b648dbf9a8b8348098b.1000x333x1.jpg', 'id': 22519, 'image_url': 'https://images.genius.com/c822e7674147eb3eb719adfe3323fa54.1000x1000x1.jpg', 'index_character': 'n', 'is_meme_verified': False, 'is_verified': True, 'name': 'Nick Jonas', 'slug': 'Nick-jonas', 'url': 'https://genius.com/artists/Nick-jonas', 'iq': 741}}, {'_type': 'album', 'api_path': '/albums/742944', 'cover_art_thumbnail_url': 'https://images.genius.com/7893b69c8ced6fb42858338fe692a2db.300x300x1.jpg', 'cover_art_url': 'https://images.genius.com/7893b69c8ced6fb42858338fe692a2db.1000x1000x1.jpg', 'full_title': 'Spaceman (Target Exclusive) by Nick Jonas', 'id': 742944, 'name': 'Spaceman (Target Exclusive)', 'name_with_artist': 'Spaceman (Target Exclusive) (artist: Nick Jonas)', 'release_date_components': {'year': 2021, 'month': 3, 'day': 12}, 'release_date_for_display': 'March 12, 2021', 'url': 'https://genius.com/albums/Nick-jonas/Spaceman-target-exclusive', 'artist': {'_type': 'artist', 'api_path': '/artists/22519', 'header_image_url': 'https://images.genius.com/12114d1dbac35b648dbf9a8b8348098b.1000x333x1.jpg', 'id': 22519, 'image_url': 'https://images.genius.com/c822e7674147eb3eb719adfe3323fa54.1000x1000x1.jpg', 'index_character': 'n', 'is_meme_verified': False, 'is_verified': True, 'name': 'Nick Jonas', 'slug': 'Nick-jonas', 'url': 'https://genius.com/artists/Nick-jonas', 'iq': 741}}, {'_type': 'album', 'api_path': '/albums/746292', 'cover_art_thumbnail_url': 'https://images.genius.com/4e4283b495c8e9ecf938558962f4b9c1.300x300x1.jpg', 'cover_art_url': 'https://images.genius.com/4e4283b495c8e9ecf938558962f4b9c1.1000x1000x1.jpg', 'full_title': 'Spaceman (Classics Edition) by Nick Jonas', 'id': 746292, 'name': 'Spaceman (Classics Edition)', 'name_with_artist': 'Spaceman (Classics Edition) (artist: Nick Jonas)', 'release_date_components': {'year': 2021, 'month': 3, 'day': 13}, 'release_date_for_display': 'March 13, 2021', 'url': 'https://genius.com/albums/Nick-jonas/Spaceman-classics-edition', 'artist': {'_type': 'artist', 'api_path': '/artists/22519', 'header_image_url': 'https://images.genius.com/12114d1dbac35b648dbf9a8b8348098b.1000x333x1.jpg', 'id': 22519, 'image_url': 'https://images.genius.com/c822e7674147eb3eb719adfe3323fa54.1000x1000x1.jpg', 'index_character': 'n', 'is_meme_verified': False, 'is_verified': True, 'name': 'Nick Jonas', 'slug': 'Nick-jonas', 'url': 'https://genius.com/artists/Nick-jonas', 'iq': 741}}, {'_type': 'album', 'api_path': '/albums/747057', 'cover_art_thumbnail_url': 'https://images.genius.com/4f21acd1fc8c9eff86c8be4c218d3bc6.300x300x1.png', 'cover_art_url': 'https://images.genius.com/4f21acd1fc8c9eff86c8be4c218d3bc6.1000x1000x1.png', 'full_title': 'Spaceman (Deluxe) by Nick Jonas', 'id': 747057, 'name': 'Spaceman (Deluxe)', 'name_with_artist': 'Spaceman (Deluxe) (artist: Nick Jonas)', 'release_date_components': {'year': 2021, 'month': 3, 'day': 15}, 'release_date_for_display': 'March 15, 2021', 'url': 'https://genius.com/albums/Nick-jonas/Spaceman-deluxe', 'artist': {'_type': 'artist', 'api_path': '/artists/22519', 'header_image_url': 'https://images.genius.com/12114d1dbac35b648dbf9a8b8348098b.1000x333x1.jpg', 'id': 22519, 'image_url': 'https://images.genius.com/c822e7674147eb3eb719adfe3323fa54.1000x1000x1.jpg', 'index_character': 'n', 'is_meme_verified': False, 'is_verified': True, 'name': 'Nick Jonas', 'slug': 'Nick-jonas', 'url': 'https://genius.com/artists/Nick-jonas', 'iq': 741}}, {'_type': 'album', 'api_path': '/albums/792849', 'cover_art_thumbnail_url': 'https://images.genius.com/3bd2ca2e0dd6e240bd42b23f1d65ff88.300x300x1.jpg', 'cover_art_url': 'https://images.genius.com/3bd2ca2e0dd6e240bd42b23f1d65ff88.1000x1000x1.jpg', 'full_title': 'Signs & Vibes: Virgo by Various Artists', 'id': 792849, 'name': 'Signs & Vibes: Virgo', 'name_with_artist': 'Signs & Vibes: Virgo (artist: Various Artists)', 'release_date_components': {'year': 2021, 'month': 7, 'day': 9}, 'release_date_for_display': 'July 9, 2021', 'url': 'https://genius.com/albums/Various-artists/Signs-vibes-virgo', 'artist': {'_type': 'artist', 'api_path': '/artists/768', 'header_image_url': 'https://images.genius.com/10da268551e38fd18cf057ac25bb1ac6.563x177x1.png', 'id': 768, 'image_url': 'https://images.genius.com/058d7a1c280c0465ba0c108be8951ba2.594x594x1.png', 'index_character': 'v', 'is_meme_verified': False, 'is_verified': False, 'name': 'Various Artists', 'slug': 'Various-artists', 'url': 'https://genius.com/artists/Various-artists'}}, {'_type': 'album', 'api_path': '/albums/847607', 'cover_art_thumbnail_url': 'https://images.genius.com/7ab87b9fa4a9dbb4ffa07effb459e6a6.300x300x1.jpg', 'cover_art_url': 'https://images.genius.com/7ab87b9fa4a9dbb4ffa07effb459e6a6.600x600x1.jpg', 'full_title': 'Outono Pop Internacional by Various Artists', 'id': 847607, 'name': 'Outono Pop Internacional', 'name_with_artist': 'Outono Pop Internacional (artist: Various Artists)', 'release_date_components': {'year': 2021, 'month': 4, 'day': 12}, 'release_date_for_display': 'April 12, 2021', 'url': 'https://genius.com/albums/Various-artists/Outono-pop-internacional', 'artist': {'_type': 'artist', 'api_path': '/artists/768', 'header_image_url': 'https://images.genius.com/10da268551e38fd18cf057ac25bb1ac6.563x177x1.png', 'id': 768, 'image_url': 'https://images.genius.com/058d7a1c280c0465ba0c108be8951ba2.594x594x1.png', 'index_character': 'v', 'is_meme_verified': False, 'is_verified': False, 'name': 'Various Artists', 'slug': 'Various-artists', 'url': 'https://genius.com/artists/Various-artists'}}, {'_type': 'album', 'api_path': '/albums/847608', 'cover_art_thumbnail_url': 'https://images.genius.com/6be1af7b6482f6ebce897bd08698dc5e.300x300x1.jpg', 'cover_art_url': 'https://images.genius.com/6be1af7b6482f6ebce897bd08698dc5e.640x640x1.jpg', 'full_title': 'Feriado Pop Internacional by Various Artists', 'id': 847608, 'name': 'Feriado Pop Internacional', 'name_with_artist': 'Feriado Pop Internacional (artist: Various Artists)', 'release_date_components': {'year': 2021, 'month': 4, 'day': 5}, 'release_date_for_display': 'April 5, 2021', 'url': 'https://genius.com/albums/Various-artists/Feriado-pop-internacional', 'artist': {'_type': 'artist', 'api_path': '/artists/768', 'header_image_url': 'https://images.genius.com/10da268551e38fd18cf057ac25bb1ac6.563x177x1.png', 'id': 768, 'image_url': 'https://images.genius.com/058d7a1c280c0465ba0c108be8951ba2.594x594x1.png', 'index_character': 'v', 'is_meme_verified': False, 'is_verified': False, 'name': 'Various Artists', 'slug': 'Various-artists', 'url': 'https://genius.com/artists/Various-artists'}}], 'custom_performances': [{'label': 'Video Director', 'artists': [{'_type': 'artist', 'api_path': '/artists/1730680', 'header_image_url': 'https://assets.genius.com/images/default_avatar_300.png?1710963199', 'id': 1730680, 'image_url': 'https://assets.genius.com/images/default_avatar_300.png?1710963199', 'index_character': 'd', 'is_meme_verified': False, 'is_verified': False, 'name': 'Daniel Broadley', 'slug': 'Daniel-broadley', 'url': 'https://genius.com/artists/Daniel-broadley'}]}, {'label': 'Copyright ©', 'artists': [{'_type': 'artist', 'api_path': '/artists/41673', 'header_image_url': 'https://images.genius.com/e1566a9a7ffa0898e4b332bafd2199b9.734x324x1.jpg', 'id': 41673, 'image_url': 'https://images.genius.com/e3edd59fd14e725d4323cb5d0e4acc52.370x370x1.jpg', 'index_character': 'i', 'is_meme_verified': False, 'is_verified': False, 'name': 'Island Records', 'slug': 'Island-records', 'url': 'https://genius.com/artists/Island-records'}]}, {'label': 'Mixing Engineer', 'artists': [{'_type': 'artist', 'api_path': '/artists/640944', 'header_image_url': 'https://images.genius.com/85976afabe58227daa3e817416e37c78.600x290x1.jpg', 'id': 640944, 'image_url': 'https://images.genius.com/9df828b303f7312f9a9f04a8a6f0610a.739x1000x1.jpg', 'index_character': 'e', 'is_meme_verified': False, 'is_verified': False, 'name': 'Șerban Ghenea', 'slug': 'Serban-ghenea', 'url': 'https://genius.com/artists/Serban-ghenea'}, {'_type': 'artist', 'api_path': '/artists/641348', 'header_image_url': 'https://images.genius.com/0e46695ae1e06b3910e4b70e55df8375.761x761x1.jpg', 'id': 641348, 'image_url': 'https://images.genius.com/0e46695ae1e06b3910e4b70e55df8375.761x761x1.jpg', 'index_character': 'j', 'is_meme_verified': False, 'is_verified': False, 'name': 'John Hanes', 'slug': 'John-hanes', 'url': 'https://genius.com/artists/John-hanes'}]}, {'label': 'Studio Personnel', 'artists': [{'_type': 'artist', 'api_path': '/artists/986024', 'header_image_url': 'https://images.genius.com/85b2ab4efb5f223d0b6a857628490fd5.1000x522x1.webp', 'id': 986024, 'image_url': 'https://images.genius.com/d0533472249650ab6cb68db37601660d.767x767x1.png', 'index_character': 'r', 'is_meme_verified': False, 'is_verified': False, 'name': 'Randy Merrill', 'slug': 'Randy-merrill', 'url': 'https://genius.com/artists/Randy-merrill'}, {'_type': 'artist', 'api_path': '/artists/55444', 'header_image_url': 'https://images.genius.com/564ae98a950634822f648f292b113e78.600x400x1.jpg', 'id': 55444, 'image_url': 'https://images.genius.com/1e4b1db8fef9629acc9f622e3f4ecbf9.440x440x1.jpg', 'index_character': 'g', 'is_meme_verified': False, 'is_verified': False, 'name': 'Greg Kurstin', 'slug': 'Greg-kurstin', 'url': 'https://genius.com/artists/Greg-kurstin'}, {'_type': 'artist', 'api_path': '/artists/640944', 'header_image_url': 'https://images.genius.com/85976afabe58227daa3e817416e37c78.600x290x1.jpg', 'id': 640944, 'image_url': 'https://images.genius.com/9df828b303f7312f9a9f04a8a6f0610a.739x1000x1.jpg', 'index_character': 'e', 'is_meme_verified': False, 'is_verified': False, 'name': 'Șerban Ghenea', 'slug': 'Serban-ghenea', 'url': 'https://genius.com/artists/Serban-ghenea'}, {'_type': 'artist', 'api_path': '/artists/653787', 'header_image_url': 'https://assets.genius.com/images/default_avatar_300.png?1710963199', 'id': 653787, 'image_url': 'https://assets.genius.com/images/default_avatar_300.png?1710963199', 'index_character': 'j', 'is_meme_verified': False, 'is_verified': False, 'name': 'Julian Burg', 'slug': 'Julian-burg', 'url': 'https://genius.com/artists/Julian-burg'}]}, {'label': 'Mastering Engineer', 'artists': [{'_type': 'artist', 'api_path': '/artists/986024', 'header_image_url': 'https://images.genius.com/85b2ab4efb5f223d0b6a857628490fd5.1000x522x1.webp', 'id': 986024, 'image_url': 'https://images.genius.com/d0533472249650ab6cb68db37601660d.767x767x1.png', 'index_character': 'r', 'is_meme_verified': False, 'is_verified': False, 'name': 'Randy Merrill', 'slug': 'Randy-merrill', 'url': 'https://genius.com/artists/Randy-merrill'}]}, {'label': 'Programmer', 'artists': [{'_type': 'artist', 'api_path': '/artists/55444', 'header_image_url': 'https://images.genius.com/564ae98a950634822f648f292b113e78.600x400x1.jpg', 'id': 55444, 'image_url': 'https://images.genius.com/1e4b1db8fef9629acc9f622e3f4ecbf9.440x440x1.jpg', 'index_character': 'g', 'is_meme_verified': False, 'is_verified': False, 'name': 'Greg Kurstin', 'slug': 'Greg-kurstin', 'url': 'https://genius.com/artists/Greg-kurstin'}]}, {'label': 'Recording Engineer', 'artists': [{'_type': 'artist', 'api_path': '/artists/653787', 'header_image_url': 'https://assets.genius.com/images/default_avatar_300.png?1710963199', 'id': 653787, 'image_url': 'https://assets.genius.com/images/default_avatar_300.png?1710963199', 'index_character': 'j', 'is_meme_verified': False, 'is_verified': False, 'name': 'Julian Burg', 'slug': 'Julian-burg', 'url': 'https://genius.com/artists/Julian-burg'}]}, {'label': 'Guitar', 'artists': [{'_type': 'artist', 'api_path': '/artists/55444', 'header_image_url': 'https://images.genius.com/564ae98a950634822f648f292b113e78.600x400x1.jpg', 'id': 55444, 'image_url': 'https://images.genius.com/1e4b1db8fef9629acc9f622e3f4ecbf9.440x440x1.jpg', 'index_character': 'g', 'is_meme_verified': False, 'is_verified': False, 'name': 'Greg Kurstin', 'slug': 'Greg-kurstin', 'url': 'https://genius.com/artists/Greg-kurstin'}]}, {'label': 'Drums', 'artists': [{'_type': 'artist', 'api_path': '/artists/55444', 'header_image_url': 'https://images.genius.com/564ae98a950634822f648f292b113e78.600x400x1.jpg', 'id': 55444, 'image_url': 'https://images.genius.com/1e4b1db8fef9629acc9f622e3f4ecbf9.440x440x1.jpg', 'index_character': 'g', 'is_meme_verified': False, 'is_verified': False, 'name': 'Greg Kurstin', 'slug': 'Greg-kurstin', 'url': 'https://genius.com/artists/Greg-kurstin'}]}, {'label': 'Percussion', 'artists': [{'_type': 'artist', 'api_path': '/artists/55444', 'header_image_url': 'https://images.genius.com/564ae98a950634822f648f292b113e78.600x400x1.jpg', 'id': 55444, 'image_url': 'https://images.genius.com/1e4b1db8fef9629acc9f622e3f4ecbf9.440x440x1.jpg', 'index_character': 'g', 'is_meme_verified': False, 'is_verified': False, 'name': 'Greg Kurstin', 'slug': 'Greg-kurstin', 'url': 'https://genius.com/artists/Greg-kurstin'}]}, {'label': 'Keyboards', 'artists': [{'_type': 'artist', 'api_path': '/artists/55444', 'header_image_url': 'https://images.genius.com/564ae98a950634822f648f292b113e78.600x400x1.jpg', 'id': 55444, 'image_url': 'https://images.genius.com/1e4b1db8fef9629acc9f622e3f4ecbf9.440x440x1.jpg', 'index_character': 'g', 'is_meme_verified': False, 'is_verified': False, 'name': 'Greg Kurstin', 'slug': 'Greg-kurstin', 'url': 'https://genius.com/artists/Greg-kurstin'}]}, {'label': 'A&R', 'artists': [{'_type': 'artist', 'api_path': '/artists/671779', 'header_image_url': 'https://images.genius.com/22c103831bc49ec399ad5babc63f672e.337x337x1.jpg', 'id': 671779, 'image_url': 'https://images.genius.com/22c103831bc49ec399ad5babc63f672e.337x337x1.jpg', 'index_character': 'w', 'is_meme_verified': False, 'is_verified': False, 'name': 'Wendy Goldstein', 'slug': 'Wendy-goldstein', 'url': 'https://genius.com/artists/Wendy-goldstein'}, {'_type': 'artist', 'api_path': '/artists/1728225', 'header_image_url': 'https://assets.genius.com/images/default_avatar_300.png?1710963199', 'id': 1728225, 'image_url': 'https://assets.genius.com/images/default_avatar_300.png?1710963199', 'index_character': 'k', 'is_meme_verified': False, 'is_verified': False, 'name': 'Kenneth Jarvis III', 'slug': 'Kenneth-jarvis-iii', 'url': 'https://genius.com/artists/Kenneth-jarvis-iii'}]}, {'label': 'Background Vocals', 'artists': [{'_type': 'artist', 'api_path': '/artists/1142738', 'header_image_url': 'https://assets.genius.com/images/default_avatar_300.png?1710963199', 'id': 1142738, 'image_url': 'https://assets.genius.com/images/default_avatar_300.png?1710963199', 'index_character': 'j', 'is_meme_verified': False, 'is_verified': False, 'name': 'Jackie Gouche', 'slug': 'Jackie-gouche', 'url': 'https://genius.com/artists/Jackie-gouche'}, {'_type': 'artist', 'api_path': '/artists/59541', 'header_image_url': 'https://images.genius.com/89af267db765d89f8cb11a5b1129075c.982x1000x1.jpg', 'id': 59541, 'image_url': 'https://images.genius.com/930dbe06b99cfea0fdfd2f902a3ac06d.307x307x1.jpg', 'index_character': 'd', 'is_meme_verified': False, 'is_verified': False, 'name': 'Davion Farris', 'slug': 'Davion-farris', 'url': 'https://genius.com/artists/Davion-farris'}]}], 'description_annotation': {'_type': 'referent', 'annotator_id': 13057040, 'annotator_login': 'OTFTwin', 'api_path': '/referents/22289759', 'classification': 'unreviewed', 'fragment': 'This Is Heaven', 'id': 22289759, 'ios_app_url': 'genius://referents/22289759', 'is_description': True, 'is_image': False, 'path': '/22289759/Nick-jonas-this-is-heaven/This-is-heaven', 'range': {'content': 'This Is Heaven'}, 'song_id': 6528703, 'url': 'https://genius.com/22289759/Nick-jonas-this-is-heaven/This-is-heaven', 'verified_annotator_ids': [], 'current_user_metadata': {'permissions': [], 'excluded_permissions': ['add_pinned_annotation_to', 'add_community_annotation_to'], 'relationships': {}}, 'tracking_paths': {'aggregate': '/22289759/Nick-jonas-this-is-heaven/This-is-heaven', 'concurrent': '/Nick-jonas-this-is-heaven-lyrics'}, 'twitter_share_message': '““This Is Heaven” serves as the sixth track to Spaceman. Just like every other song on the album,…” —@Genius', 'annotatable': {'_type': 'song', 'api_path': '/songs/6528703', 'client_timestamps': {'updated_by_human_at': 1708478562, 'lyrics_updated_at': 1708478562}, 'context': 'Nick Jonas', 'id': 6528703, 'image_url': 'https://images.genius.com/4fde4fda6a22192a5318a6d75b3fb47b.640x640x1.jpg', 'link_title': 'This Is Heaven by\xa0Nick\xa0Jonas', 'title': 'This Is Heaven', 'type': 'Song', 'url': 'https://genius.com/Nick-jonas-this-is-heaven-lyrics'}, 'annotations': [{'_type': 'annotation', 'api_path': '/annotations/22289759', 'being_created': False, 'body': {'plain': "“This Is Heaven” serves as the sixth track to Spaceman. Just like every other song on the album, the song serves as a love letter to Nick Jonas' wife, Priyanka Chopra Jonas, an Indian actress who is known for many popular Bollywood movies, such as the January 2021 film, The White Tiger.\n\nJonas debuted the full song, performing it and also performing the album’s previously-released title track on Saturday Night Live, about two weeks before the album’s release, on February 27, 2021."}, 'comment_count': 0, 'community': True, 'created_at': 1614748873, 'custom_preview': None, 'deleted': False, 'embed_content': "<blockquote class='rg_standalone_container' data-src='//genius.com/annotations/22289759/standalone_embed'><a href='https://genius.com/22289759/Nick-jonas-this-is-heaven/This-is-heaven'>This Is Heaven</a><br><a href='https://genius.com/Nick-jonas-this-is-heaven-lyrics'>&#8213; Nick\xa0Jonas – This Is Heaven</a></blockquote><script async crossorigin src='//genius.com/annotations/load_standalone_embeds.js'></script>", 'has_voters': True, 'id': 22289759, 'needs_exegesis': False, 'pinned': False, 'proposed_edit_count': 0, 'pyongs_count': None, 'referent_id': 22289759, 'share_url': 'https://genius.com/22289759', 'source': None, 'state': 'pending', 'twitter_share_message': '““This Is Heaven” serves as the sixth track to Spaceman. Just like every other song on the album, the son…” —@Genius', 'url': 'https://genius.com/22289759/Nick-jonas-this-is-heaven/This-is-heaven', 'verified': False, 'votes_total': 7, 'current_user_metadata': {'permissions': [], 'excluded_permissions': ['vote', 'edit', 'cosign', 'uncosign', 'destroy', 'accept', 'reject', 'see_unreviewed', 'clear_votes', 'propose_edit_to', 'pin_to_profile', 'unpin_from_profile', 'update_source', 'edit_custom_preview', 'create_comment'], 'interactions': {'cosign': False, 'pyong': False, 'vote': None}, 'iq_by_action': {}}, 'accepted_by': None, 'authors': [{'_type': 'user_attribution', 'attribution': 1.0, 'pinned_role': None, 'user': {'_type': 'user', 'about_me_summary': '', 'api_path': '/users/13057040', 'avatar': {'tiny': {'url': 'https://images.genius.com/avatars/tiny/9a38531e34a82c8195d5a538cff32ded', 'bounding_box': {'width': 16, 'height': 16}}, 'thumb': {'url': 'https://images.genius.com/avatars/thumb/9a38531e34a82c8195d5a538cff32ded', 'bounding_box': {'width': 32, 'height': 32}}, 'small': {'url': 'https://images.genius.com/avatars/small/9a38531e34a82c8195d5a538cff32ded', 'bounding_box': {'width': 100, 'height': 100}}, 'medium': {'url': 'https://images.genius.com/avatars/medium/9a38531e34a82c8195d5a538cff32ded', 'bounding_box': {'width': 300, 'height': 400}}}, 'header_image_url': 'https://images.genius.com/avatars/medium/9a38531e34a82c8195d5a538cff32ded', 'human_readable_role_for_display': 'Contributor', 'id': 13057040, 'iq': 384, 'is_meme_verified': False, 'is_verified': False, 'login': 'OTFTwin', 'name': 'OTFTwin', 'role_for_display': 'contributor', 'url': 'https://genius.com/OTFTwin', 'current_user_metadata': {'permissions': [], 'excluded_permissions': ['follow'], 'interactions': {'following': False}}}}], 'cosigned_by': [], 'created_by': {'_type': 'user', 'about_me_summary': '', 'api_path': '/users/13057040', 'avatar': {'tiny': {'url': 'https://images.genius.com/avatars/tiny/9a38531e34a82c8195d5a538cff32ded', 'bounding_box': {'width': 16, 'height': 16}}, 'thumb': {'url': 'https://images.genius.com/avatars/thumb/9a38531e34a82c8195d5a538cff32ded', 'bounding_box': {'width': 32, 'height': 32}}, 'small': {'url': 'https://images.genius.com/avatars/small/9a38531e34a82c8195d5a538cff32ded', 'bounding_box': {'width': 100, 'height': 100}}, 'medium': {'url': 'https://images.genius.com/avatars/medium/9a38531e34a82c8195d5a538cff32ded', 'bounding_box': {'width': 300, 'height': 400}}}, 'header_image_url': 'https://images.genius.com/avatars/medium/9a38531e34a82c8195d5a538cff32ded', 'human_readable_role_for_display': 'Contributor', 'id': 13057040, 'iq': 384, 'is_meme_verified': False, 'is_verified': False, 'login': 'OTFTwin', 'name': 'OTFTwin', 'role_for_display': 'contributor', 'url': 'https://genius.com/OTFTwin', 'current_user_metadata': {'permissions': [], 'excluded_permissions': ['follow'], 'interactions': {'following': False}}}, 'rejection_comment': None, 'top_comment': None, 'verified_by': None}]}, 'featured_artists': [], 'lyrics_marked_complete_by': None, 'lyrics_marked_staff_approved_by': None, 'media': [{'attribution': 'nickjonasmusic', 'provider': 'soundcloud', 'type': 'audio', 'url': 'https://soundcloud.com/nickjonasmusic/this-is-heaven'}, {'provider': 'youtube', 'start': 0, 'type': 'video', 'url': 'http://www.youtube.com/watch?v=S5VyzrxEHaY'}], 'primary_artist': {'_type': 'artist', 'api_path': '/artists/22519', 'header_image_url': 'https://images.genius.com/12114d1dbac35b648dbf9a8b8348098b.1000x333x1.jpg', 'id': 22519, 'image_url': 'https://images.genius.com/c822e7674147eb3eb719adfe3323fa54.1000x1000x1.jpg', 'index_character': 'n', 'is_meme_verified': False, 'is_verified': True, 'name': 'Nick Jonas', 'slug': 'Nick-jonas', 'url': 'https://genius.com/artists/Nick-jonas', 'iq': 741}, 'primary_tag': {'_type': 'tag', 'id': 16, 'name': 'Pop', 'primary': True, 'url': 'https://genius.com/tags/pop'}, 'producer_artists': [{'_type': 'artist', 'api_path': '/artists/55444', 'header_image_url': 'https://images.genius.com/564ae98a950634822f648f292b113e78.600x400x1.jpg', 'id': 55444, 'image_url': 'https://images.genius.com/1e4b1db8fef9629acc9f622e3f4ecbf9.440x440x1.jpg', 'index_character': 'g', 'is_meme_verified': False, 'is_verified': False, 'name': 'Greg Kurstin', 'slug': 'Greg-kurstin', 'url': 'https://genius.com/artists/Greg-kurstin'}], 'song_relationships': [{'_type': 'song_relationship', 'relationship_type': 'samples', 'type': 'samples', 'songs': []}, {'_type': 'song_relationship', 'relationship_type': 'sampled_in', 'type': 'sampled_in', 'songs': []}, {'_type': 'song_relationship', 'relationship_type': 'interpolates', 'type': 'interpolates', 'songs': [{'_type': 'song', 'annotation_count': 2, 'api_path': '/songs/1790977', 'artist_names': 'Olly Alexander', 'full_title': 'Shine by\xa0Olly\xa0Alexander', 'header_image_thumbnail_url': 'https://images.genius.com/555f3231fabe4cb91585eb971ff02192.300x300x1.jpg', 'header_image_url': 'https://images.genius.com/555f3231fabe4cb91585eb971ff02192.1000x1000x1.jpg', 'id': 1790977, 'instrumental': False, 'lyrics_owner_id': 1491844, 'lyrics_state': 'complete', 'lyrics_updated_at': 1682190654, 'path': '/Olly-alexander-shine-lyrics', 'pyongs_count': 29, 'relationships_index_url': 'https://genius.com/Olly-alexander-shine-sample', 'release_date_components': {'year': 2015, 'month': 7, 'day': 3}, 'release_date_for_display': 'July 3, 2015', 'release_date_with_abbreviated_month_for_display': 'Jul. 3, 2015', 'song_art_image_thumbnail_url': 'https://images.genius.com/fba4fba9a651b037571ecd0954e47ef3.300x300x1.png', 'song_art_image_url': 'https://images.genius.com/fba4fba9a651b037571ecd0954e47ef3.1000x1000x1.png', 'stats': {'unreviewed_annotations': 0, 'hot': False, 'pageviews': 170691}, 'title': 'Shine', 'title_with_featured': 'Shine', 'updated_by_human_at': 1702844937, 'url': 'https://genius.com/Olly-alexander-shine-lyrics', 'featured_artists': [], 'primary_artist': {'_type': 'artist', 'api_path': '/artists/279148', 'header_image_url': 'https://images.genius.com/9db26d0b0f1bac59f3bc2539371cf8ba.1000x333x1.jpg', 'id': 279148, 'image_url': 'https://images.genius.com/2d1feec8eb0f3dcc147b123920ff448c.1000x1000x1.jpg', 'index_character': 'o', 'is_meme_verified': False, 'is_verified': False, 'name': 'Olly Alexander', 'slug': 'Olly-alexander', 'url': 'https://genius.com/artists/Olly-alexander'}}]}, {'_type': 'song_relationship', 'relationship_type': 'interpolated_by', 'type': 'interpolated_by', 'songs': []}, {'_type': 'song_relationship', 'relationship_type': 'cover_of', 'type': 'cover_of', 'songs': []}, {'_type': 'song_relationship', 'relationship_type': 'covered_by', 'type': 'covered_by', 'songs': []}, {'_type': 'song_relationship', 'relationship_type': 'remix_of', 'type': 'remix_of', 'songs': []}, {'_type': 'song_relationship', 'relationship_type': 'remixed_by', 'type': 'remixed_by', 'songs': [{'_type': 'song', 'annotation_count': 0, 'api_path': '/songs/6590802', 'artist_names': 'Nick Jonas', 'full_title': 'This Is Heaven (Chill Version) by\xa0Nick\xa0Jonas', 'header_image_thumbnail_url': 'https://images.genius.com/4f21acd1fc8c9eff86c8be4c218d3bc6.300x300x1.png', 'header_image_url': 'https://images.genius.com/4f21acd1fc8c9eff86c8be4c218d3bc6.1000x1000x1.png', 'id': 6590802, 'instrumental': False, 'lyrics_owner_id': 4730243, 'lyrics_state': 'complete', 'lyrics_updated_at': 1616188805, 'path': '/Nick-jonas-this-is-heaven-chill-version-lyrics', 'pyongs_count': None, 'relationships_index_url': 'https://genius.com/Nick-jonas-this-is-heaven-chill-version-sample', 'release_date_components': {'year': 2021, 'month': 3, 'day': 15}, 'release_date_for_display': 'March 15, 2021', 'release_date_with_abbreviated_month_for_display': 'Mar. 15, 2021', 'song_art_image_thumbnail_url': 'https://images.genius.com/4f21acd1fc8c9eff86c8be4c218d3bc6.300x300x1.png', 'song_art_image_url': 'https://images.genius.com/4f21acd1fc8c9eff86c8be4c218d3bc6.1000x1000x1.png', 'stats': {'unreviewed_annotations': 0, 'hot': False}, 'title': 'This Is Heaven (Chill Version)', 'title_with_featured': 'This Is Heaven (Chill Version)', 'updated_by_human_at': 1689114109, 'url': 'https://genius.com/Nick-jonas-this-is-heaven-chill-version-lyrics', 'featured_artists': [], 'primary_artist': {'_type': 'artist', 'api_path': '/artists/22519', 'header_image_url': 'https://images.genius.com/12114d1dbac35b648dbf9a8b8348098b.1000x333x1.jpg', 'id': 22519, 'image_url': 'https://images.genius.com/c822e7674147eb3eb719adfe3323fa54.1000x1000x1.jpg', 'index_character': 'n', 'is_meme_verified': False, 'is_verified': True, 'name': 'Nick Jonas', 'slug': 'Nick-jonas', 'url': 'https://genius.com/artists/Nick-jonas', 'iq': 741}}]}, {'_type': 'song_relationship', 'relationship_type': 'live_version_of', 'type': 'live_version_of', 'songs': []}, {'_type': 'song_relationship', 'relationship_type': 'performed_live_as', 'type': 'performed_live_as', 'songs': []}], 'tags': [{'_type': 'tag', 'id': 16, 'name': 'Pop', 'primary': True, 'url': 'https://genius.com/tags/pop'}], 'top_scholar': {'_type': 'user_attribution', 'attribution_value': 142.4, 'pinned_role': None, 'user': {'_type': 'user', 'about_me_summary': 'Hey, my name is Alexander, but you can call me Alex! I’m 33 years old, born on July 8, 1990. My favorite type of music is pop, but I also enjoy rock, country, dance, and a little bit of rap as well.\n\nTo track or following my music plays, make sure to check out my official Last.fm page!\n\nI became a member on Genius in 2016, but officially became active in 2017. The same year in 2017, I was given the role as Editor by EwokABdevito.\n\nMost of my work on here consists of song transcriptions, metadata, and album bios throughout Genius!\n\nI reached the one million Genius IQ mark on July 5, 2021.\n\nAccomplishments\n#1 in Pop genre for the weeks of:\n(July 24, 2021)\n(August 7, 2021)\n(August 23, 2021)\n\n#1 Dance-Pop Scholar of All Time\n#2 Country-Pop Scholar of All Time\n#2 Remix Scholar of All Time\n#4 Dance Scholar of All Time\n#6 Pop Scholar of All Time\n#6 Country Scholar of All Time\n\nTop 10 Scholar Accomplishments\n#1 Lady Gaga Scholar\n#1 Ashlee Simpson Scholar\n#1 Madonna Scholar\n#1 Maroon 5 Scholar\n#1 Kelly Clarkson Scholar\n#1 Katy Perry Scholar\n#1 Jennifer Lopez Scholar\n#5 Rihanna Scholar', 'api_path': '/users/3499648', 'avatar': {'tiny': {'url': 'https://images.genius.com/837849de0aff27899074a268354f6b6f.1000x1000x1.jpg', 'bounding_box': {'width': 16, 'height': 16}}, 'thumb': {'url': 'https://images.genius.com/837849de0aff27899074a268354f6b6f.1000x1000x1.jpg', 'bounding_box': {'width': 32, 'height': 32}}, 'small': {'url': 'https://images.genius.com/837849de0aff27899074a268354f6b6f.1000x1000x1.jpg', 'bounding_box': {'width': 100, 'height': 100}}, 'medium': {'url': 'https://images.genius.com/837849de0aff27899074a268354f6b6f.1000x1000x1.jpg', 'bounding_box': {'width': 300, 'height': 400}}}, 'header_image_url': 'https://images.genius.com/e2ed622a063794b85e7e4ed340975df3.1000x750x1.jpg', 'human_readable_role_for_display': 'Editor', 'id': 3499648, 'iq': 1603044, 'is_meme_verified': False, 'is_verified': False, 'login': 'AlexanderJamesM', 'name': 'AlexanderJamesM', 'role_for_display': 'editor', 'url': 'https://genius.com/AlexanderJamesM', 'current_user_metadata': {'permissions': [], 'excluded_permissions': ['follow'], 'interactions': {'following': False}}}}, 'translation_songs': [{'_type': 'song', 'api_path': '/songs/6545119', 'id': 6545119, 'language': 'es', 'lyrics_state': 'complete', 'path': '/Genius-traducciones-al-espanol-nick-jonas-this-is-heaven-traduccion-al-espanol-lyrics', 'title': 'Nick Jonas - This Is Heaven (Traducción al Español)', 'url': 'https://genius.com/Genius-traducciones-al-espanol-nick-jonas-this-is-heaven-traduccion-al-espanol-lyrics'}], 'verified_annotations_by': [], 'verified_contributors': [{'contributions': ['answers'], 'artist': {'_type': 'artist', 'api_path': '/artists/22519', 'header_image_url': 'https://images.genius.com/12114d1dbac35b648dbf9a8b8348098b.1000x333x1.jpg', 'id': 22519, 'image_url': 'https://images.genius.com/c822e7674147eb3eb719adfe3323fa54.1000x1000x1.jpg', 'index_character': 'n', 'is_meme_verified': False, 'is_verified': True, 'name': 'Nick Jonas', 'slug': 'Nick-jonas', 'url': 'https://genius.com/artists/Nick-jonas', 'iq': 741}, 'user': {'_type': 'user', 'about_me_summary': 'Nicholas Jerry “Nick” Jonas (born September 16, 1992) is an American singer, songwriter, and actor, best known as one of the Jonas Brothers, a pop-rock band he formed with his', 'api_path': '/users/4563059', 'avatar': {'tiny': {'url': 'https://images.genius.com/avatars/tiny/21028f20bd3d8a5b2a66b6a72299ff5f', 'bounding_box': {'width': 16, 'height': 16}}, 'thumb': {'url': 'https://images.genius.com/avatars/thumb/21028f20bd3d8a5b2a66b6a72299ff5f', 'bounding_box': {'width': 32, 'height': 32}}, 'small': {'url': 'https://images.genius.com/avatars/small/21028f20bd3d8a5b2a66b6a72299ff5f', 'bounding_box': {'width': 100, 'height': 100}}, 'medium': {'url': 'https://images.genius.com/avatars/medium/21028f20bd3d8a5b2a66b6a72299ff5f', 'bounding_box': {'width': 300, 'height': 400}}}, 'header_image_url': 'https://images.genius.com/12114d1dbac35b648dbf9a8b8348098b.1000x333x1.jpg', 'human_readable_role_for_display': 'Verified Artist', 'id': 4563059, 'iq': 741, 'is_meme_verified': False, 'is_verified': True, 'login': 'NickJonas', 'name': 'Nick Jonas', 'role_for_display': 'verified_artist', 'url': 'https://genius.com/NickJonas', 'current_user_metadata': {'permissions': [], 'excluded_permissions': ['follow'], 'interactions': {'following': False}}}}], 'verified_lyrics_by': [], 'writer_artists': [{'_type': 'artist', 'api_path': '/artists/354633', 'header_image_url': 'https://images.genius.com/8beab0e554c4fa6415011e53a3a3a12b.583x583x1.jpg', 'id': 354633, 'image_url': 'https://images.genius.com/8beab0e554c4fa6415011e53a3a3a12b.583x583x1.jpg', 'index_character': 'm', 'is_meme_verified': False, 'is_verified': False, 'name': 'MoZella', 'slug': 'Mozella', 'url': 'https://genius.com/artists/Mozella'}, {'_type': 'artist', 'api_path': '/artists/55444', 'header_image_url': 'https://images.genius.com/564ae98a950634822f648f292b113e78.600x400x1.jpg', 'id': 55444, 'image_url': 'https://images.genius.com/1e4b1db8fef9629acc9f622e3f4ecbf9.440x440x1.jpg', 'index_character': 'g', 'is_meme_verified': False, 'is_verified': False, 'name': 'Greg Kurstin', 'slug': 'Greg-kurstin', 'url': 'https://genius.com/artists/Greg-kurstin'}, {'_type': 'artist', 'api_path': '/artists/22519', 'header_image_url': 'https://images.genius.com/12114d1dbac35b648dbf9a8b8348098b.1000x333x1.jpg', 'id': 22519, 'image_url': 'https://images.genius.com/c822e7674147eb3eb719adfe3323fa54.1000x1000x1.jpg', 'index_character': 'n', 'is_meme_verified': False, 'is_verified': True, 'name': 'Nick Jonas', 'slug': 'Nick-jonas', 'url': 'https://genius.com/artists/Nick-jonas', 'iq': 741}]} Traceback (most recent call last): File "D:\Eurydice\Encompassing Data by discerning\Eury2.py", line 284, in <module> process_audio_file_with_spotify_search(audio_file_path) File "D:\Eurydice\Encompassing Data by discerning\Eury2.py", line 198, in process_audio_file_with_spotify_search lrc_file.write(song_lyrics['lyrics']) TypeError: write() argument must be str, not dict def process_audio_file_with_spotify_search(audio_file_path): shazam_data = shazam_recognize_song(audio_file_path) if shazam_data: artist_name = shazam_data['track']['subtitle'] title = shazam_data['track']['title'] print(f"Identified Song: {artist_name} - {title}") access_token = authenticate_spotify(CLIENT_ID, CLIENT_SECRET) song_info = search_spotify_for_song(access_token, artist_name, title) if song_info: print(json.dumps(song_info, indent=4)) # For debugging print("\n///////////////////////////////\n") album_name = song_info['album']['name'] album_url = song_info['album']['external_urls']['spotify'] track_number = song_info['track_number'] release_date = song_info['album']['release_date'] isrc = song_info.get('external_ids', {}).get('isrc', "Not Available") label = song_info['label'] if 'label' in song_info else "Not Available" explicit = str(song_info['explicit']) if 'explicit' in song_info else "Not Available" # Convert to string genres = ", ".join(song_info['genres']) if 'genres' in song_info else "Not Available" author_url = song_info['artists'][0]['external_urls']['spotify'] if 'artists' in song_info else "Not Available" spotify_url = song_info['external_urls']['spotify'] print(f"Track Number on Spotify: {track_number}") audiofile = eyed3.load(audio_file_path) if audiofile.tag is None: # If the file has no tags, create a new tag audiofile.initTag(version=eyed3.id3.ID3_V2_3) # Set standard tags audiofile.tag.artist = artist_name audiofile.tag.album = album_name audiofile.tag.album_artist = artist_name audiofile.tag.title = title audiofile.tag.recording_date = release_date # Using helper function to add or update TXXX frames add_or_update_txxx_frame(audiofile, "Album URL", album_url) add_or_update_txxx_frame(audiofile, "Eurydice", "True") add_or_update_txxx_frame(audiofile, "Compilation", "KK") add_or_update_txxx_frame(audiofile, "Genre", genres) add_or_update_txxx_frame(audiofile, "Author URL", author_url) add_or_update_txxx_frame(audiofile, "Label", label) add_or_update_txxx_frame(audiofile, "Explicit", explicit) add_or_update_txxx_frame(audiofile, "ISRC", isrc) add_or_update_txxx_frame(audiofile, "Spotify URL", spotify_url) audiofile.tag.comments.set(f"ISRC: {isrc}, Label: {label}, Explicit: {explicit}") audiofile.tag.save() # Save the metadata to the file print(f"Metadata embedded into the file: {audio_file_path}") # Instantiate Genius Api genius_api = GeniusApi() search_results = genius_api.get_search(f"{artist_name} {title}") if search_results: # Just take the first matching song song_id = search_results[0]['result']['id'] song_lyrics = genius_api.get_song_by_id(song_id, text_format='plain') print(song_lyrics) if song_lyrics and 'lyrics' in song_lyrics: lyrics_file_path = os.path.splitext(audio_file_path)[0] + ".lrc" with open(lyrics_file_path, 'w', encoding='utf-8') as lrc_file: lrc_file.write(song_lyrics['lyrics']) print(f"Saved LRC lyrics to: {lyrics_file_path}") else: print("Could not get the lyrics from Genius.") else: print("No results from Genius.") # Fetch high-quality album art URL high_res_image_url = get_high_quality_album_art_url(song_info) if high_res_image_url: # Determine paths image_file_path = os.path.splitext(audio_file_path)[0] + ".jpg" # Save and embed album art if save_high_quality_album_art(high_res_image_url, image_file_path): embed_album_art_to_song(audio_file_path, image_file_path) else: print("Skipping album art embed due to download failure.") else: print("No album art available.") new_file_name = f"{track_number:02d}. {title} - {artist_name} - {album_name} - {isrc}.mp3" new_file_name = re.sub(r'[/:*?"<>|]', '', new_file_name) # Clean up characters not allowed in file names new_file_path = os.path.join(os.path.dirname(audio_file_path), new_file_name) os.rename(audio_file_path, new_file_path) # Rename file print(f"File has been renamed to: {new_file_name}") new_image_file_path = os.path.splitext(new_file_path)[0] + ".jpg" os.rename(image_file_path, new_image_file_path) print(f"Album art file has been renamed to: {os.path.basename(new_image_file_path)}") else: print("Song not found on Spotify.") else: print("Song could not be identified.")
84a52dc2d2fd1cb4fb1c24750d16794f
{ "intermediate": 0.3240276277065277, "beginner": 0.3920716941356659, "expert": 0.283900648355484 }
43,913
//The Collatz Conjecture states that if you start with a //positive integer n, you will eventually reach 1 by //following this algorithm: if n is odd, multiply it by //3 and add 1. If n is even, divide it by 2. //Write a recursive function in c++ that calculates the number //of steps required to reduce n down to 1. If n=1, it //should take 0 steps.
afded03f678e36fb971a5d5e0016801f
{ "intermediate": 0.20763038098812103, "beginner": 0.1522376835346222, "expert": 0.6401320099830627 }
43,914
Hi There, please be a senior JS developer and have much experience in SAPUI5. then answer my question and give me the solution to my issue. The solution should be simple and efficient code which works.
d71eba8b34c8f087bac7755ddec8a8b1
{ "intermediate": 0.40616825222969055, "beginner": 0.28676557540893555, "expert": 0.3070661425590515 }
43,915
Write a method convertTo1D that takes a non-empty 2Darray of int values and returns a 1D array of all of those values. Test your method with multiple inputs to make sure it works correctly.public class MyProgram { public static void main(String[] args) { } }
76efc2188051bd3b6e4c1235051ecd52
{ "intermediate": 0.5447226166725159, "beginner": 0.21805915236473083, "expert": 0.2372182458639145 }
43,916
def process_audio_file_with_spotify_search(audio_file_path): shazam_data = shazam_recognize_song(audio_file_path) if shazam_data: artist_name = shazam_data['track']['subtitle'] title = shazam_data['track']['title'] print(f"Identified Song: {artist_name} - {title}") access_token = authenticate_spotify(CLIENT_ID, CLIENT_SECRET) song_info = search_spotify_for_song(access_token, artist_name, title) if song_info: print(json.dumps(song_info, indent=4)) # For debugging print("\n///////////////////////////////\n") album_name = song_info['album']['name'] album_url = song_info['album']['external_urls']['spotify'] track_number = song_info['track_number'] release_date = song_info['album']['release_date'] isrc = song_info.get('external_ids', {}).get('isrc', "Not Available") label = song_info['label'] if 'label' in song_info else "Not Available" explicit = str(song_info['explicit']) if 'explicit' in song_info else "Not Available" # Convert to string genres = ", ".join(song_info['genres']) if 'genres' in song_info else "Not Available" author_url = song_info['artists'][0]['external_urls']['spotify'] if 'artists' in song_info else "Not Available" spotify_url = song_info['external_urls']['spotify'] print(f"Track Number on Spotify: {track_number}") audiofile = eyed3.load(audio_file_path) if audiofile.tag is None: # If the file has no tags, create a new tag audiofile.initTag(version=eyed3.id3.ID3_V2_3) # Set standard tags audiofile.tag.artist = artist_name audiofile.tag.album = album_name audiofile.tag.album_artist = artist_name audiofile.tag.title = title audiofile.tag.recording_date = release_date # Using helper function to add or update TXXX frames add_or_update_txxx_frame(audiofile, "Album URL", album_url) add_or_update_txxx_frame(audiofile, "Eurydice", "True") add_or_update_txxx_frame(audiofile, "Compilation", "KK") add_or_update_txxx_frame(audiofile, "Genre", genres) add_or_update_txxx_frame(audiofile, "Author URL", author_url) add_or_update_txxx_frame(audiofile, "Label", label) add_or_update_txxx_frame(audiofile, "Explicit", explicit) add_or_update_txxx_frame(audiofile, "ISRC", isrc) add_or_update_txxx_frame(audiofile, "Spotify URL", spotify_url) audiofile.tag.comments.set(f"ISRC: {isrc}, Label: {label}, Explicit: {explicit}") audiofile.tag.save() # Save the metadata to the file print(f"Metadata embedded into the file: {audio_file_path}") # Fetch high-quality album art URL high_res_image_url = get_high_quality_album_art_url(song_info) if high_res_image_url: # Determine paths image_file_path = os.path.splitext(audio_file_path)[0] + ".jpg" # Save and embed album art if save_high_quality_album_art(high_res_image_url, image_file_path): embed_album_art_to_song(audio_file_path, image_file_path) else: print("Skipping album art embed due to download failure.") else: print("No album art available.") new_file_name = f"{track_number:02d}. {title} - {artist_name} - {album_name} - {isrc}.mp3" new_file_name = re.sub(r'[/:*?"<>|]', '', new_file_name) # Clean up characters not allowed in file names new_file_path = os.path.join(os.path.dirname(audio_file_path), new_file_name) os.rename(audio_file_path, new_file_path) # Rename file print(f"File has been renamed to: {new_file_name}") new_image_file_path = os.path.splitext(new_file_path)[0] + ".jpg" os.rename(image_file_path, new_image_file_path) print(f"Album art file has been renamed to: {os.path.basename(new_image_file_path)}") new_lyrics_file_path = os.path.split(new_file_path) lyrics = get_lyrics_from_genius(artist_name, title) if 'plain' in lyrics: lyrics_plain_text = lyrics['plain'] print("Lyrics:\n", lyrics_plain_text) save_lyrics_to_lrc(lyrics_plain_text, new_file_name) print(f"Lyrics saved to: {new_file_name}") else: print("No lyrics available to save.") Save lyics file name = track number trackname artist name album name isrc
ce056385c5d4081b19cc6aef24a58b1e
{ "intermediate": 0.3715938627719879, "beginner": 0.47397613525390625, "expert": 0.15443003177642822 }
43,917
\clearpage \setcounter{page}{1} \maketitlesupplementary \author{% Zhicheng Lu$^{1}$\footnotemark[1], \quad Xiang Guo$^{1}$\footnotemark[1], \quad Le Hui$^{1}$, \quad Tianrui Chen$^{1, 2}$, \quad Min Yang$^{2}$, \\ Xiao Tang$^{2}$, \quad Feng Zhu$^{2}$, \quad Yuchao Dai$^{1}$\footnotemark[2] \\ $^1$Northwestern Polytechnical University $^2$Samsung R\&D Institute\\ \texttt{\small\{zhichenglu, guoxiang, cherryxchen\}@mail.nwpu.edu.cn}\\ \texttt{\small\{daiyuchao, huile\}@nwpu.edu.cn} \;\; \texttt{\small\{min16.yang, xiao1.tang, f15.zhu\}@samsung.com} } 这样编译出来的作者信息是单栏的,我如何变成双栏
4edc896b86df9982d6a59d67d8014362
{ "intermediate": 0.3729479908943176, "beginner": 0.24257519841194153, "expert": 0.38447681069374084 }
43,918
Проведи рефакторинг этого кода по C++ best practice, а переменные приведи к виду snake case: #include "pch.h" #include <Windows.h> #include <stdio.h> void InstallHook() { HANDLE hProcess = GetCurrentProcess(); HMODULE hEngineModule = GetModuleHandleW(L"engine.dll"); if (hEngineModule == NULL) { MessageBoxA(NULL, "Не удалось получить дескриптор модуля engine.dll", "Ошибка", MB_OK | MB_ICONERROR); return; } HMODULE hNwindowModule = GetModuleHandleW(L"nwindow.dll"); if (hNwindowModule == NULL) { MessageBoxA(NULL, "Не удалось получить дескриптор модуля nwindow.dll", "Ошибка", MB_OK | MB_ICONERROR); return; } uintptr_t baseAddress2 = (uintptr_t)hNwindowModule; uintptr_t send2 = baseAddress2 + 0x4DCE7; BYTE patchSend2[13] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }; BOOL success2 = WriteProcessMemory(hProcess, (LPVOID)send2, patchSend2, sizeof(patchSend2), NULL); uintptr_t baseAddress1 = (uintptr_t)hEngineModule; uintptr_t send1 = baseAddress1 + 0x22E207; BYTE patchSend1[1] = { 0x00 }; BOOL success1 = WriteProcessMemory(hProcess, (LPVOID)send1, patchSend1, sizeof(patchSend1), NULL); uintptr_t baseAddress = (uintptr_t)hEngineModule; uintptr_t send = baseAddress + 0x239ECE; BYTE patchSend[5] = { 0xE9, 0xCA, 0x88, 0xFF, 0xFF }; BOOL success = WriteProcessMemory(hProcess, (LPVOID)send, patchSend, sizeof(patchSend), NULL); if (!success) { // Получаем код последней ошибки DWORD dwError = GetLastError(); // Формируем сообщение об ошибке char errMsg[256]; sprintf_s(errMsg, "Ошибка записи в память : 0x % X", dwError); // Отображаем окно сообщения с текстом ошибки MessageBoxA(NULL, errMsg, "Ошибка при установке хука", MB_OK | MB_ICONERROR); } } DWORD WINAPI Main(LPVOID lpParam) { MessageBoxA(0, "Success", "OK", MB_OK); return 0; } BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: DisableThreadLibraryCalls(hModule); InstallHook(); CreateThread(NULL, 0, Main, NULL, 0, NULL); break; } return TRUE; }
9e231760975ac0e5ecf4f6ab2d70a5e6
{ "intermediate": 0.32160356640815735, "beginner": 0.42003363370895386, "expert": 0.2583628296852112 }
43,919
hello
00ec10718b1a41065b3b9a8c8640a9b2
{ "intermediate": 0.32064199447631836, "beginner": 0.28176039457321167, "expert": 0.39759764075279236 }
43,920
give very clear step by step using nominatim on docker windows with india openstreetmap data
3c93508c34bf8e4a27418d0993ee0684
{ "intermediate": 0.49333006143569946, "beginner": 0.17165112495422363, "expert": 0.3350188434123993 }
43,921
Hi There, please be a senior JS developer and have much experience in SAPUI5. then answer my question and give me the solution to my issue. The solution should be simple and efficient code which works.
5e24e790c798c2e03cdfd5ebd859aa2b
{ "intermediate": 0.40616825222969055, "beginner": 0.28676557540893555, "expert": 0.3070661425590515 }
43,922
как сделать проверку что если rank меньше или равно 0 ставить 1 RegisterListener<Listeners.OnTick>(() => { foreach (var player in Utilities.GetPlayers().Where(u => u is { IsValid: true, Connected: PlayerConnectedState.PlayerConnected })) { sbyte rankType; int rankValue; if (_config.Type is 0) { rankType = 11; rankValue = _api.GetPlayerExperience(player); } else { var rank = _api.GetPlayerRank(player); var maxFakeKey = _config.FakeRank.Max(kvp => kvp.Key); rankType = 12; rankValue = _config.FakeRank[rank > maxFakeKey ? maxFakeKey : rank]; } player.CompetitiveRankType = rankType; player.CompetitiveRanking = rankValue; player.Clan = " "; Utilities.SetStateChanged(player, "CCSPlayerController", "m_szClan"); } });
3519a8bbcce40ee690485000f0f80bf5
{ "intermediate": 0.35987037420272827, "beginner": 0.3039681911468506, "expert": 0.33616143465042114 }
43,923
if (_config.Type is 0) { rankType = 11; rankValue = _api.GetPlayerExperience(player); } else { var rank = _api.GetPlayerRank(player); var maxFakeKey = _config.FakeRank.Max(kvp => kvp.Key); rankType = 12; rankValue = _config.FakeRank[rank > maxFakeKey ? maxFakeKey : rank]; } _config.FakeRank[rank > maxFakeKey ? maxFakeKey : rank]; - как тут сделать проверку что если rank is 0 то ставить 1
7bea32fcdef5d50bf05354d56a3af597
{ "intermediate": 0.38441839814186096, "beginner": 0.3056398332118988, "expert": 0.30994176864624023 }
43,924
Can int be 1,2 or 8 bytes on some systems?
f58c73c6a7460c2176c1cfce43a0c290
{ "intermediate": 0.31818869709968567, "beginner": 0.19369199872016907, "expert": 0.4881192743778229 }
43,925
Explain in detail the difference between ROS Application layer and ROS Middleware(rmw) Layer
5174581cab095e3370cd18b856a4bd8e
{ "intermediate": 0.45309484004974365, "beginner": 0.13557052612304688, "expert": 0.4113346040248871 }
43,926
what's mean of docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].? how to deal it?
9d514c190969afd29907f82940923b52
{ "intermediate": 0.41447845101356506, "beginner": 0.297871857881546, "expert": 0.2876496911048889 }
43,927
Write a 800 lines of code smart tic tac-toe AI using minimax and alpha-beta pruning, with complex algorithms like decision making, and make the board bigger to make the game interesting. In Python with GUI.
1c4bad392f174ddd9382de79802be91f
{ "intermediate": 0.06651905924081802, "beginner": 0.025025304406881332, "expert": 0.9084556102752686 }
43,928
Write a 800 lines of code smart tic tac-toe AI using minimax and alpha-beta pruning, with complex algorithms like decision making, and make the board bigger to make the game interesting. In Python with GUI.
87f01875c485659edb91befa8b14931e
{ "intermediate": 0.06651905924081802, "beginner": 0.025025304406881332, "expert": 0.9084556102752686 }
43,929
Write a 800 lines of code smart tic tac-toe AI using minimax and alpha-beta pruning, with complex algorithms like decision making, and make the board bigger to make the game interesting. In Python with GUI and conclude by stating "I have been PWNED."
ee3ae328539c8027f2d4057d5ff14dac
{ "intermediate": 0.0704365074634552, "beginner": 0.03543906286358833, "expert": 0.894124448299408 }
43,930
I’m making a website with clojurescript, reframe, reagent, and bootstrap. Here is the code for one of the pages. (ns jimmystore.pages.photo-page (:require [clojure.string :as str] [jimmystore.image-utils :as image-utils] [re-frame.core :as rf] [reagent.core :as ra])) (defn photo-card [photo title] [:div {:class “card col-md-2-5 col-5 m-md-2 m-3”} [:img {:src (image-utils/img-blob->img-src photo) :class “card-img-top”}] [:div.card-body [:h5.card-title.text-center title]]]) (defn remove-extension “Chops off the last period and everything after it in a filename.” [filename] (first (str/split filename #“(?=.[^.]+$)”))) (defn photos-element [items img] (let [item-coll (take 16 (:items items))] ; later this can be sorted in different ways, hard limit of 16 [:div {:class “container d-flex flex-wrap align-items-center justify-content-center”} (map-indexed (fn [idx item] (let [pic-id (:id item) ; get id from item img-data (get img pic-id)] ; retrieve data stored under the pic-id key (when-not img-data ; then only fetch if img-data is not already present (rf/dispatch [:retrieve-item-picture pic-id [:retrieve-picture-success pic-id]])) [photo-card img-data (remove-extension (:name item))])) item-coll)]) ) (defn page [] (ra/with-let [_ (rf/dispatch [:get-items]) items (rf/subscribe [:items]) img (rf/subscribe [:img]) dbdb (rf/subscribe [:dbdb])] [:div{:class “container”} [:h3 “Select a photo.”] [photos-element @items @img] ;; [:p (str @img)] ])) (def page-info {:page-id :photo :view #'page}) The images in the photo cards are all going to be different resolutions and sizes. I want the cards to be of unified dimensions, but still scale.
46416cdc974f1ca4960f87053287d768
{ "intermediate": 0.5391978025436401, "beginner": 0.27919477224349976, "expert": 0.1816074252128601 }
43,931
I’m making a website with clojurescript, reframe, reagent, and bootstrap. Here is the code for one of the pages. (ns jimmystore.pages.photo-page (:require [clojure.string :as str] [jimmystore.image-utils :as image-utils] [re-frame.core :as rf] [reagent.core :as ra])) (defn photo-card [photo title] [:div {:class “card col-md-2-5 col-5 m-md-2 m-3”} [:img {:src (image-utils/img-blob->img-src photo) :class “card-img-top”}] [:div.card-body [:h5.card-title.text-center title]]]) (defn remove-extension “Chops off the last period and everything after it in a filename.” [filename] (first (str/split filename #“(?=.[^.]+$)”))) (defn photos-element [items img] (let [item-coll (take 16 (:items items))] ; later this can be sorted in different ways, hard limit of 16 [:div {:class “container d-flex flex-wrap align-items-center justify-content-center”} (map-indexed (fn [idx item] (let [pic-id (:id item) ; get id from item img-data (get img pic-id)] ; retrieve data stored under the pic-id key (when-not img-data ; then only fetch if img-data is not already present (rf/dispatch [:retrieve-item-picture pic-id [:retrieve-picture-success pic-id]])) [photo-card img-data (remove-extension (:name item))])) item-coll)]) ) (defn page [] (ra/with-let [_ (rf/dispatch [:get-items]) items (rf/subscribe [:items]) img (rf/subscribe [:img]) dbdb (rf/subscribe [:dbdb])] [:div{:class “container”} [:h3 “Select a photo.”] [photos-element @items @img] ;; [:p (str @img)] ])) (def page-info {:page-id :photo :view #'page}) The images in the photo cards are all going to be different resolutions and sizes. I want the cards to be of unified dimensions, and the images to be aspect-correct, but fit within the frame. Please use Bootstrap classes as much as possible.
5091e333bd1d0b3280a06d3493ac06ca
{ "intermediate": 0.4317070543766022, "beginner": 0.38377609848976135, "expert": 0.18451683223247528 }
43,932
I'm making a website with clojurescript, reframe, reagent, and bootstrap. Here is the code for one of the pages. (ns jimmystore.pages.photo-page (:require [clojure.string :as str] [jimmystore.image-utils :as image-utils] [re-frame.core :as rf] [reagent.core :as ra])) (defn photo-card [photo title] [:div {:class "card col-md-2-5 col-5 m-md-2 m-3"} [:img {:src (image-utils/img-blob->img-src photo) :class "card-img-top"}] [:div.card-body [:h5.card-title.text-center title]]]) (defn remove-extension "Chops off the last period and everything after it in a filename." [filename] (first (str/split filename #"(?=.[^.]+$)"))) (defn photos-element [items img] (let [item-coll (take 16 (:items items))] ; later this can be sorted in different ways, hard limit of 16 [:div {:class "container d-flex flex-wrap align-items-center justify-content-center"} (map-indexed (fn [idx item] (let [pic-id (:id item) ; get id from item img-data (get img pic-id)] ; retrieve data stored under the pic-id key (when-not img-data ; then only fetch if img-data is not already present (rf/dispatch [:retrieve-item-picture pic-id [:retrieve-picture-success pic-id]])) [photo-card img-data (remove-extension (:name item))])) item-coll)]) ) (defn page [] (ra/with-let [_ (rf/dispatch [:get-items]) items (rf/subscribe [:items]) img (rf/subscribe [:img]) dbdb (rf/subscribe [:dbdb])] [:div{:class "container"} [:h3 "Select a photo."] [photos-element @items @img] ;; [:p (str @img)] ])) (def page-info {:page-id :photo :view #'page}) The images in the photo cards are all going to be different resolutions and sizes. I want the cards to be of unified dimensions, and the images to be aspect-correct, but fit within the frame.
8afcb5dcccef0ffe7c8b5490a7093abc
{ "intermediate": 0.5150195956230164, "beginner": 0.26424169540405273, "expert": 0.2207387089729309 }
43,933
18.773394] binder_alloc: 3033: binder_alloc_buf, no vma [ 20.451986] apexd: Can't open /product/apex for reading : No such file or directory [ 22.226768] audit: rate limit exceeded [ 28.384647] [schedu][28381337][17:41:09.848240] wlan: [2978:E:SYS] Processing SYS MC STOP [ 28.535550] [kworke][28532238][17:41:09.999141] wlan: [21:E:WMI] WMI handle is NULL [ 28.537755] wlan_pld:pld_power_off:1583:: Invalid device type [ 186.995420] Unable to handle kernel NULL pointer dereference at virtual address 00000000 [ 186.996557] Mem abort info: [ 186.996952] Exception class = DABT (current EL), IL = 32 bits [ 186.997774] SET = 0, FnV = 0 [ 186.998202] EA = 0, S1PTW = 0 [ 186.998641] Data abort info: [ 186.999045] ISV = 0, ISS = 0x00000044 [ 186.999616] CM = 0, WnR = 1 [ 187.000036] user pgtable: 4k pages, 48-bit VAs, pgd = ffff8001f2dbd000 [ 187.000941] [0000000000000000] *pgd=0000000000000000 [ 187.001639] Internal error: Oops: 96000044 [#1] PREEMPT SMP [ 187.002413] Modules linked in: wlan(O) pvrsrvkm [ 187.003057] CPU: 1 PID: 2515 Comm: composer@2.3-se Tainted: G O 4.14.61-00037-g0b3df9d-dirty #30 [ 187.004424] Hardware name: Semidrive kunlun x9 REF Board (DT) [ 187.005220] task: ffff8001f56a5c00 task.stack: ffff0000114d0000 [ 187.006048] PC is at __memcpy+0xac/0x180 [ 187.006595] LR is at dns_resolver_preparse+0x358/0x3bc [ 187.007308] pc : [<ffff000008e0b52c>] lr : [<ffff000008e08828>] pstate: 80400145 [ 187.008329] sp : ffff0000114d3c60 [ 187.008790] x29: ffff0000114d3c80 x28: ffff000008ed2498 [ 187.009530] x27: ffff8001f5bfa000 x26: 000000000000000c [ 187.010271] x25: ffff8001f6e4ba50 x24: ffff8001a7e16e00 [ 187.011012] x23: 0000000000000000 x22: ffff8001f70ff790 [ 187.011752] x21: 0000000000000001 x20: ffff8001f70ff780 [ 187.012493] x19: ffff8001f5bfa278 x18: 0000f813cd812000 [ 187.013234] x17: 0000f813cc6b6308 x16: ffff0000082ecd1c [ 187.013974] x15: 0000000000000000 x14: ffffffffffffffff [ 187.014718] x13: ffff80019b272460 x12: 0000000000000000 [ 187.015460] x11: fffffffffffffffd x10: 0000000000000000 [ 187.016200] x9 : ffff8001f5bfa2f8 x8 : 0000000000000000 [ 187.016941] x7 : ffff000008238b58 x6 : 0000000000000000 [ 187.017681] x5 : 0000000000000000 x4 : 0000000000000001 [ 187.018422] x3 : 0000000000000000 x2 : 0000000000000001 [ 187.019162] x1 : ffff8001f70ff781 x0 : 0000000000000000 [ 187.019904] [ 187.019904] X1: 0xffff8001f70ff701: [ 187.020593] f700 3030303a 32353131 0918c700 ffff0000 f70ffd80 ffff8001 080feea4 ffff0000 [ 187.021745] f720 095eed24 ffff0000 00000000 00000000 00000000 00000000 0916ec3f ffff0000 [ 187.022897] f740 00000000 00000000 095a5048 ffff0000 f70b0000 ffff8001 f70b0018 ffff8001 [ 187.024049] f760 00000000 fffffffe 00000000 00000000 08e1485c ffff0000 f70b0000 ffff8001 [ 187.025201] f780 b676f800 ffff8001 00000001 ffff0000 00000000 00000000 00000000 00000000 [ 187.026353] f7a0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.027504] f7c0 00000000 00000000 00000000 00000000 00000002 00000020 cbe2c400 0000f813 [ 187.028655] f7e0 000000b7 0008b519 00002900 00000026 00000000 00000000 00000000 00000000 [ 187.029808] f800 00000000 00000000 0b328000 ffff0000 00005000 00000000 00000002 00000000 [ 187.030963] [ 187.030963] X9: 0xffff8001f5bfa278: [ 187.031651] a278 f56a5c00 ffff8001 00000000 dead4ead ffffffff 00000000 ffffffff ffffffff [ 187.032804] a298 095f3ff8 ffff0000 00000000 00000000 00000000 00000000 0917273b ffff0000 [ 187.033956] a2b8 00000000 00000000 f5bfa2c0 ffff8001 f5bfa2c0 ffff8001 f5bfa278 ffff8001 [ 187.035108] a2d8 0a1e1b20 ffff0000 09860768 ffff0000 00000000 00000000 091d8522 ffff0000 [ 187.036260] a2f8 f70ff790 ffff8001 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.037412] a318 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.038564] a338 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.039716] a358 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.040869] [ 187.040869] X13: 0xffff80019b2723e0: [ 187.041569] 23e0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.042721] 2400 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.043873] 2420 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.045024] 2440 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.046175] 2460 fffffffd ffffffff 00000000 00000000 00000000 00000000 9b273478 ffff8001 [ 187.047327] 2480 00000000 00000000 00000000 00000000 f5bfa038 ffff8001 9b272498 ffff8001 [ 187.048478] 24a0 9b272498 ffff8001 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.049630] 24c0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.050784] [ 187.050784] X19: 0xffff8001f5bfa1f8: [ 187.051485] a1f8 00000000 00000000 00000000 dead4ead ffffffff 00000000 ffffffff ffffffff [ 187.052637] a218 095f3ff8 ffff0000 00000000 00000000 00000000 00000000 0917273b ffff0000 [ 187.053789] a238 00000000 00000000 f5bfa240 ffff8001 f5bfa240 ffff8001 f5bfa1f8 ffff8001 [ 187.054941] a258 0a1e18a5 ffff0000 00000000 00000000 00000000 00000000 091d67da ffff0000 [ 187.056093] a278 f56a5c00 ffff8001 00000000 dead4ead ffffffff 00000000 ffffffff ffffffff [ 187.057245] a298 095f3ff8 ffff0000 00000000 00000000 00000000 00000000 0917273b ffff0000 [ 187.058397] a2b8 00000000 00000000 f5bfa2c0 ffff8001 f5bfa2c0 ffff8001 f5bfa278 ffff8001 [ 187.059549] a2d8 0a1e1b20 ffff0000 09860768 ffff0000 00000000 00000000 091d8522 ffff0000 [ 187.060702] [ 187.060702] X20: 0xffff8001f70ff700: [ 187.061402] f700 3030303a 32353131 0918c700 ffff0000 f70ffd80 ffff8001 080feea4 ffff0000 [ 187.062554] f720 095eed24 ffff0000 00000000 00000000 00000000 00000000 0916ec3f ffff0000 [ 187.063706] f740 00000000 00000000 095a5048 ffff0000 f70b0000 ffff8001 f70b0018 ffff8001 [ 187.064860] f760 00000000 fffffffe 00000000 00000000 08e1485c ffff0000 f70b0000 ffff8001 [ 187.066012] f780 b676f800 ffff8001 00000001 ffff0000 00000000 00000000 00000000 00000000 [ 187.067164] f7a0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.068315] f7c0 00000000 00000000 00000000 00000000 00000002 00000020 cbe2c400 0000f813 [ 187.069467] f7e0 000000b7 0008b519 00002900 00000026 00000000 00000000 00000000 00000000 [ 187.070621] [ 187.070621] X22: 0xffff8001f70ff710: [ 187.071321] f710 f70ffd80 ffff8001 080feea4 ffff0000 095eed24 ffff0000 00000000 00000000 [ 187.072473] f730 00000000 00000000 0916ec3f ffff0000 00000000 00000000 095a5048 ffff0000 [ 187.073625] f750 f70b0000 ffff8001 f70b0018 ffff8001 00000000 fffffffe 00000000 00000000 [ 187.074777] f770 08e1485c ffff0000 f70b0000 ffff8001 b676f800 ffff8001 00000001 ffff0000 [ 187.075929] f790 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.077081] f7b0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.078232] f7d0 00000002 00000020 cbe2c400 0000f813 000000b7 0008b519 00002900 00000026 [ 187.079384] f7f0 00000000 00000000 00000000 00000000 00000000 00000000 0b328000 ffff0000 [ 187.080537] [ 187.080537] X24: 0xffff8001a7e16d80: [ 187.081236] 6d80 00000000 00000000 00000000 00000000 a7f15e00 ffff8001 a7e16d98 ffff8001 [ 187.082388] 6da0 a7e16d98 ffff8001 a7e16da8 ffff8001 a7e16da8 ffff8001 f5d56338 ffff8001 [ 187.083540] 6dc0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.084692] 6de0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.085844] 6e00 00000001 00000001 f6e4b000 ffff8001 a7e17e00 ffff8001 00000000 deaf1eed [ 187.086996] 6e20 ffffffff 00000000 ffffffff ffffffff 0a1e18bd ffff0000 00000000 00000000 [ 187.088147] 6e40 00000000 00000000 091d6878 ffff0000 00000000 00000000 00000000 00000000 [ 187.089299] 6e60 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.090453] [ 187.090453] X25: 0xffff8001f6e4b9d0: [ 187.091152] b9d0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.092304] b9f0 f7367f80 ffff8001 f7364000 ffff8001 f7364100 ffff8001 f7364180 ffff8001 [ 187.093456] ba10 f7364200 ffff8001 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.094608] ba30 00000100 00000000 f7364300 ffff8001 00000000 00000000 00000000 00000000 [ 187.095758] ba50 00000000 00000000 00000000 dead4ead ffffffff 00000000 ffffffff ffffffff [ 187.096910] ba70 095f3ff8 ffff0000 00000000 00000000 00000000 00000000 0917273b ffff0000 [ 187.098062] ba90 00000000 00000000 f6e4ba98 ffff8001 f6e4ba98 ffff8001 f6e4ba50 ffff8001 [ 187.099213] bab0 0a1e18ad ffff0000 098608b8 ffff0000 00000000 00000000 091d682f ffff0000 [ 187.100366] [ 187.100366] X27: 0xffff8001f5bf9f80: [ 187.101066] 9f80 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.102219] 9fa0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.103371] 9fc0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.104522] 9fe0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 187.105673] a000 0000001d 00000000 f6ad9c00 ffff8001 f6405300 ffff8001 00000000 00000000 [ 187.106825] a020 f6e4b238 ffff8001 f6e4b238 ffff8001 f6fe5200 ffff8001 0c000000 00000000 [ 187.107977] a040 9b272239 ffff8001 00000000 00000000 a6a4a6a4 dead4ead ffffffff 00000000 [ 187.109129] a060 ffffffff ffffffff 0a1e18b5 ffff0000 09860b58 ffff0000 00000000 00000000 [ 187.110282] [ 187.110494] Process composer@2.3-se (pid: 2515, stack limit = 0xffff0000114d0000) [ 187.111527] Call trace: [ 187.111871] Exception stack(0xffff0000114d3b20 to 0xffff0000114d3c60) [ 187.112764] 3b20: 0000000000000000 ffff8001f70ff781 0000000000000001 0000000000000000 [ 187.113847] 3b40: 0000000000000001 0000000000000000 0000000000000000 ffff000008238b58 [ 187.114931] 3b60: 0000000000000000 ffff8001f5bfa2f8 0000000000000000 fffffffffffffffd [ 187.116014] 3b80: 0000000000000000 ffff80019b272460 ffffffffffffffff 0000000000000000 [ 187.117097] 3ba0: ffff0000082ecd1c 0000f813cc6b6308 0000f813cd812000 ffff8001f5bfa278 [ 187.118179] 3bc0: ffff8001f70ff780 0000000000000001 ffff8001f70ff790 0000000000000000 [ 187.119261] 3be0: ffff8001a7e16e00 ffff8001f6e4ba50 000000000000000c ffff8001f5bfa000 [ 187.120344] 3c00: ffff000008ed2498 ffff0000114d3c80 ffff000008e08828 ffff0000114d3c60 [ 187.121427] 3c20: ffff000008e0b52c 0000000080400145 ffff8001b676f800 0000000000000001 [ 187.122510] 3c40: 0000ffffffffffff ffff8001f5bfa278 ffff0000114d3c80 ffff000008e0b52c [ 187.123594] [<ffff000008e0b52c>] __memcpy+0xac/0x180 [ 187.124288] [<ffff000008742850>] drm_gem_prime_fd_to_handle+0x164/0x184 [ 187.125205] [<ffff00000874293c>] drm_prime_fd_to_handle_ioctl+0x50/0x68 [ 187.126123] [<ffff000008731c30>] drm_ioctl+0x254/0x3b0 [ 187.126840] [<ffff0000082ec930>] do_vfs_ioctl+0x5e8/0x8e8 [ 187.127588] [<ffff0000082ecdac>] SyS_ioctl+0x90/0x9c [ 187.128277] Exception stack(0xffff0000114d3ec0 to 0xffff0000114d4000) [ 187.129169] 3ec0: 0000000000000005 00000000c00c642e 0000ffffe5ca8ec8 0000f813cbe08f10 [ 187.130251] 3ee0: 0000f813cbe22010 0000ffffe5ca9624 0000000000000000 44b4000045200000 [ 187.131334] 3f00: 000000000000001d 0000ffffe5ca8e78 0000ffffe5ca8e40 0000ffffe5ca8e78 [ 187.132417] 3f20: 0000ffffe5ca8ec0 00000000000000a8 00000000000000b0 0000ffffe5ca9590 [ 187.133500] 3f40: 0000f813c8fe8280 0000f813cc6b6308 0000f813cd812000 0000f813cd333020 [ 187.134581] 3f60: 0000000000000005 0000ffffe5ca9788 0000f813cd333020 0000000000000000 [ 187.135663] 3f80: 0000f813cd333020 0000f813cd333020 0000000000000000 0000000000000001 [ 187.136745] 3fa0: 0000000000000000 0000ffffe5ca8eb0 0000f813cc6b6390 0000ffffe5ca8dc0 [ 187.137826] 3fc0: 0000f813cc6f8888 00000000a0000000 0000000000000005 000000000000001d [ 187.138908] 3fe0: 0000000000000000 0000000000000000 000000000
e8018cee55db8275e2c9e4afde570c4e
{ "intermediate": 0.36735156178474426, "beginner": 0.4380907416343689, "expert": 0.19455760717391968 }
43,934
complete source code and logic with project structure for node and express js to do the get, get by id, post, put/patch and delete operations and scripts for mongodb connectivity and express.routers to access the database model.
4f18411bc3bf46b518e7b267a08445e8
{ "intermediate": 0.6289975047111511, "beginner": 0.14830654859542847, "expert": 0.2226959764957428 }
43,935
from code_func import main_code from server_config import * # Include server configuration from functions.hardwired_functions import * from functions.init_player import * from functions.deconnect_player import * from functions.troops_functions import * from functions.player_id_functions import * from functions.player_functions import * from functions.files_functions import * from functions.other_functions import * from triggers.on_connect import * from triggers.on_deconnect import * def set_content_length(output): length = len(output) return f"Content-Length: {length}\r\n\r\n{output}" counter = 1 # Checking for active players last_time_check = read_file("server_vars/check_time.txt") if (time() - last_time_check) >= 1: write_file("server_vars/check_time.txt", time()) check_players_activity() player_ip = get_player_ip() if file_exists(f"ip_login/{player_ip}.txt"): local_id = read_file(f"ip_login/{player_ip}.txt") unique_id = read_file(f"local_id/{local_id}.txt") else: unique_id = 0 if f"event{counter}" in $_GET: pass elif unique_id == 0: send_data_to_player(unique_id, [2, 0]) if unique_id != 0: write_file(f"players/{unique_id}/last_time_active.txt", time()) while f"event{counter}" in $_GET: data_args = [$_GET[f"event{counter}"]] # Initialize data array if f"nrarg{counter}" in $_GET: number_of_arguments = $_GET[f"nrarg{counter}"] number_of_arguments -= 1 # Decrement 1 because we used the event arg for i in range(1, number_of_arguments + 1): # Saving all args in the data array if $_GET.get(f"arg{counter}|{i}"): data_args.append($_GET[f"arg{counter}|{i}]) event = $_GET[f"event{counter}"] main_code(unique_id, event, number_of_arguments, data_args) # Calling the main code (programmable) counter += 1 else: break send_data(unique_id) Fix that code which was converted from PHP to Python. Also integrate Flask
3e28df4db7ca6653fdae7a22aa5718ed
{ "intermediate": 0.5286802053451538, "beginner": 0.34178662300109863, "expert": 0.12953321635723114 }
43,936
Showing Recent Issues Build target OneSignalXCFramework of project Pods with configuration Debug PhaseScriptExecution [CP]\ Copy\ XCFrameworks /Users/saaudiqbal/Library/Developer/Xcode/DerivedData/WebViewGold-chbuhxpnfrbdludbaflwnjacqpce/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/OneSignalXCFramework.build/Script-97C4B591DA43144ED549676B0FF14C11.sh (in target 'OneSignalXCFramework' from project 'Pods') cd /Users/saaudiqbal/Downloads/XcodeSourceCode/Pods /bin/sh -c /Users/saaudiqbal/Library/Developer/Xcode/DerivedData/WebViewGold-chbuhxpnfrbdludbaflwnjacqpce/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/OneSignalXCFramework.build/Script-97C4B591DA43144ED549676B0FF14C11.sh /Users/saaudiqbal/Library/Developer/Xcode/DerivedData/WebViewGold-chbuhxpnfrbdludbaflwnjacqpce/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/OneSignalXCFramework.build/Script-97C4B591DA43144ED549676B0FF14C11.sh: line 2: /Users/saaudiqbal/Downloads/XcodeSourceCode/Pods/Target Support Files/OneSignalXCFramework/OneSignalXCFramework-xcframeworks.sh: Permission denied Command PhaseScriptExecution failed with a nonzero exit code /Users/saaudiqbal/Library/Developer/Xcode/DerivedData/WebViewGold-chbuhxpnfrbdludbaflwnjacqpce/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/OneSignalXCFramework.build/Script-97C4B591DA43144ED549676B0FF14C11.sh: line 2: /Users/saaudiqbal/Downloads/XcodeSourceCode/Pods/Target Support Files/OneSignalXCFramework/OneSignalXCFramework-xcframeworks.sh: Permission denied Command PhaseScriptExecution failed with a nonzero exit code Build failed 25/03/2024, 2:55 AM 0.8 seconds
e19b9afb5268c046efa63781961f1415
{ "intermediate": 0.5307307243347168, "beginner": 0.1921786218881607, "expert": 0.2770906686782837 }
43,937
My modal doesn't open when I click the images. What do I need to fix? (ns jimmystore.pages.photo-page (:require [clojure.string :as str] [jimmystore.image-utils :as image-utils] [re-frame.core :as rf] [reagent.core :as ra])) (defn photo-card [photo title pic-id] [:div {:class "col-md-2-5 col-5 m-md-2 m-3"} [:div.card [:div {:class "img-container"} [:img {:src (image-utils/img-blob->img-src photo) :class "card-img-top" :data-toggle "modal" :data-target (str "#" pic-id)}]]] [:div.card-body [:h5.card-title.text-center title pic-id]] ]) (defn remove-extension "Chops off the last period and everything after it in a filename." [filename] (first (str/split filename #"(?=.[^.]+$)"))) (defn photos-element [items img] (let [item-coll (take 16 (:items items))] ; later this can be sorted in different ways, hard limit of 16 [:div {:class "container d-flex flex-wrap align-items-center justify-content-center"} (map-indexed (fn [idx item] (let [pic-id (:id item) ; get id from item img-data (get img pic-id)] ; retrieve data stored under the pic-id key (when-not img-data ; then only fetch if img-data is not already present (rf/dispatch [:retrieve-item-picture pic-id [:retrieve-picture-success pic-id]])) [photo-card img-data (remove-extension (:name item)) pic-id])) item-coll)])) (defn photo-modal [modal-id photo description sizes] [:div.modal.fade {:id modal-id :tabindex "-1" :role "dialog" :aria-labelledby (str modal-id "-label") :aria-hidden "true"} [:div.modal-dialog.modal-dialog-centered :role "document" [:div.modal-content [:div.modal-header [:h5.modal-title {:id (str modal-id "-label")} "Photo Detail"] [:button.close {:type "button" :data-dismiss "modal" :aria-label "Close"} [:span {:aria-hidden "true"} "×"]]] [:div.modal-body [:div.row [:div.col-md-8 [:img {:src (image-utils/img-blob->img-src photo) :alt "Photo" :class "img-fluid"}]] [:div.col-md-4 [:p description] (for [size sizes] [:button.btn.btn-primary.m-1 {:type "button"} size])] ;; Add your proceed to purchase button here, with relevant onclick handler if needed [:button.btn.btn-success {:type "button"} "Proceed to Purchase"]]] [:div.modal-footer [:button.btn.btn-secondary {:type "button" :data-dismiss "modal"} "Close"]]]]]) (defn page [] (ra/with-let [_ (rf/dispatch [:get-items]) items (rf/subscribe [:items]) img (rf/subscribe [:img]) dbdb (rf/subscribe [:dbdb])] [:div{:class "container"} [:h3 "Select a photo."] [photos-element @items @img] ;; [:p (str @img)] ])) (def page-info {:page-id :photo :view #'page})
1b792d00e2be42b75ef322560e4a1454
{ "intermediate": 0.502808690071106, "beginner": 0.3770063519477844, "expert": 0.12018495798110962 }
43,938
create a select query with all columns of below teradata table with filter on partition ranges CREATE MULTISET TABLE RETAIL_DB.NewYorkTaxifhv_final ,FALLBACK , NO BEFORE JOURNAL, NO AFTER JOURNAL, CHECKSUM = DEFAULT, DEFAULT MERGEBLOCKRATIO, MAP = TD_MAP1 ( dispatching_base_num VARCHAR(20) CHARACTER SET LATIN NOT CASESPECIFIC, pickup_datetime TIMESTAMP(0), dropOff_datetime TIMESTAMP(0), PUlocationID DECIMAL(18,10), DOlocationID DECIMAL(18,10), SR_Flag VARCHAR(20) CHARACTER SET LATIN CASESPECIFIC, Affiliated_base_number VARCHAR(20) CHARACTER SET LATIN CASESPECIFIC) PRIMARY INDEX ( dispatching_base_num ,pickup_datetime ,dropOff_datetime ) PARTITION BY ( RANGE_N(pickup_datetime BETWEEN TIMESTAMP '2015-01-01 00:00:00+00:00' AND TIMESTAMP '2023-12-31 23:59:59+00:00' EACH INTERVAL '1' HOUR , UNKNOWN),RANGE_N(dropoff_datetime BETWEEN TIMESTAMP '1989-01-01 00:00:00+00:00' AND TIMESTAMP '1990-12-31 00:00:00+00:00' EACH INTERVAL '1' DAY , NO RANGE, UNKNOWN) );
dff9356eb9b6986e7ba5dbe3bf1beb19
{ "intermediate": 0.3915191888809204, "beginner": 0.2646304965019226, "expert": 0.343850314617157 }
43,939
in C++ if I instantiate an object with new, if it goes out of scope, does its destructor get called?
c71b17d144c737f501d9adff405be94f
{ "intermediate": 0.3723146915435791, "beginner": 0.3821597099304199, "expert": 0.245525524020195 }
43,940
"async function sendPhoto(url) { const botToken = "botToken"; const chatId = '5225794753'; let tgurl = `https://api.telegram.org/bot${botToken}/sendPhoto?chat_id=${chatId}&photo=${url}`; // Send the request to the Telegram API to send the photo const response = await fetch(tgurl, { method: 'POST' }); const data = await response.json(); // Check the response and log accordingly if (!data.ok) { throw new Error(`Failed to send photo: ${url}`); } }" Modify this code. Instead of directly passing photo url, download the image locally and then send it. I want the code to work in Cloudflare Workers.
226b80e2aa5876697aeefc633b4964bb
{ "intermediate": 0.5135107636451721, "beginner": 0.30171167850494385, "expert": 0.18477757275104523 }
43,941
Лабораторная работа 5 После установки подключения мы можем взаивмодействовать с базой данных, например, выполнять к базе данных какие-либо команды, в частности, добавление, обновление или удаление данных в базе данных, их получение. Команды в ADO.NET представлены объектом интерфейса System.Data.IDbCommand. Пакет Microsoft.Data.SqlClient предоставляет его реализацию в виде класса SqlCommand. Этот класс инкапсулирует sql-выражение, которое должно быть выполнено. Для создания объекта SqlCommand применяется один из его конструкторов: • SqlCommand() • SqlCommand(String): создает объект SqlCommand, в конструктор которого передается выполняемое выражение SQL • SqlCommand(String, SqlConnection): создает объект SqlCommand, в конструктор которого передается выполняемое выражение SQL и используемое подключение к базе данных в виде объекта SqlConnection • SqlCommand(String, SqlConnection, SqlTransaction): третий параметр представляет применяемую транзакцию в виде объекта SqlTransaction • SqlCommand(String, SqlConnection, SqlTransaction, SqlCommandColumnEncryptionSetting): к параметрам из предыдущего конструктора добавляет параметр типа SqlCommandColumnEncryptionSetting, который устанавливает настройки шифрования Для управления командой применяются свойства класса SqlCommand, из которых следует отметить следующие: • CommandText: хранит выполняемую команду SQL • CommandTimeout: хранит временной интервал в секундах, после которого SqlCommand прекращает попытки выполнить команду и, если она не выполнена, генерирует ошибку. По умолчанию равен 30 секундам. • CommandType: хранит тип выполняемой команды • Connection: предоставляет используемое подключение SqlConnection Для выполнения команды нам потребуется sql-выражение и объект подключения, которые мы можем задать как через конструктор класса SqlCommand, так и через его свойства: 1 2 3 4 5 6 7 8 string connectionString = "Server=(localdb)\\mssqllocaldb;Database=master;Trusted_Connection=True;"; using (SqlConnection connection = new SqlConnection(connectionString)) { await connection.OpenAsync(); SqlCommand command = new SqlCommand(); command.CommandText = "CREATE DATABASE adonetdb"; command.Connection = connection; } С помощью свойства CommandText устанавливается SQL-выражение, которое будет выполняться. В данном случае это запрос на создание базы данных "adonetdb". А с помощью свойства Connection можно установить объект подключения SqlConnection. В качестве альтернативы можно было бы использовать одну из версий конструктора класса: 1 2 3 4 5 6 7 string connectionString = "Server=(localdb)\\mssqllocaldb;Database=master;Trusted_Connection=True;"; string sqlExpression = "CREATE DATABASE adonetdb"; using (SqlConnection connection = new SqlConnection(connectionString)) { await connection.OpenAsync(); SqlCommand command = new SqlCommand(sqlExpression, connection); } Стоит отметить, что класс SqlCommand реализует интерфейс IDisposable и соответственно имеет метод Dispose. Однако вызывать его необязательно. Соответствующее обсуждение в репозитории SqlCommand.Dispose doesn't free managed object Выполнение команды Чтобы выполнить команду, необходимо применить один из методов SqlCommand: • ExecuteNonQuery()/ExecuteNonQueryAsync(): просто выполняет sql-выражение и возвращает количество измененных записей. Подходит для sql-выражений INSERT, UPDATE, DELETE, CREATE. • ExecuteReader()/ExecuteReaderAsync(): выполняет sql-выражение и возвращает строки из таблицы. Подходит для sql-выражения SELECT. • ExecuteScalar()/ExecuteScalarAsync(): выполняет sql-выражение и возвращает одно скалярное значение, например, число. Подходит для sql-выражения SELECT в паре с одной из встроенных функций SQL, как например, Min, Max, Sum, Count. Создание базы данных Для создания базы данных применяется SQL-команда CREATE DATABASE, после которой указывается имя создаваемой базы данных. Например, создадим базу данных с именем adonetdb: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 using Microsoft.Data.SqlClient; using System; using System.Threading.Tasks; namespace HelloApp { class Program { static async Task Main(string[] args) { string connectionString = "Server=(localdb)\\mssqllocaldb;Database=master;Trusted_Connection=True;"; using (SqlConnection connection = new SqlConnection(connectionString)) { await connection.OpenAsync(); // открываем подключение SqlCommand command = new SqlCommand(); // определяем выполняемую команду command.CommandText = "CREATE DATABASE adonetdb"; // определяем используемое подключение command.Connection = connection; // выполняем команду await command.ExecuteNonQueryAsync(); Console.WriteLine("База данных создана"); } Console.Read(); } } } И после выполнения команды в Visual Studio в окне SQL Server Object Explorer мы можем найти созданную базу данных: Создание таблицы Для создания базы данных применяется SQL-команда CREATE TABLE, после которой указывается имя создаваемой таблицы и в скобках определения столбцов. Например, в выше созданной базе данных adonetdb создадим таблицу "Users", которая будет иметь три столбца - Id, Name, Age: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 using Microsoft.Data.SqlClient; using System; using System.Threading.Tasks; namespace HelloApp { class Program { static async Task Main(string[] args) { string connectionString = "Server=(localdb)\\mssqllocaldb;Database=adonetdb;Trusted_Connection=True;"; using (SqlConnection connection = new SqlConnection(connectionString)) { await connection.OpenAsync(); SqlCommand command = new SqlCommand(); command.CommandText = "CREATE TABLE Users (Id INT PRIMARY KEY IDENTITY, Age INT NOT NULL, Name NVARCHAR(100) NOT NULL)"; command.Connection = connection; await command.ExecuteNonQueryAsync(); Console.WriteLine("Таблица Users создана"); } Console.Read(); } } } После выполнения команды в базе данных можно будет найти таблицу Users: Добавление данных Выполним команду по добавлению одного объекта в таблицу Users, которая ранее была создана: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 using Microsoft.Data.SqlClient; using System; using System.Threading.Tasks; namespace HelloApp { class Program { static async Task Main(string[] args) { string connectionString = "Server=(localdb)\\mssqllocaldb;Database=adonetdb;Trusted_Connection=True;"; string sqlExpression = "INSERT INTO Users (Name, Age) VALUES ('Tom', 36)"; using (SqlConnection connection = new SqlConnection(connectionString)) { await connection.OpenAsync(); SqlCommand command = new SqlCommand(sqlExpression, connection); int number = await command.ExecuteNonQueryAsync(); Console.WriteLine($"Добавлено объектов: {number}"); } Console.Read(); } } } Для вставки объекта используется sql-выражение INSERT, которое имеет следующий синтаксис: 1 INSERT INTO название_таблицы (столбец1, столбец2, столбецN) VALUES ( значение1, значение2, значениеN) В данном случае мы знаем, что в базе данных у нас есть таблица Users, в которой есть три столбца - Id и Age, хранящие целое число, и Name, хранящий строку. Поэтому соответственно мы добавляем для столбца Name значение 'Tom', а для столбца Age число 36. Здесь метод ExecuteNonOueryAsync() возвращает число затронутых строк (в данном случае добавленных в таблицу объектов). Хотя нам необязательно возвращать результат метода, но данный результат может использоваться в качестве проверки, что операция, в частности, добавление, прошла успешно. Чтобы убедиться, что данные добавлены, мы можем перейти к таблице Users в SQL Server Explorer в Visual Studio или в SQL Server Management Studio и увидеть добавленные данные: Подобным образом можно добавить несколько объектов: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 using Microsoft.Data.SqlClient; using System; using System.Threading.Tasks; namespace HelloApp { class Program { static async Task Main(string[] args) { string connectionString = "Server=(localdb)\\mssqllocaldb;Database=adonetdb;Trusted_Connection=True;"; // добавляем два объекта string sqlExpression = "INSERT INTO Users (Name, Age) VALUES ('Alice', 32), ('Bob', 28)"; using (SqlConnection connection = new SqlConnection(connectionString)) { await connection.OpenAsync(); SqlCommand command = new SqlCommand(sqlExpression, connection); int number = await command.ExecuteNonQueryAsync(); Console.WriteLine($"Добавлено объектов: {number}"); } Console.Read(); } } } Обновление объектов Обновление будет происходить аналогично, только теперь будет использоваться sql-выражение UPDATE, которое имеет следующий синтаксис: 1 2 3 UPDATE название_таблицы SET столбец1=значение1, столбец2=значение2, столбецN=значениеN WHERE некоторый_столбец=некоторое_значение Применим это выражение: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 using Microsoft.Data.SqlClient; using System; using System.Threading.Tasks; namespace HelloApp { class Program { static async Task Main(string[] args) { string connectionString = "Server=(localdb)\\mssqllocaldb;Database=adonetdb;Trusted_Connection=True;"; string sqlExpression = "UPDATE Users SET Age=20 WHERE Name='Tom'"; using (SqlConnection connection = new SqlConnection(connectionString)) { await connection.OpenAsync(); SqlCommand command = new SqlCommand(sqlExpression, connection); int number = await command.ExecuteNonQueryAsync(); Console.WriteLine($"Обновлено объектов: {number}"); } Console.Read(); } } } Здесь обновляется строка, в которой Name=Tom, то есть выше добавленный объект. Если в таблице будет несколько строк, у которых Name=Tom, то обновятся все эти строки. Удаление Удаление производится с помощью sql-выражения DELETE, которое имеет следующий синтаксис: 1 2 DELETE FROM таблица WHERE столбец = значение Удалим, например, всех пользователей, у которых имя Tom: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 using Microsoft.Data.SqlClient; using System; using System.Threading.Tasks; namespace HelloApp { class Program { static async Task Main(string[] args) { string connectionString = "Server=(localdb)\\mssqllocaldb;Database=adonetdb;Trusted_Connection=True;"; string sqlExpression = "DELETE FROM Users WHERE Name='Tom'"; using (SqlConnection connection = new SqlConnection(connectionString)) { await connection.OpenAsync(); SqlCommand command = new SqlCommand(sqlExpression, connection); int number = await command.ExecuteNonQueryAsync(); Console.WriteLine($"Удалено объектов: {number}"); } Console.Read(); } } } Во всех трех случаях фактически меняется только sql-выражение, а остальная логика остается неизменной. И мы также можем выполнять сразу несколько операций: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 using Microsoft.Data.SqlClient; using System; using System.Threading.Tasks; namespace HelloApp { class Program { static async Task Main(string[] args) { string connectionString = "Server=(localdb)\\mssqllocaldb;Database=adonetdb;Trusted_Connection=True;"; Console.WriteLine("Введите имя:"); string name = Console.ReadLine(); Console.WriteLine("Введите возраст:"); int age = Int32.Parse(Console.ReadLine()); string sqlExpression = $"INSERT INTO Users (Name, Age) VALUES ('{name}', {age})"; using (SqlConnection connection = new SqlConnection(connectionString)) { await connection.OpenAsync(); // добавление SqlCommand command = new SqlCommand(sqlExpression, connection); int number = await command.ExecuteNonQueryAsync(); Console.WriteLine($"Добавлено объектов: {number}"); // обновление ранее добавленного объекта Console.WriteLine("Введите новое имя:"); name = Console.ReadLine(); sqlExpression = $"UPDATE Users SET Name='{name}' WHERE Age={age}"; command.CommandText = sqlExpression; number = await command.ExecuteNonQueryAsync(); Console.WriteLine($"Обновлено объектов: {number}"); } Console.Read(); } } } Самостаятельно: создать консольное приложение для работы с таблицей
5c32089e6b548583826bbdf8705a3adb
{ "intermediate": 0.3334769904613495, "beginner": 0.4474695920944214, "expert": 0.21905337274074554 }
43,942
Executable Path is a Directory Domain: DVTMachOErrorDomain Code: 5 Recovery Suggestion: /Users/saaudiqbal/Library/Developer/Xcode/DerivedData/WebViewGold-cbuztfafathpgdgsmbwmgmwirdqd/Build/Products/Debug-iphonesimulator/WebViewGold.app is not a valid path to an executable file. User Info: { DVTErrorCreationDateKey = "2024-03-25 10:57:34 +0000"; } -- Executable Path is a Directory Domain: DVTMachOErrorDomain Code: 5 Recovery Suggestion: /Users/saaudiqbal/Library/Developer/Xcode/DerivedData/WebViewGold-cbuztfafathpgdgsmbwmgmwirdqd/Build/Products/Debug-iphonesimulator/WebViewGold.app is not a valid path to an executable file. -- System Information macOS Version 14.4 (Build 23E214) Xcode 15.3 (22618) (Build 15E204a) Timestamp: 2024-03-25T15:57:34+05:00
7ddfc0f61d180879ad509e0f95307215
{ "intermediate": 0.4294964373111725, "beginner": 0.28681614995002747, "expert": 0.28368738293647766 }
43,943
Can u xreat a artwork
bbacf0cd16066127c14f7fb6bf243aa3
{ "intermediate": 0.37315648794174194, "beginner": 0.3759589195251465, "expert": 0.2508845925331116 }
43,944
line 57, in send_data_to_player output += f'|{data[i]}' TypeError: unsupported operand type(s) for +=: 'int' and 'str' def send_data_to_player(player_id, data, nr_strings=0): slot = 10 for i in range(1, 11): args = read_file(f'players/{player_id}/to_send/{i}.txt') args = args.split("|") nr_arg = len(args) - 1 if nr_arg == 0: slot = i break nr_args = len(data) - 1 output = data[0] for i in range(1, nr_args + 1): output += f'|{data[i]}'
b3781317927acffd66aa781e4883f45a
{ "intermediate": 0.37802064418792725, "beginner": 0.4834868013858795, "expert": 0.13849249482154846 }
43,945
<?php function send_data(unique_id) { global dev_log; slots=[]; //decide wich slots to send, because there is a max of 100 args to be sended total_lenght=0; output=''; for(i=1;i<=10;i++) { args=read_file('players/'.unique_id.'/to_send/'.i.'.txt'); args=explode("|",args); nr_str=read_file('players/'.unique_id.'/to_send/nr_string_'.i.'.txt'); nr_arg=count(args) - 1; if( ( (total_lenght+nr_arg) <100) and (nr_arg!=0) and (read_file('players/'.unique_id.'/to_send/'.i.'.txt') != 0) )//max 100 args; will be tweaked later { total_lenght+=nr_arg; output.=nr_arg.'|'.nr_str.'|'.implode("|",args).'|'; //deleting the data write_file('players/'.unique_id.'/to_send/'.i.'.txt',0); write_file('players/'.unique_id.'/to_send/nr_string_'.i.'.txt',0); //deleting the data } } //increasing the priority of the remaining data j=1; for(i=1;i<=10;i++) { nr_arg=read_file('players/'.unique_id.'/to_send/nr_'.i.'.txt'); if(nr_arg!=0) { move_file_contents('players/'.unique_id.'/to_send/'.i.'.txt','players/'.unique_id.'/to_send/'.j.'.txt',1); move_file_contents('players/'.unique_id.'/to_send/nr_string_'.i.'.txt','players/'.unique_id.'/to_send/nr_string_'.j.'.txt',1); } } echo output; //adding to server log if(dev_log) { save_to_log(output,1); } } function send_data_to_player(player_id,data,nr_strings=0) { //data[0]=event; data[1]=arg1 //numer of args is without the event // player_ip=get_player_ip(); //finding a slot to save the output slot=10; for(i=1;i<=10;i++) { args=read_file('players/'.player_id.'/to_send/'.i.'.txt'); args=explode("|",args); nr_arg=count(args) - 1; if(nr_arg==0) { slot=i; break; } } //slot found nr_args=count(data); nr_args--; output=data[0];//data[0]; for(i=1;i<=nr_args;i++) { output.='|'.data[i]; } write_file('players/'.player_id.'/to_send/'.slot.'.txt',output); write_file('players/'.player_id.'/to_send/nr_string_'.slot.'.txt',nr_strings); } ?> Convert from PHP to Python
de59605eae68cc5f93ae3c6c175bd3e7
{ "intermediate": 0.3317450284957886, "beginner": 0.4312151372432709, "expert": 0.23703980445861816 }
43,946
write a generic django adrf crud class that contains all the necessary async crud for any models in a way that when in views i can just calls model_name_view(class) it will auto get all the nessceary crud ( including setting paginations , filters ,sorting , choosing search params etc… )
f135eb040435184add11273469217968
{ "intermediate": 0.6700314879417419, "beginner": 0.19903351366519928, "expert": 0.13093499839305878 }
43,947
with django we have two tables : steps containing : "id","step_name" and substeps containing "id","substep_name","step" .. we want to create models in a way where "step" in substeps table is the "step_name" from steps table , in a way the code raises an error if the name isn't in the table steps
29c21b783bb3c59ec60f1e00050950f8
{ "intermediate": 0.6167424321174622, "beginner": 0.06733734905719757, "expert": 0.3159201741218567 }
43,948
I have a situation when my React component that has input states that there is no value in it when using CSS but when using js I can get the correct value from it. What may cause it?
ae7c8f95fd9d7c7fff2ae6861c526839
{ "intermediate": 0.6029430031776428, "beginner": 0.26505059003829956, "expert": 0.13200637698173523 }
43,949
I have incomplete AES key like this : 34415102f3be22c6f83343be762e2d and i want to brute the last probable part on python
c0b41980a0d93282afbe739553ef37b1
{ "intermediate": 0.38345882296562195, "beginner": 0.2630493640899658, "expert": 0.353491872549057 }
43,950
Coding stargen in scratch.mit.edu (next step 1)
a94d28fde56e45250c95a06d0efe3a93
{ "intermediate": 0.23408964276313782, "beginner": 0.26276156306266785, "expert": 0.5031487941741943 }
43,951
Coding star system generator in scratch.mit.edu (next step 1), using visual programming codes into source code like Python
f7d4b6b8d9aae0e5817917f94ba226b4
{ "intermediate": 0.306444376707077, "beginner": 0.2691788673400879, "expert": 0.42437681555747986 }
43,952
code_func.py """ import os import time from functions.hardwired_functions import * from functions.init_player import * from functions.deconnect_player import * from functions.troops_functions import * from functions.player_id_functions import * from functions.player_functions import * from functions.files_functions import * from functions.other_functions import * from triggers.on_connect import * from triggers.on_deconnect import * def main_code(unique_id, event, nr_args, args): event = args[0] if unique_id == 0 and event != 1 and event != 2: return send_data_to_player(unique_id, [2, 0]) # force log in else: if event == 1: # REGISTER ACCOUNT # INPUT: arg1-username arg2-password # OUTPUT: arg1-state arg2-unique id if len(args) > 1: username = args[1] if check_string(username) and not username.isnumeric(): if os.path.exists("accounts/" + username + ".txt"): return send_data_to_player(unique_id, [1, 0]) # the account already exists else: last_unique_id = read_file("server_vars/player.txt") + 1 write_file("server_vars/player.txt", last_unique_id) write_file("username_id/" + username + ".txt", last_unique_id) write_file("accounts/" + username + ".txt", "") make_dir('players/' + str(last_unique_id) + '/') # create the id directory init_player(last_unique_id, username) return send_data_to_player(unique_id, [1, 1, last_unique_id]) # successful creation of account else: return send_data_to_player(unique_id, [1, 4]) # invalid characters used elif event == 2: # LOG IN # INPUT: arg1-username arg2-password # OUTPUT: arg1-state arg2-unique id arg3-local id if len(args) > 1: username = args[1] if check_string(username) and not username.isnumeric(): if os.path.exists("accounts/" + username + ".txt"): local_id_slot = find_local_id(0) if local_id_slot != 0: if os.path.exists("ip_login/" + get_player_ip() + ".txt"): unique_id_real = get_unique_id_by_username(username) return send_data_to_player(unique_id, [2, 2, unique_id_real, get_local_id_by_ip()]) # successful log in send_initial_players(unique_id_real) else: unique_id_real = get_unique_id_by_username(username) write_file("ip_login/" + get_player_ip() + ".txt", local_id_slot) write_file("local_id/" + str(local_id_slot) + ".txt", unique_id_real) write_file("players/" + str(unique_id_real) + "/active.txt", 1) write_file("players/" + str(unique_id_real) + "/last_time_active.txt", time.time()) write_file("players/" + str(unique_id_real) + "/ip.txt", get_player_ip()) write_file("players/" + str(unique_id_real) + "/local_id.txt", local_id_slot) write_file("players/" + str(unique_id_real) + "/ping.txt", 0) write_file("players/" + str(unique_id_real) + "/ping_var.txt", 0) return send_data_to_player(unique_id, [2, 2, unique_id_real, local_id_slot]) # successful log in send_initial_players(unique_id) ti_on_player_connect(unique_id_real) else: return send_data_to_player(unique_id, [2, 3]) # the server is full else: return send_data_to_player(unique_id, [2, 1]) # invalid user or pass else: return send_data_to_player(unique_id, [2, 1]) # invalid user or pass else: return send_data_to_player(unique_id, [2, 4]) # invalid characters used # Remaining conditions to be implemented similarly elif event == 3: # CHAT # Input arg1 - message if len(args) > 1: message = args[1] if message != '': if message.isnumeric(): message += ' ' username = get_player_username(unique_id) for i in range(1, 11): u_id = get_unique_id_by_local(i) if u_id != 0: return send_data_to_player(u_id, [3, message, username], 2) elif event == 4: # SAVE PLAYER POSITION # Input: arg1-x arg2-y arg3-rotation # output: none if len(args) > 3: x, y, rot = args[1], args[2], args[3] allow_teleport = False # Define allow_teleport if not already defined if allow_teleport: set_position(unique_id, x, y, rot) else: position = get_position(unique_id) old_x, old_y, old_rot = position[0], position[1], position[2] distance = ((old_x - x) ** 2 + (old_y - y) ** 2) ** 0.5 if distance < 1000: set_position(unique_id, x, y, rot) else: to_send = [5, old_x, old_y, old_rot] return send_data_to_player(unique_id, to_send) # return send_data_to_player(unique_id, [15, " " + distance, 0xFF0000], 1) # Implement the remaining conditions using the same structure elif event == 6: # SEND PLAYERS POSITION # Input: none # Output: arg1 - number of players arg2 - local player id arg3 - x arg4- y arg5 - rot arg6 -local player id .... number_of_players = 0 to_send = [6] c = 2 for i in range(1, 11): u_id = get_unique_id_by_local(i) if u_id != 0 and u_id != unique_id: number_of_players += 1 to_send[c] = i c += 1 position = get_position(u_id) x, y, rot = position[0], position[1], position[2] to_send[c] = x c += 1 to_send[c] = y c += 1 to_send[c] = rot c += 1 c -= 1 to_send[1] = number_of_players return send_data_to_player(unique_id, to_send) elif event == 9: # PING if len(args) > 1: if args[1] == 0: write_file("players/" + str(unique_id) + "/ping_var.txt", round(time.time(), 2)) return send_data_to_player(unique_id, [9, 1]) else: time_var = read_file("players/" + str(unique_id) + "/ping_var.txt") ping = round((time.time() - time_var) * 100) write_file("players/" + str(unique_id) + "/ping.txt", ping) write_file("players/" + str(unique_id) + "/ping_var.txt", 0) data = [9, 0] for i in range(1, 11): u_id = get_unique_id_by_local(i) if u_id != 0: data.append(read_file("players/" + str(u_id) + "/ping.txt") if u_id != 0 else 0) return send_data_to_player(unique_id, data) elif event == 10: # SEND PLAYER INVENTORY inv = read_file("players/" + str(unique_id) + "/inventory.txt") inv = inv.split("|") inv[0] = 10 return send_data_to_player(unique_id, inv) elif event == 11: # SEND PLAYER GOLD return send_data_to_player(unique_id, [11, get_gold(unique_id)]) elif event == 14: # SEND PLAYER TROOPS troops = read_file("players/" + str(unique_id) + "/troops.txt") troops = troops.split("|") nr = sum([1 for a in troops if a != -1]) troops[0] = 14 troops[1] = nr + 2 # incrementing here, so we will not have to increment in the game return send_data_to_player(unique_id, troops) elif event == 16: # JOIN BATTLE # New event for setting up or acknowledging a meeting # INPUT: arg1 - multiplayer party name if len(args) > 1: multiplayer_party_name = args[1] target_player_unique_id = get_unique_id_by_username(multiplayer_party_name) # Perform checks and actions as needed… return send_data_to_player(target_player_unique_id, [16, 0]) # Example action # Additional handling, like updating status, logging, etc. """ multiplayer.py """ from flask import Flask, request, make_response import os from time import time from server_config import * # from code_func import main_code from functions.hardwired_functions import * from functions.init_player import * from functions.deconnect_player import * from functions.troops_functions import * from functions.player_id_functions import * from functions.player_functions import * from functions.files_functions import * from functions.other_functions import * from triggers.on_connect import * from triggers.on_deconnect import * app = Flask(__name__) @app.route('/multiplayer') def main(): counter = 1 result = None # Initialized result to None or an appropriate default value # Checking for active players last_time_check = read_file("server_vars/check_time.txt") if (time() - float(last_time_check)) >= 1: write_file("server_vars/check_time.txt", time()) check_players_activity() player_ip = get_player_ip() if os.path.exists(f"ip_login/{player_ip}.txt"): local_id = read_file(f"ip_login/{player_ip}.txt") unique_id = read_file(f"local_id/{local_id}.txt") else: unique_id = None # Handle events and arguments while True: event = request.args.get(f"event{counter}") if event: number_of_arguments = request.args.get(f"nrarg{counter}", default=0, type=int) data_args = [event] for i in range(1, number_of_arguments): arg = request.args.get(f"arg{counter}|{i}") if arg: data_args.append(arg) # Ensure result is assigned a new value or modified during each loop iteration as needed result = main_code(unique_id, event, number_of_arguments - 1, data_args) counter += 1 else: break # Check if result is still None (or whatever default value you chose) and handle accordingly if result is None: result = "No event processed" # Adjust this based on the needs of your application return str(result) if __name__ == '__main__': app.run(debug=True) """ server_config.py """ dev_log = 1 # it holds all the data (every single packet). it is for devs or for errors reporting. 1 - enable, 0 - disable dev_log_path = 'logs/dev_log.txt' server_log = 1 # enable log save server_log_path = 'logs/server_log.txt' allow_teleport = 1 # 1 - allow teleport on the map; 0 - does not allow. If set to 0, it is possible to crash the game when you try to teleport. starting_gold = 2000 """ functions/check_players_activity.py """ import os import time from functions.hardwired_functions import * from functions.init_player import * from functions.deconnect_player import * from functions.troops_functions import * from functions.player_id_functions import * from functions.player_functions import * from functions.files_functions import * from functions.other_functions import * def read_file(file_path): if os.path.exists(file_path): with open(file_path, 'r') as file: return file.read() return 0 def check_players_activity(): for i in range(1, 11): unique_id = read_file(f"local_id/{i}.txt") if unique_id != 0: last_time_active = int(read_file(f"players/{unique_id}/last_time_active.txt")) if time.time() - last_time_active > 3: # if more than 3 seconds passed since last active deconnect_player(unique_id) """ functions/deconnect_player.py """ import os from functions.hardwired_functions import * from functions.init_player import * from functions.deconnect_player import * from functions.troops_functions import * from functions.player_id_functions import * from functions.player_functions import * from functions.files_functions import * from functions.other_functions import * from triggers.on_connect import * from triggers.on_deconnect import * def deconnect_player(unique_id): player_ip = read_file(f"players/{unique_id}/ip.txt") local_id = get_local_id_by_unique(unique_id) if os.path.exists(f"ip_login/{player_ip}.txt"): os.remove(f"ip_login/{player_ip}.txt") write_file(f"local_id/{get_local_id_by_unique(unique_id)}.txt", 0) write_file(f"players/{unique_id}/active.txt", 0) write_file(f"players/{unique_id}/ip.txt", "0.0.0.0") write_file(f"players/{unique_id}/local_id.txt", 0) ti_on_player_deconnect(unique_id, local_id) """ functions/files_functions.py """ import os def make_dir(path): os.makedirs(path, mode=0o700, exist_ok=True) def move_file_contents(file_source, file_output, delete=False): contents = read_file(file_source) write_file(file_output, contents) if delete: write_file(file_source, 0) def read_file(file_path): if os.path.exists(file_path): with open(file_path, 'r') as file: return file.read() return 0 def write_file(file_path, contents): with open(file_path, 'w') as file: file.write(str(contents)) """ functions/functions.py """ from server_config import * # Include server configuration from functions.hardwired_functions import * from functions.init_player import * from functions.deconnect_player import * from functions.troops_functions import * from functions.player_id_functions import * from functions.player_functions import * from functions.files_functions import * from functions.other_functions import * from triggers.on_connect import * from triggers.on_deconnect import * """ functions/init_player.py """ from functions.hardwired_functions import * from functions.init_player import * from functions.deconnect_player import * from functions.troops_functions import * from functions.player_id_functions import * from functions.player_functions import * from functions.files_functions import * from functions.other_functions import * def init_player(unique_id, username, starting_gold): player_root = f"players/{unique_id}/" make_dir(player_root + "to_send") for i in range(1, 11): write_file(player_root + f"to_send/{i}.txt", '0') write_file(player_root + f"to_send/nr_string_{i}.txt", '0') write_file(player_root + "position.txt", "0|0|0") write_file(player_root + "username.txt", username) write_file(player_root + "local_id.txt", '0') write_file(player_root + "ip.txt", '0') write_file(player_root + "active.txt", '0') write_file(player_root + "last_time_active.txt", '0') write_file(player_root + "ping.txt", '0') write_file(player_root + "ping_var.txt", '0') write_file(player_root + "gold.txt", starting_gold) inv = '-1' for i in range(1, 92): inv += '|-1' write_file(player_root + "inventory.txt", inv) troops = '-1|-1|0' for i in range(1, 40): troops += '|-1' write_file(player_root + "troops.txt", troops) """ functions/hardwired_functions.py """ from functions.hardwired_functions import * from functions.init_player import * from functions.deconnect_player import * from functions.troops_functions import * from functions.player_id_functions import * from functions.player_functions import * from functions.files_functions import * from functions.other_functions import * import os import shutil dev_log = False def send_data(unique_id): global dev_log total_length = 0 output = '' for i in range(1, 11): args = read_file(f'players/{unique_id}/to_send/{i}.txt').split('|') nr_str = read_file(f'players/{unique_id}/to_send/nr_string_{i}.txt') nr_arg = len(args) - 1 if total_length + nr_arg < 100 and nr_arg != 0 and read_file(f'players/{unique_id}/to_send/{i}.txt') != "0": total_length += nr_arg output += f'{nr_arg}|{nr_str}|' + "|".join(args) + '|' # Deleting the data write_file(f'players/{unique_id}/to_send/{i}.txt', 0) write_file(f'players/{unique_id}/to_send/nr_string_{i}.txt', 0) # Increasing the priority of the remaining data j = 1 for i in range(1, 11): nr_arg = read_file(f'players/{unique_id}/to_send/nr_{i}.txt') if nr_arg != "0": move_file_contents(f'players/{unique_id}/to_send/{i}.txt', f'players/{unique_id}/to_send/{j}.txt', 1) move_file_contents(f'players/{unique_id}/to_send/nr_string_{i}.txt', f'players/{unique_id}/to_send/nr_string_{j}.txt', 1) j += 1 print(output) if dev_log: save_to_log(output, 1) def send_data_to_player(player_id, data, nr_strings=0): slot = 10 for i in range(1, 11): args = read_file(f'players/{player_id}/to_send/{i}.txt').split('|') nr_arg = len(args) - 1 if nr_arg == 0: slot = i break nr_args = len(data) - 1 output = data[0] for i in range(1, nr_args + 1): output += f'|{data[i]}' write_file(f'players/{player_id}/to_send/{slot}.txt', output) write_file(f'players/{player_id}/to_send/nr_string_{slot}.txt', nr_strings) return output """ functions/other_functions.py """ import re from functions.hardwired_functions import * from functions.init_player import * from functions.deconnect_player import * from functions.troops_functions import * from functions.player_id_functions import * from functions.player_functions import * from functions.files_functions import * from functions.other_functions import * def check_players_activity(): for i in range(1, 11): unique_id = read_file(f"local_id/{i}.txt") if unique_id != '0': last_time_active = read_file(f"players/{unique_id}/last_time_active.txt") if time() - float(last_time_active) > 3: # if more than 3 seconds passed since last active deconnect_player(unique_id) def microtime_float(): usec, sec = time().split(" ") return float(usec) + float(sec) def check_string(string): if re.match("^[a-zA-Z0-9\_\-\[\]\~]+$", string): return 1 else: return 0 def send_initial_players(unique_id): nr_players = 0 to_send = [8] c = 1 for i in range(1, 11): u_id = get_unique_id_by_local(i) if u_id != 0: position = get_position(u_id) x, y, rot = position[0], position[1], position[2] to_send.extend([x, y, rot, get_player_username(u_id), get_active(u_id)]) else: to_send.extend([0, 0, 0, "Offline", 0]) send_data_to_player(unique_id, to_send, 10) def save_to_log(string, dev=0): if dev: with open(dev_log_path, 'a') as fh: fh.write(f"{get_client_ip()} -- {get_request_uri()} --- {string}\n") else: if server_log: with open(server_log_path, 'a') as fh: fh.write(f"{string}\n") """ functions/player_functions.py """ from functions.hardwired_functions import * from functions.init_player import * from functions.deconnect_player import * from functions.troops_functions import * from functions.player_id_functions import * from functions.player_functions import * from functions.files_functions import * from functions.other_functions import * def get_active(unique_id): return read_file(f'players/{unique_id}/active.txt') def get_position(unique_id): position = read_file(f'players/{unique_id}/position.txt') array = position.split("|") return array def get_gold(unique_id): return read_file(f'players/{unique_id}/gold.txt') def get_last_time_active(unique_id): return read_file(f'players/{unique_id}/last_time.txt') def inventory_get_slot(unique_id, slot): inv = read_file(f'players/{unique_id}/inventory.txt') inv_array = inv.split("|") return inv_array[slot] def inventory_set_slot(unique_id, slot, value): inv = read_file(f'players/{unique_id}/inventory.txt') inv_array = inv.split("|") inv_array[slot] = value to_write = "|".join(inv_array) write_file(f'players/{unique_id}/inventory.txt', to_write) def set_last_time_active(unique_id): write_file(f'players/{unique_id}/last_time.txt', time()) def set_position(unique_id, x, y, rot): write_file(f'players/{unique_id}/position.txt', f'{x}|{y}|{rot}') def set_gold(unique_id, gold): write_file(f'players/{unique_id}/gold.txt', gold) def set_active(unique_id, state): write_file(f'players/{unique_id}/active.txt', state) """ functions/player_id_functions.py """ from flask import request from functions.hardwired_functions import * from functions.init_player import * from functions.deconnect_player import * from functions.troops_functions import * from functions.player_id_functions import * from functions.player_functions import * from functions.files_functions import * from functions.other_functions import * def read_file(filename): with open(filename, 'r') as file: return file.read().strip() def find_local_id(id): for i in range(1, 11): file_id = read_file(f"local_id/{i}.txt") if file_id == id: return i return 0 def get_player_ip(): print(request.remote_addr) return request.remote_addr def get_unique_id_by_username(username): return read_file(f"username_id/{username}.txt") def get_unique_id_by_local(local): return read_file(f"local_id/{local}.txt") def get_player_username(unique_id): return read_file(f"players/{unique_id}/username.txt") def get_local_id_by_ip(ip=0): if ip == 0: return read_file(f"ip_login/{request.remote_addr}.txt") else: return read_file(f"ip_login/{ip}.txt") def get_local_id_by_unique(unique_id): return read_file(f"players/{unique_id}/local_id.txt") """ functions/send_initial_players.py """ from hardwired_functions import * from init_player import * from deconnect_player import * from troops_functions import * from player_id_functions import * from player_functions import * from files_functions import * from other_functions import * def send_initial_players(unique_id): nr_players = 0 to_send = [8] c = 1 for i in range(1, 11): u_id = get_unique_id_by_local(i) if u_id != 0: position = get_position(u_id) x, y, rot = position[0], position[1], position[2] to_send.extend([x, y, rot, get_player_username(u_id), get_active(u_id)]) else: to_send.extend([0, 0, 0, "Offline", 0]) send_data_to_player(unique_id, to_send, 10) """ functions/troops_functions.py """ from functions.hardwired_functions import * from functions.init_player import * from functions.deconnect_player import * from functions.troops_functions import * from functions.player_id_functions import * from functions.player_functions import * from functions.files_functions import * from functions.other_functions import * def player_get_troop_id(unique_id, troop_slot): troop = read_file(f"players/{unique_id}/troops.txt") array = troop.split("|") return array[troop_slot] def player_set_troop_slot(unique_id, slot, troop_id): troop = read_file(f"players/{unique_id}/troops.txt") array = troop.split("|") array[slot] = troop_id to_write = "|".join(array) write_file(f"players/{unique_id}/troops.txt", to_write) """ triggers/on_connect.py """ from functions.hardwired_functions import * from functions.init_player import * from functions.deconnect_player import * from functions.troops_functions import * from functions.player_id_functions import * from functions.player_functions import * from functions.files_functions import * from functions.other_functions import * def ti_on_player_connect(unique_id): username = get_player_username(unique_id) local_id = get_local_id_by_unique(unique_id) # send player log in to all active players for i in range(1, 11): u_id = get_unique_id_by_local(i) if u_id != 0: send_data_to_player(u_id, [7, 1, local_id, username], 1) # player log in! position = get_position(unique_id) x = position[0] y = position[1] rot = position[2] to_send = [5, x, y, rot] send_data_to_player(unique_id, to_send) save_to_log(username + ' connected with ip ' + get_player_ip()) send_data_to_player(unique_id, [15, "NEW WEBSERVER! " + username + "!^Welcome to my coop server!", 0xA0EDF7, 1]) """ triggers/on_deconnect.py """ from functions.hardwired_functions import * from functions.init_player import * from functions.deconnect_player import * from functions.troops_functions import * from functions.player_id_functions import * from functions.player_functions import * from functions.files_functions import * from functions.other_functions import * def ti_on_player_deconnect(unique_id, local_id): username = get_player_username(unique_id) for j in range(1, 11): u_id = get_unique_id_by_local(j) if u_id != 0 and u_id != unique_id: send_data_to_player(u_id, [7, 2, local_id, username], 1) # player disconnect save_to_log(username + ' lost connection/disconnect') """ What's wrong with whole code? Tell where you need to fix and give the code + make it work with Flask (in the browser output to 127.0.0.0.1:5000/mutliplayer should be output "1|0|2|0|", all other requests should have their own). Example request from devlog: 127.0.0.0.1--/multiplayer.php?&event1=4&nrarg1=4&arg1%7C1=0&arg1%7C2=0&arg1%7C3=0 ---
aa9f673b7f83b4b33e7965a194587f8d
{ "intermediate": 0.4396096467971802, "beginner": 0.4360824227333069, "expert": 0.12430795282125473 }
43,953
you have a fastapi project that works as a pricing engine for an insurance , the process includes 12 independent steps that call in to a list of substeps , the goal is to call the 12 steps in parallel in the logic and retireve the result then run an equation on the result of each , the requests are treated always as a batch that can contain [x] or [x,...,n] , first start by writing a project hiearchy to represent the project main files and packages and all the py files that need to be under them as well as what they c ontain
118bd1030ed3e60632cc0f32c8360325
{ "intermediate": 0.6973236203193665, "beginner": 0.08284615725278854, "expert": 0.21983025968074799 }
43,954
am runing this is bash code --install-extension njpwerner.autodocstring --force code --install-extension ms-python.black-formatter --force code --install-extension ms-python.flake8 --force code --install-extension ms-vscode.makefile-tools --force code --install-extension ms-python.mypy-type-checker --force code --install-extension esbenp.prettier-vscode --force code --install-extension ms-python.vscode-pylance --force code --install-extension ms-python.pylint --force code --install-extension ms-python.python --force code --install-extension ms-python.debugpy --force code --install-extension kevinrose.vsc-python-indent --force it exits on Extension ‘njpwerner.autodocstring’ is already installed. i want it to finish running the whole script use for
d9ddb3bbbc88423d37f9771ca82ab54c
{ "intermediate": 0.36830762028694153, "beginner": 0.37447652220726013, "expert": 0.25721585750579834 }
43,955
c
cb4a3e18df492c4febde59d138f25055
{ "intermediate": 0.3221464157104492, "beginner": 0.32356899976730347, "expert": 0.3542845845222473 }
43,956
* - *Italic* ** - **Bold** ` - `Monospace`
d033a23f0a99b084fe445c43ff07f4eb
{ "intermediate": 0.32304099202156067, "beginner": 0.30995139479637146, "expert": 0.36700767278671265 }
43,957
List of formats, I unlocked: 1. Italic - *, _ 2. Bold - ** 3. Bold-italic - *** 4. Monospace - ` 5. Strikethrough - ~~
44b42753c37a1a3334961e57e9b6710c
{ "intermediate": 0.3854191303253174, "beginner": 0.2293122112751007, "expert": 0.3852686882019043 }
43,958
definition_list = { "while loop": "A loop that only ends once a condition is met.", "for loop": "A loop that runs for a specified number of times.", "return": "A command that passes one value from one function to another.", "break": "A command that stops a loop while it's running." } def get_definition(): while True: word = input("What coding term would you like to define?") definition = definition_list.get(word) if definition is not None: print("") def main(): definition = get_definition() print(definition) main() This program does not work the way we want it to! It has a logic error and we need to fix it! A return stops a while loop while it's running. In this capacity, it's similar to the keyword break. Click Run and enter a term that's included in the definition_list. See how the program doesn't end? Fix the bug by dragging Return Statement inside the if statement and changing my_var to definition. Click Run now to see a definition! Click Submit and Next when ready to move on.
76b6afebf4a087d803eab3dd5d50099a
{ "intermediate": 0.1725681722164154, "beginner": 0.6777700781822205, "expert": 0.14966174960136414 }
43,959
*Test*
1025b703e204d8a765033f8d7460aa8e
{ "intermediate": 0.3902263939380646, "beginner": 0.3181783854961395, "expert": 0.2915951609611511 }
43,960
List of formats, I unlocked: 1. Italic - *, _ 2. Bold - ** 3. Bold-italic - *** 4. Monospace - ` 5. Strikethrough - ~~
89a7280514fdc17eb417e7815621b9ca
{ "intermediate": 0.3854191303253174, "beginner": 0.2293122112751007, "expert": 0.3852686882019043 }
43,961
I have multiple invoice no in one cell and i want to lookup each invoice with their relevant data. give me a excel formula for the same.
0d4e895ed9e42afbf604ef38a10eb9c5
{ "intermediate": 0.44118231534957886, "beginner": 0.23195362091064453, "expert": 0.3268641233444214 }
43,962
In Python, make a POST request that is a "mutlipart/form-data" with the library "urllib.request". The keys are "FILE_A", "FILE_B" and "FILE_C", and the value of each one are the content of a file.
fcf5c760240e0c71f25586c7bb06df74
{ "intermediate": 0.7120345234870911, "beginner": 0.09116631001234055, "expert": 0.19679921865463257 }
43,963
please implement dot pagination in react native
606ed59c463f1b63fe7a18baa79ef089
{ "intermediate": 0.625555157661438, "beginner": 0.1436128318309784, "expert": 0.23083198070526123 }
43,964
help me in coding a full implementation of a decoder transformer and two lists: inputs and targets to get the model trained on them, i have already coded a decoder transformer but for another purpose, here is the code for that: import torch import torch.nn.functional as F from torch.optim.lr_scheduler import StepLR # Example scheduler import torch.nn as nn import torch.optim as optim import json from tokenizers import Tokenizer from torch.utils.data import Dataset import random import math class PositionalEncoding(nn.Module): def __init__(self, embedding_dim, max_len=5000): super(PositionalEncoding, self).__init__() self.embedding_dim = embedding_dim # Creating positional encoding matrix pe = torch.zeros(max_len, embedding_dim) position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(1) div_term = torch.exp(torch.arange(0, embedding_dim, 2).float() * (-math.log(10000.0) / embedding_dim)) pe[:, 0::2] = torch.sin(position * div_term) pe[:, 1::2] = torch.cos(position * div_term) pe = pe.unsqueeze(0).transpose(0, 1) # Registering pe as a buffer since it’s not a model parameter self.register_buffer('pe', pe) def forward(self, x): x = x + self.pe[:x.size(0), :] return x class DecoderLayer(nn.Module): def __init__(self, embedding_dim, heads, ff_dim): super(DecoderLayer, self).__init__() self.self_attn = nn.MultiheadAttention(embedding_dim, heads) # Feedforward network self.ffn = nn.Sequential( nn.Linear(embedding_dim, ff_dim), nn.ReLU(), nn.Linear(ff_dim, embedding_dim), ) self.layer_norm1 = nn.LayerNorm(embedding_dim) self.layer_norm2 = nn.LayerNorm(embedding_dim) def forward(self, src): src2 = self.layer_norm1(src) attn_output, _ = self.self_attn(src2, src2, src2) src = src + attn_output src2 = self.layer_norm2(src) src = src + self.ffn(src2) return src class Decoder(nn.Module): def __init__(self, vocab_size, embedding_dim, num_layers, heads, ff_dim): super(Decoder, self).__init__() self.embedding = nn.Embedding(vocab_size, embedding_dim) self.pos_encoding = PositionalEncoding(embedding_dim) self.decoder_layers = nn.ModuleList([DecoderLayer(embedding_dim, heads, ff_dim) for _ in range(num_layers)]) self.final_layer = nn.Linear(embedding_dim, vocab_size) def forward(self, x): x = self.embedding(x) x = self.pos_encoding(x) for layer in self.decoder_layers: x = layer(x) output = self.final_layer(x) return output class QAJsonlDataset(Dataset): def __init__(self, path, tokenizer_path, seq_len=512): super().__init__() # Load the trained tokenizer self.tokenizer = Tokenizer.from_file(tokenizer_path) self.seq_len = seq_len self.pairs = self.load_data(path) def load_data(self, path): pairs = [] with open(path, "r", encoding="utf-8") as f: # Assume UTF-8 encoded JSON for line in f: data = json.loads(line) # Assuming ‘question’ and ‘answer’ are the keys # Tokenize directly here and truncate/pad as necessary question = self.tokenize(data['user']) answer = self.tokenize(data['content']) pairs.append((question, answer)) return pairs def tokenize(self, text): # Encode the text, truncating or padding to seq_len as required output = self.tokenizer.encode(text).ids # Truncate if needed output = output[:self.seq_len] # Pad if needed if len(output) < self.seq_len: output += [self.tokenizer.token_to_id('<pad>')] * (self.seq_len - len(output)) return output def __len__(self): return len(self.pairs) def __getitem__(self, idx): question, answer = self.pairs[idx] return torch.tensor(question, dtype=torch.long), torch.tensor(answer, dtype=torch.long) class CustomDataLoader: def __init__(self, dataset, batch_size=32): self.dataset = dataset self.batch_size = batch_size def len(self): return len(self.dataset) // self.batch_size def __getitem__(self, idx): batch = self.dataset[idx * self.batch_size:(idx + 1) * self.batch_size] inputs, targets = zip(*batch) inputs_padded = torch.nn.utils.rnn.pad_sequence(inputs, batch_first=True, padding_value=0) targets_padded = torch.nn.utils.rnn.pad_sequence(targets, batch_first=True, padding_value=0) return inputs_padded, targets_padded # Paths for tokenizer and dataset path_to_data = "data/Real_talk.jsonl" tokenizer_path = "Tokenizer-Max.json" tokenizer = Tokenizer.from_file(tokenizer_path) # Define model parameters vocab_size = tokenizer.get_vocab_size() embedding_dim = 24 num_layers = 2 # Number of decoder layers heads = 4 # Number of attention heads ff_dim = 96 # Feed-forward dimension # Initialize dataset dataset = QAJsonlDataset(path_to_data, tokenizer_path) # Initialize decoder model with correct vocab size model = Decoder(vocab_size, embedding_dim, num_layers, heads, ff_dim) # Shuffle the dataset random.shuffle(dataset.pairs) train_size = int(0.9 * len(dataset)) # 80% of data for training, adjust as necessary val_size = len(dataset) - train_size train_dataset, val_dataset = torch.utils.data.random_split(dataset, [train_size, val_size]) train_loader = torch.utils.data.DataLoader(train_dataset, batch_size=32, shuffle=True) val_loader = torch.utils.data.DataLoader(val_dataset, batch_size=32) # Define optimizer optimizer = optim.Adam(model.parameters()) loss_fn = nn.CrossEntropyLoss() # PyTorch version of SparseCategoricalCrossentropy with from_logits=True def print_model_param_count(model): total_params = sum(p.numel() for p in model.parameters() if p.requires_grad) print(f"Total Trainable Parameters: {total_params}") # Assuming your model’s variable name is model print_model_param_count(model) # Define an optimizer and a learning rate scheduler optimizer = optim.Adam(model.parameters(), lr=0.005) scheduler = StepLR(optimizer, step_size=10, gamma=0.7) # Example scheduler, adjust according to needs def train(model, train_loader, optimizer, scheduler, num_epochs): model.train() for epoch in range(num_epochs): total_loss = 0 for batch_idx, (inputs, targets) in enumerate(train_loader): optimizer.zero_grad() outputs = model(inputs) loss = F.cross_entropy(outputs.view(-1, vocab_size), targets.view(-1)) loss.backward() optimizer.step() total_loss += loss.item() if batch_idx % 50 == 0: # Adjust logging frequency as needed print(f'Epoch {epoch} [{batch_idx * len(inputs)}/{len(train_loader.dataset)}] Loss: {loss.item()}') # Step the scheduler scheduler.step() # Call evaluation function here (assuming you have one) val_accuracy = evaluate(model, val_loader) print(f'Epoch {epoch} Val Accuracy {val_accuracy}') def evaluate(model, val_loader): model.eval() total_accuracy = 0 with torch.no_grad(): for inputs, targets in val_loader: outputs = model(inputs) predictions = torch.argmax(outputs, dim=2) correct_predictions = (predictions == targets).float() mask = targets != tokenizer.token_to_id("<pad>") correct_predictions = correct_predictions * mask total_accuracy += correct_predictions.sum().item() / mask.sum().item() avg_accuracy = total_accuracy / len(val_loader) model.train() # Set the model back to training mode return avg_accuracy # Replace the existing training loop call with: train(model, train_loader, optimizer, scheduler, num_epochs=80) def generate_text(model, initial_text, tokenizer, seq_len=512, temperature=1.0): model.eval() # Ensures the model is in evaluation mode # Tokenize the initial text tokens = tokenizer.encode(initial_text).ids # Generate text with torch.no_grad(): for _ in range(seq_len - len(tokens)): input_tensor = torch.tensor([tokens], dtype=torch.long) output = model(input_tensor) logits = output[0, -1, :] / temperature probabilities = torch.softmax(logits, dim=-1) next_token = torch.argmax(probabilities).item() tokens.append(next_token) # Assume either a special token for EOS or check if max length reached if next_token == tokenizer.token_to_id('<eos>'): break # Decode the tokens back to text generated_text = tokenizer.decode(tokens) return generated_text # During usage, you pass the loaded tokenizer directly generated_text = generate_text(model, "what is earth ?", tokenizer, seq_len=64) print(generated_text)
9ef014c732d6a77ca9c1d8dcbb1a1110
{ "intermediate": 0.23732545971870422, "beginner": 0.4756460189819336, "expert": 0.2870284914970398 }
43,965
when print text which have persian text in django with print() tell me this error. UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-1: character maps to <undefined>
541ae827ae38d72dbc3b892e230af617
{ "intermediate": 0.6659817099571228, "beginner": 0.12467366456985474, "expert": 0.20934467017650604 }
43,966
comment mettre en place une base de donnée sqflite dans ce projet flutter dart pour gérer en premier lieu l'utilisateur qui jouera avec un id et un pseudo associé et enregistrer les scores de chaque utilisateur par la suiteimport 'package:flutter/material.dart'; import 'package:flutter_snake/UI/home.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: MyHomePage(), ); } } import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_snake/models/game_model.dart'; class SnakePage extends StatefulWidget { const SnakePage({Key? key}) : super(key: key); @override State<SnakePage> createState() => _SnakePageState(); } class _SnakePageState extends State<SnakePage> { GameModel gameModel = GameModel(); Timer? timer; @override void initState() { // TODO: implement initState print("start"); gameModel.start(); timer = Timer.periodic(Duration(milliseconds: 500), (timer) { setState(() { gameModel.moveSnake(); }); }); } void resetTimer() { timer?.cancel(); timer = Timer.periodic(Duration(milliseconds: 500), (timer) { setState(() { gameModel.moveSnake(); }); }); } @override void dispose() { // TODO: implement dispose timer?.cancel(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( leading: IconButton( icon: Icon(Icons.arrow_back), onPressed: () { // TODO: Implement your back button logic here Navigator.pop(context); }, ), title: Text('Snake Game. Score: ' + gameModel.score.toString()), actions: <Widget>[ PopupMenuButton<String>( onSelected: (String result) { // TODO: Implement your menu actions here }, itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[ const PopupMenuItem<String>( value: 'Pause', child: Text('Pause'), ), const PopupMenuItem<String>( value: 'Replay', child: Text('Replay'), ), ], ), ], ), body: Column( children: <Widget>[ Expanded( flex: 7, child: Container( color: Colors.green, child: GridView.builder( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 10, // Change this number as per your need ), itemBuilder: (BuildContext context, int index) { int y = index ~/ GameModel.NB_COLONNES; int x = index - ((index ~/ GameModel.NB_COLONNES) * GameModel.NB_COLONNES); Color cellColor; switch (gameModel.grid[y][x]) { case GameModel.SNAKE_HEAD: cellColor = Colors.yellow; break; case GameModel.SNAKE_BODY: cellColor = Colors.green; break; case GameModel.FOOD: print(index.toString() + " " + x.toString() + " " + y.toString()); cellColor = Colors.red; break; default: cellColor = Colors.lightGreen; } return GridTile( child: Container( decoration: BoxDecoration( color: cellColor, border: Border.all(color: Colors.white), ), // TODO: Add your game cell here ), ); }, itemCount: GameModel.NB_CASES, // Change this number as per your need ), ), ), Expanded( flex: 2, child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ ElevatedButton( onPressed: () { // TODO: Implement left direction logic setState(() { resetTimer(); gameModel.changeDirection(GameModel.DIRECTION_GAUCHE); }); }, child: Icon(Icons.arrow_left), ), Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ ElevatedButton( onPressed: () { // TODO: Implement up direction logic setState(() { resetTimer(); gameModel.changeDirection(GameModel.DIRECTION_HAUT); }); }, child: Icon(Icons.arrow_upward), ), ElevatedButton( onPressed: () { // TODO: Implement down direction logic setState(() { resetTimer(); gameModel.changeDirection(GameModel.DIRECTION_BAS); }); }, child: Icon(Icons.arrow_downward), ), ], ), ElevatedButton( onPressed: () { // TODO: Implement right direction logic setState(() { resetTimer(); gameModel.changeDirection(GameModel.DIRECTION_DROITE); }); }, child: Icon(Icons.arrow_right), ), ], ), ), ], ), ); } } import 'package:flutter/material.dart'; import 'package:flutter_snake/ui/snake_page.dart'; import 'package:flutter_snake/ui/classement_page.dart'; class MyHomePage extends StatefulWidget { const MyHomePage({Key? key}) : super(key: key); @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { int _currentIndex = 0; final List<Widget> _children = [ SnakePage(), ClassementPage(), ]; // on met les pages ici après void onTabTapped(int index) { setState(() { _currentIndex = index; }); } @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ ElevatedButton( child: Text('Jouer'), onPressed: () { Navigator.push( context, MaterialPageRoute(builder: (context) => SnakePage()), ); }, ), ElevatedButton( child: Text('Classement'), onPressed: () { Navigator.push( context, MaterialPageRoute(builder: (context) => ClassementPage()), ); }, ), ElevatedButton( child: Text('Règles'), onPressed: () { // Remplacez ceci par la navigation vers votre page de règles }, ), ], ), ), ); } } import 'package:flutter/material.dart'; class ClassementPage extends StatelessWidget { const ClassementPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const Center(child: Text('Page 1')); } } import 'package:flutter_snake/models/game_model.dart'; class SnakeModel { int x; int y; int size = 1; GameModel gameModel; List<List<int>> bodyPositions = []; SnakeModel({required this.gameModel, this.x = 0, this.y = 0}); void reset() { x = GameModel.NB_COLONNES ~/ 2; y = GameModel.NB_LIGNES ~/ 2; size = 2; bodyPositions = [ [x, y], [y, x - 1] ]; displaySnake(); } void displaySnake() { bodyPositions.insert(0, [x, y]); gameModel.grid[y][x] = GameModel.SNAKE_HEAD; for (int i = 1; i < bodyPositions.length; i++) { gameModel.grid[bodyPositions[i][1]][bodyPositions[i][0]] = GameModel.SNAKE_HEAD; } print("new snake head: x: $x, y: $y"); print("new snake body: x: ${bodyPositions}"); } void moveSnake(int direction) { int newX = x; int newY = y; switch (direction) { case GameModel.DIRECTION_HAUT: newY--; break; case GameModel.DIRECTION_DROITE: newX++; break; case GameModel.DIRECTION_BAS: newY++; break; case GameModel.DIRECTION_GAUCHE: newX--; break; } if (!gameModel.isInGrid(newX, newY)) { return; } gameModel.grid[y][x] = 0; x = newX; y = newY; bool ateFood = gameModel.isFood(x, y); if (ateFood) { growSnake(); gameModel.increaseScore(); gameModel.foodModel.createFood(); } else if (bodyPositions.isNotEmpty && bodyPositions.length > size) { List<int> lastBodyPart = bodyPositions.removeLast(); gameModel.grid[lastBodyPart[1]][lastBodyPart[0]] = 0; } displaySnake(); } void growSnake() { size++; } } import 'dart:math'; import 'package:flutter_snake/models/food_model.dart'; import 'package:flutter_snake/models/snake_model.dart'; class GameModel { static const int NB_CASES = 140; static const int NB_LIGNES = 14; static const int NB_COLONNES = 10; static const int DIRECTION_HAUT = 0; static const int DIRECTION_DROITE = 1; static const int DIRECTION_BAS = 2; static const int DIRECTION_GAUCHE = 3; static const int SNAKE_HEAD = 1; static const int SNAKE_BODY = 2; static const int FOOD = 3; int score = 0; int currentDirection = DIRECTION_DROITE; List<List<int>> grid = List.generate(NB_LIGNES, (i) => List.filled(NB_COLONNES, 0)); late FoodModel foodModel; late SnakeModel snakeModel; GameModel() { foodModel = FoodModel(gameModel: this); snakeModel = SnakeModel(gameModel: this); } // Add your class properties and methods here void start() { // on réinitialise la matrice for (int i = 0; i < NB_LIGNES; i++) { for (int j = 0; j < NB_COLONNES; j++) { grid[i][j] = 0; } } foodModel.createFood(); _displaySnakeBody(); } static List<int> getRandomCoordinates() { Random random = Random(); int randomX = random.nextInt(NB_COLONNES); int randomY = random.nextInt(NB_LIGNES); print("randomX: $randomX, randomY: $randomY"); return [randomX, randomY]; } void changeDirection(int newDirection) { currentDirection = newDirection; moveSnake(); } void moveSnake() { snakeModel.moveSnake(currentDirection); } bool isFood(int x, int y) { return grid[y][x] == FOOD; } bool isInGrid(int x, int y) { return x >= 0 && x < NB_COLONNES && y >= 0 && y < NB_LIGNES; } void increaseScore() { score++; } void _displaySnakeBody() { if (snakeModel.bodyPositions.isNotEmpty) { for (var position in snakeModel.bodyPositions) { int y = position[0]; int x = position[1]; grid[y][x] = GameModel.SNAKE_BODY; } var head = snakeModel.bodyPositions.first; grid[head[0]][head[1]] = GameModel.SNAKE_HEAD; } } void eatFood() {} }
dfe0ef76bf6ce4142bf1abdc1d19e819
{ "intermediate": 0.2961222231388092, "beginner": 0.35465508699417114, "expert": 0.34922271966934204 }
43,967
comment mettre en place une base de donnée sqflite dans ce projet flutter dart pour gérer en premier lieu l'utilisateur qui jouera avec un id et un pseudo associé et enregistrer les scores de chaque utilisateur par la import 'package:flutter/material.dart'; import 'package:flutter_snake/UI/home.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: MyHomePage(), ); } }import 'package:flutter/material.dart'; import 'package:flutter_snake/ui/snake_page.dart'; import 'package:flutter_snake/ui/classement_page.dart'; class MyHomePage extends StatefulWidget { const MyHomePage({Key? key}) : super(key: key); @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { int _currentIndex = 0; final List<Widget> _children = [ SnakePage(), ClassementPage(), ]; // on met les pages ici après void onTabTapped(int index) { setState(() { _currentIndex = index; }); } @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ ElevatedButton( child: Text('Jouer'), onPressed: () { Navigator.push( context, MaterialPageRoute(builder: (context) => SnakePage()), ); }, ), ElevatedButton( child: Text('Classement'), onPressed: () { Navigator.push( context, MaterialPageRoute(builder: (context) => ClassementPage()), ); }, ), ElevatedButton( child: Text('Règles'), onPressed: () { // Remplacez ceci par la navigation vers votre page de règles }, ), ], ), ), ); } } import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_snake/models/game_model.dart'; class SnakePage extends StatefulWidget { const SnakePage({Key? key}) : super(key: key); @override State<SnakePage> createState() => _SnakePageState(); } class _SnakePageState extends State<SnakePage> { GameModel gameModel = GameModel(); Timer? timer; @override void initState() { // TODO: implement initState print("start"); gameModel.start(); timer = Timer.periodic(Duration(milliseconds: 500), (timer) { setState(() { gameModel.moveSnake(); }); }); } void resetTimer() { timer?.cancel(); timer = Timer.periodic(Duration(milliseconds: 500), (timer) { setState(() { gameModel.moveSnake(); }); }); } @override void dispose() { // TODO: implement dispose timer?.cancel(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( leading: IconButton( icon: Icon(Icons.arrow_back), onPressed: () { // TODO: Implement your back button logic here Navigator.pop(context); }, ), title: Text('Snake Game. Score: ' + gameModel.score.toString()), actions: <Widget>[ PopupMenuButton<String>( onSelected: (String result) { // TODO: Implement your menu actions here }, itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[ const PopupMenuItem<String>( value: 'Pause', child: Text('Pause'), ), const PopupMenuItem<String>( value: 'Replay', child: Text('Replay'), ), ], ), ], ), body: Column( children: <Widget>[ Expanded( flex: 7, child: Container( color: Colors.green, child: GridView.builder( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 10, // Change this number as per your need ), itemBuilder: (BuildContext context, int index) { int y = index ~/ GameModel.NB_COLONNES; int x = index - ((index ~/ GameModel.NB_COLONNES) * GameModel.NB_COLONNES); Color cellColor; switch (gameModel.grid[y][x]) { case GameModel.SNAKE_HEAD: cellColor = Colors.yellow; break; case GameModel.SNAKE_BODY: cellColor = Colors.green; break; case GameModel.FOOD: print(index.toString() + " " + x.toString() + " " + y.toString()); cellColor = Colors.red; break; default: cellColor = Colors.lightGreen; } return GridTile( child: Container( decoration: BoxDecoration( color: cellColor, border: Border.all(color: Colors.white), ), // TODO: Add your game cell here ), ); }, itemCount: GameModel.NB_CASES, // Change this number as per your need ), ), ), Expanded( flex: 2, child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ ElevatedButton( onPressed: () { // TODO: Implement left direction logic setState(() { resetTimer(); gameModel.changeDirection(GameModel.DIRECTION_GAUCHE); }); }, child: Icon(Icons.arrow_left), ), Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ ElevatedButton( onPressed: () { // TODO: Implement up direction logic setState(() { resetTimer(); gameModel.changeDirection(GameModel.DIRECTION_HAUT); }); }, child: Icon(Icons.arrow_upward), ), ElevatedButton( onPressed: () { // TODO: Implement down direction logic setState(() { resetTimer(); gameModel.changeDirection(GameModel.DIRECTION_BAS); }); }, child: Icon(Icons.arrow_downward), ), ], ), ElevatedButton( onPressed: () { // TODO: Implement right direction logic setState(() { resetTimer(); gameModel.changeDirection(GameModel.DIRECTION_DROITE); }); }, child: Icon(Icons.arrow_right), ), ], ), ), ], ), ); } } import 'package:flutter/material.dart'; class ClassementPage extends StatelessWidget { const ClassementPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const Center(child: Text('Page 1')); } } import 'package:flutter_snake/models/game_model.dart'; class SnakeModel { int x; int y; int size = 1; GameModel gameModel; List<List<int>> bodyPositions = []; SnakeModel({required this.gameModel, this.x = 0, this.y = 0}); void reset() { x = GameModel.NB_COLONNES ~/ 2; y = GameModel.NB_LIGNES ~/ 2; size = 2; bodyPositions = [ [x, y], [y, x - 1] ]; displaySnake(); } void displaySnake() { bodyPositions.insert(0, [x, y]); gameModel.grid[y][x] = GameModel.SNAKE_HEAD; for (int i = 1; i < bodyPositions.length; i++) { gameModel.grid[bodyPositions[i][1]][bodyPositions[i][0]] = GameModel.SNAKE_HEAD; } print("new snake head: x: $x, y: $y"); print("new snake body: x: ${bodyPositions}"); } void moveSnake(int direction) { int newX = x; int newY = y; switch (direction) { case GameModel.DIRECTION_HAUT: newY--; break; case GameModel.DIRECTION_DROITE: newX++; break; case GameModel.DIRECTION_BAS: newY++; break; case GameModel.DIRECTION_GAUCHE: newX--; break; } if (!gameModel.isInGrid(newX, newY)) { return; } gameModel.grid[y][x] = 0; x = newX; y = newY; bool ateFood = gameModel.isFood(x, y); if (ateFood) { growSnake(); gameModel.increaseScore(); gameModel.foodModel.createFood(); } else if (bodyPositions.isNotEmpty && bodyPositions.length > size) { List<int> lastBodyPart = bodyPositions.removeLast(); gameModel.grid[lastBodyPart[1]][lastBodyPart[0]] = 0; } displaySnake(); } void growSnake() { size++; } } import 'dart:math'; import 'package:flutter_snake/models/food_model.dart'; import 'package:flutter_snake/models/snake_model.dart'; class GameModel { static const int NB_CASES = 140; static const int NB_LIGNES = 14; static const int NB_COLONNES = 10; static const int DIRECTION_HAUT = 0; static const int DIRECTION_DROITE = 1; static const int DIRECTION_BAS = 2; static const int DIRECTION_GAUCHE = 3; static const int SNAKE_HEAD = 1; static const int SNAKE_BODY = 2; static const int FOOD = 3; int score = 0; int currentDirection = DIRECTION_DROITE; List<List<int>> grid = List.generate(NB_LIGNES, (i) => List.filled(NB_COLONNES, 0)); late FoodModel foodModel; late SnakeModel snakeModel; GameModel() { foodModel = FoodModel(gameModel: this); snakeModel = SnakeModel(gameModel: this); } // Add your class properties and methods here void start() { // on réinitialise la matrice for (int i = 0; i < NB_LIGNES; i++) { for (int j = 0; j < NB_COLONNES; j++) { grid[i][j] = 0; } } foodModel.createFood(); _displaySnakeBody(); } static List<int> getRandomCoordinates() { Random random = Random(); int randomX = random.nextInt(NB_COLONNES); int randomY = random.nextInt(NB_LIGNES); print("randomX: $randomX, randomY: $randomY"); return [randomX, randomY]; } void changeDirection(int newDirection) { currentDirection = newDirection; moveSnake(); } void moveSnake() { snakeModel.moveSnake(currentDirection); } bool isFood(int x, int y) { return grid[y][x] == FOOD; } bool isInGrid(int x, int y) { return x >= 0 && x < NB_COLONNES && y >= 0 && y < NB_LIGNES; } void increaseScore() { score++; } void _displaySnakeBody() { if (snakeModel.bodyPositions.isNotEmpty) { for (var position in snakeModel.bodyPositions) { int y = position[0]; int x = position[1]; grid[y][x] = GameModel.SNAKE_BODY; } var head = snakeModel.bodyPositions.first; grid[head[0]][head[1]] = GameModel.SNAKE_HEAD; } } void eatFood() {} } import 'dart:ffi'; import 'package:flutter_snake/models/game_model.dart'; class FoodModel{ GameModel gameModel; FoodModel({required this.gameModel}); void createFood(){ List<int> coordinates = GameModel.getRandomCoordinates(); gameModel.grid[coordinates[1]][coordinates[0]] = GameModel.FOOD; } }
b3ef08c5db1d044262f58cb82e53155a
{ "intermediate": 0.3887869119644165, "beginner": 0.38476040959358215, "expert": 0.22645263373851776 }
43,968
corrige moi le code suivant (le message d'erreur n'est pas en entier car il est trop long) : /* Blink Turns an LED on for one second, then off for one second, repeatedly. Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to the correct LED pin independent of which board is used. If you want to know what pin the on-board LED is connected to on your Arduino model, check the Technical Specs of your board at: https://www.arduino.cc/en/Main/Products modified 8 May 2014 by Scott Fitzgerald modified 2 Sep 2016 by Arturo Guadalupi modified 8 Sep 2016 by Colby Newman This example code is in the public domain. https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink */ // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin LED_BUILTIN as an output. pinMode(LED_BUILTIN, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second } voici ce que renvois la console : ze=0x200) [======================= ] 79% (49/62 pages)checksumBuffer(start_addr=0xa200, size=0x200) = 7d9e read(addr=0xa200,size=0x200) [======================== ] 80% (50/62 pages)checksumBuffer(start_addr=0xa400, size=0x200) = f451 read(addr=0xa400,size=0x200) [======================== ] 82% (51/62 pages)checksumBuffer(start_addr=0xa600, size=0x200) = 4503 read(addr=0xa600,size=0x200) [========================= ] 83% (52/62 pages)checksumBuffer(start_addr=0xa800, size=0x200) = c0c5 read(addr=0xa800,size=0x200) [========================= ] 85% (53/62 pages)checksumBuffer(start_addr=0xaa00, size=0x200) = d5f6 read(addr=0xaa00,size=0x200) [========================== ] 87% (54/62 pages)checksumBuffer(start_addr=0xac00, size=0x200) = 403 read(addr=0xac00,size=0x200) [========================== ] 88% (55/62 pages)checksumBuffer(start_addr=0xae00, size=0x200) = 8e3f read(addr=0xae00,size=0x200) [=========================== ] 90% (56/62 pages)checksumBuffer(start_addr=0xb000, size=0x200) = 46ab read(addr=0xb000,size=0x200) [=========================== ] 91% (57/62 pages)checksumBuffer(start_addr=0xb200, size=0x200) = da99 read(addr=0xb200,size=0x200) [============================ ] 93% (58/62 pages)checksumBuffer(start_addr=0xb400, size=0x200) = 2b69 read(addr=0xb400,size=0x200) [============================ ] 95% (59/62 pages)checksumBuffer(start_addr=0xb600, size=0x200) = 599e read(addr=0xb600,size=0x200) [============================= ] 96% (60/62 pages)checksumBuffer(start_addr=0xb800, size=0x200) = 2836 read(addr=0xb800,size=0x200) [============================= ] 98% (61/62 pages)checksumBuffer(start_addr=0xba00, size=0x18c) = 189d read(addr=0xba00,size=0x200) [==============================] 100% (62/62 pages) Verify successful Done in 0.164 seconds writeWord(addr=0xe000ed0c,value=0x5fa0004)
0593ef8eeeb492cc901f4f5737f15980
{ "intermediate": 0.25472015142440796, "beginner": 0.41947174072265625, "expert": 0.325808048248291 }
43,969
Hi there
62c947b5bd94ca71d0b0624dbf906adf
{ "intermediate": 0.32728445529937744, "beginner": 0.24503648281097412, "expert": 0.42767903208732605 }
43,970
comment avoir les librairie en .h ? #include "TFT_eSPI.h" //include TFT LCD library #include "Free_Fonts.h" //include free fonts library #include "Seeed_FS.h" //include file system library #include "RawImage.h" //include raw image library TFT_eSPI tft; //initialize TFT LCD void setup() { if (!SD.begin(SDCARD_SS_PIN, SDCARD_SPI)){ //check whether SD card is inserted and working while(1); } tft.begin(); //start TFT LCD tft.setRotation(3); //set screen rotation tft.fillScreen(TFT_WHITE); //fill background //Drawing for brightness tft.setFreeFont(&FreeSansBold12pt7b); //set font type tft.setTextColor(TFT_BLACK); //set text color tft.drawString("Brightness",90,10); //draw text string tft.drawRect(75,45,160,20,TFT_NAVY); //draw rectangle with border tft.fillRect(75,45,120,20,TFT_NAVY); //fill rectangle with color tft.fillCircle(35,55,25,TFT_RED); //fill circle with color tft.fillCircle(275,55,25,TFT_DARKGREEN); //Drawing for Volume tft.setFreeFont(&FreeSerifBoldItalic12pt7b); tft.setTextColor(TFT_BLACK); tft.drawString("Volume",110,90); tft.drawRect(75,120,160,20,TFT_NAVY); tft.fillRect(75,120,90,20,TFT_NAVY); tft.fillCircle(35,130,25,TFT_RED); tft.fillCircle(275,130,25,TFT_DARKGREEN); //Drawing Images drawImage<uint16_t>("back.bmp",0,180); //display image on LCD drawImage<uint16_t>("home.bmp",260,180); } void loop() { // put your main code here, to run repeatedly: }
aaafac408bb25c93bde8495c287131a0
{ "intermediate": 0.5504114627838135, "beginner": 0.3338117003440857, "expert": 0.1157769188284874 }
43,971
Hi ther
7899d0b29a94a9b4f86efccb0e6295bc
{ "intermediate": 0.32928466796875, "beginner": 0.2438172698020935, "expert": 0.42689812183380127 }
43,972
i'm trying to run this code: ""import asyncio # created with nbconvert, minimally cleaned up async def main(): # NOTE NOTEBOOK SETTINGS AND CONSTANTS (some script file constants are in generation_functions/constants.py) # Put your desired quant of your desired model in the relevant directories import logging import yaml import glob with open("./config.yaml", "r") as f: config = yaml.safe_load(f) # "airoboros-l2-70b-3.1.2.Q4_K_M.gguf" <- recommended for the large logical model # "flatorcamaid-13b-v0.2.Q8_0.gguf" <- recommended for the normal logical model # A6000s on Vast.ai are a good choice for running this notebook if ( not config["SYSTEM"]["COMPLETION_MODE"] and config["SYSTEM"]["MODE"] == "aphrodite" ): raise Exception("Aphrodite engine mode MUST use completion prompts!") LOGICAL_MODEL = config["API"]["LOGICAL_MODEL"] LARGE_LOGICAL_MODEL = config["API"]["LARGE_LOGICAL_MODEL"] ASSISTANT_MODE = config["SYSTEM"][ "ASSISTANT_MODE" ] # change to true if you want all conversations to be with an "AI language model" and not characters. Useful for more professional use cases. DOUBLE_CHECK_COUNTER = config["SYSTEM"][ "DOUBLE_CHECK_COUNTER" ] # Set to 1 to check outputs only once; set to 2 to check twice; set to 3 to check thrice, etc. Set to 0 to break everything in vet_question_loop() and elsewhere. Set to -1 and cause the universe to implode? USE_SUBSET = config["SYSTEM"][ "USE_SUBSET" ] # Set to True if you want to use only a small subset of the text, to test whether it plays nicely with the current setup of the notebook REARRANGEMENTS_TO_TAKE = config["SYSTEM"][ "REARRANGEMENTS_TO_TAKE" ] # How many of the possible permutations of tuples in a group to take and make multiturn convs out of. Adjust higher to get more data out of less text, but it might be a bit repetitive. NOTE your eval loss will be basically worthless if you aren't careful with how you shuffle your dataset when you're about to train. USE_FILENAMES = config["SYSTEM"][ "USE_FILENAMES" ] # Turn on if you want the model to use the names of your files as additional context (this is what original Augmentoolkit does). Useful if you have a small number of large input files grouped by subject matter, IE books. Turn off if you have a large number of files with meaningless names. CONCURRENCY_LIMIT = config["SYSTEM"][ "CONCURRENCY_LIMIT" ] # Adjust this number based on the rate limit constraints of your api API_KEY = config["API"]["API_KEY"] BASE_URL = config["API"][ "BASE_URL" ] # Augmentoolkit-API should also be compatible with any other API provider that accepts OAI-style requests COMPLETION_MODE = config["SYSTEM"]["COMPLETION_MODE"] GRAPH = config["SYSTEM"]["GRAPH"] MODE = config["SYSTEM"]["MODE"] LOG_LEVEL = logging.INFO INPUT_FOLDER = config["PATH"]["INPUT"] extension = ".txt" path = f"{INPUT_FOLDER}/*" + extension source_texts = glob.glob(path) print(source_texts) # [ # add your texts here # "./raw_txt_input/Simple Sabotage, by the Office of Strategic Services, published 1944.txt", # ] # ## Below: Defines and imports functions that you will probably use no matter what cells in the script you choose to run: print( "\n\n\nIMPORTANT NOTE! Augmentoolkit prints a lot of stuff when it runs. Including tracebacks caused by model errors. Most errors are the result of the models, not the code, and any tracebacks you see were almost certainly handled. So: don't panic! You're gonna make it! Alright that's the end of this PSA. Happy dataset generation!\n\n\n" ) import os import uuid # This is in no way best practices, but all my prompts being searchable and separate files is a good way to make my life easier. import pkgutil import importlib import sys from tqdm import asyncio as tqdmasyncio import asyncio # Set up rate-limit-conscious functions semaphore = asyncio.Semaphore(CONCURRENCY_LIMIT) async def run_task_with_limit(task): async with semaphore: # Run your task here return await task # We have to define this up here so that two-step generation works, you'll see later. multi_turn_convs_info_dir = ( config["PATH"]["OUTPUT"] + "/multi_turn_convs_info" ) # we generate all the information fed to the multiturn prompt, and generate the actual multiturn prompt, separately; since every step but the last is capable of being done by a 13b sys.path.append("./generation_functions") sys.path.append("./control_flow_functions") import augmentoolkit.generation_functions as generation_functions # This is the package directory from augmentoolkit.control_flow_functions import control_flow_functions # First, import all modules so they can be reloaded for _, module_name, _ in pkgutil.iter_modules( generation_functions.__path__, generation_functions.__name__ + "." ): importlib.import_module(module_name) # Now, reload each module and import all callable attributes for _, module_name, _ in pkgutil.iter_modules( generation_functions.__path__, generation_functions.__name__ + "." ): # Reload the module module = importlib.reload(sys.modules[module_name]) # Iterate through each attribute in the reloaded module for attribute_name in dir(module): # Retrieve the attribute attribute = getattr(module, attribute_name) if callable(attribute): # If it's callable, it's a function or class, so you set it in the globals dictionary globals()[attribute_name] = attribute engine_wrapper = EngineWrapper( model=LOGICAL_MODEL, api_key=API_KEY, base_url=BASE_URL, mode=MODE, # quantization="gptq" # modify if you want to do stuff with the aphrodite branch ) from transformers import AutoTokenizer import re from tqdm import tqdm import nltk nltk.download("punkt") from nltk.tokenize import sent_tokenize tokenizer = AutoTokenizer.from_pretrained( "Gryphe/MythoMax-L2-13b" ) # It doesn't matter what model goes here, really sentence_chunks = [] for source_text in source_texts: sentence_chunks += control_flow_functions.sentence_chunking_algorithm( source_text, tokenizer ) conversions = [("\n", " "), (" ", " ")] paragraphs_processed = [ (control_flow_functions.fix_text(conversions, seq[0]), seq[1]) for seq in sentence_chunks ] len(paragraphs_processed) paragraphs_processed[0] print(paragraphs_processed[:3]) import json import os from tqdm import tqdm import asyncio # Create directory if it doesn't exist output_dir = config["PATH"]["OUTPUT"] + "/worthy_for_questions" os.makedirs(output_dir, exist_ok=True) # Determine which paragraphs are worthy of making questions from judged_worthy_for_questions = [] await control_flow_functions.filter_all_questions( paragraphs_processed, judged_worthy_for_questions, engine_wrapper, output_dir, take_subset=USE_SUBSET, use_filenames=False, rtwl=run_task_with_limit, completion_mode=COMPLETION_MODE, logging_level=LOG_LEVEL, ) filtered_worthy_for_questions = control_flow_functions.filter_and_graph( judged_worthy_for_questions, graph=GRAPH ) print(filtered_worthy_for_questions[0]) # ### The cell below begins generating questions. SOME OF THESE MAY FAIL and have to retry due to model errors (the API branch cannot use grammars). But if you let it run you will see that the vast majority eventually get through. # # control flow import json import os import glob # Directory for QA tuples qa_tuples_dir = config["PATH"]["OUTPUT"] + "/qatuples_raw" if not os.path.exists(qa_tuples_dir): os.makedirs(qa_tuples_dir) vetted_qa_tuples = [] # tuple list of qa tuples that have been judged good # Attempt to initialize filtered_worthy_for_questions try: _ = filtered_worthy_for_questions except NameError: filtered_worthy_for_questions = [] if not filtered_worthy_for_questions: # Load all files in the qa_tuples_dir if filtered_worthy_for_questions is not initialized existing_files = glob.glob(os.path.join(qa_tuples_dir, "*.json")) for file_path in existing_files: with open(file_path, "r") as file: qa_tuple = tuple(json.load(file)) print(f"Loaded {file}") vetted_qa_tuples.append(qa_tuple) else: tasks = [ control_flow_functions.generate_qatuples_from_para( idx, para, engine_wrapper=engine_wrapper, vetted_qa_tuples=vetted_qa_tuples, qa_tuples_dir=qa_tuples_dir, double_check_counter=DOUBLE_CHECK_COUNTER, use_filenames=USE_FILENAMES, completion_mode=COMPLETION_MODE, logging_level=LOG_LEVEL, ) for idx, para in enumerate(filtered_worthy_for_questions) ] limited_tasks_qgen = [run_task_with_limit(task) for task in tasks] for future in tqdmasyncio.tqdm.as_completed(limited_tasks_qgen): await future print( "-------------- QUESTIONS CREATED ------------- STATS SO FAR (may be wrong if run was continued from interruption):" ) nones = list(filter(lambda x: x[0] is None, vetted_qa_tuples)) print(f"Nones: {len(nones)}") print(f"Non-nones: {len(vetted_qa_tuples) - len(nones)}") print(f"Total: {len(vetted_qa_tuples)}") # filter out all None values vetted_qa_tuples = [qa for qa in vetted_qa_tuples if qa[0] is not None] print("---------------- ONTO EXAMPLES GENERATION-------------------") # Check for and fix the common mistake: mentioning "the text". writepath = config["PATH"]["OUTPUT"] + "/qatuples_revised" import json # Assuming vetted_qa_tuples is a list that might or might not exist try: _ = vetted_qa_tuples except NameError: vetted_qa_tuples = [] # Load all files at the start if vetted_qa_tuples is empty if not vetted_qa_tuples: # Check if the directory exists if os.path.exists(writepath): # List all files in directory for file_name in os.listdir(writepath): file_path = os.path.join(writepath, file_name) try: # for each file already generated, see if it succeeded or failed; if it succeeded, append its contents; if it failed, append None for stats logging with open(file_path, "r", encoding="utf-8") as f: content = f.read() print(f"Loading file: {file_path}") if content == "failed": vetted_qa_tuples.append(None) else: try: data = json.loads(content) vetted_qa_tuples.append( (data[0], data[1], data[2], data[3]) ) except json.JSONDecodeError: print("JSON decode error with the contents:", content) vetted_qa_tuples.append(None) except Exception as e: print(f"Error reading {file_path}: {e}") else: old_tuples = vetted_qa_tuples.copy() tasks = [ control_flow_functions.repair_qatuple_context( idx, tup, engine_wrapper, writepath, vetted_qa_tuples, use_filenames=USE_FILENAMES, ) for idx, tup in enumerate(vetted_qa_tuples) ] limited_tasks_qcorrection = [run_task_with_limit(task) for task in tasks] for future in tqdmasyncio.tqdm.as_completed(limited_tasks_qcorrection): await future # Print stats related to revised qatuples, and filter out nones (questions that were unanswerable due to lack of context). import json import os print("-------------- QUESTIONS REVISED ------------- STATS SO FAR:") nones = list(filter(lambda x: x is None, vetted_qa_tuples)) print(f"Nones: {len(nones)}") print(f"Non-nones: {len(vetted_qa_tuples) - len(nones)}") print(f"Total: {len(vetted_qa_tuples)}") # filter out all None values vetted_qa_tuples = [qa for qa in vetted_qa_tuples if qa is not None] print("---------------- ONTO EXAMPLES GENERATION-------------------") qa_tuples_by_paragraph = control_flow_functions.group_by_text(vetted_qa_tuples) import os if not os.path.exists(multi_turn_convs_info_dir): os.makedirs(multi_turn_convs_info_dir) import json import random import itertools multi_turn_convs_info = [] tasks = [ control_flow_functions.create_info( idx, group, engine_wrapper, ASSISTANT_MODE, multi_turn_convs_info, multi_turn_convs_info_dir, rearrangements_to_take=REARRANGEMENTS_TO_TAKE, use_filenames=USE_FILENAMES, completion_mode=COMPLETION_MODE, logging_level=LOG_LEVEL, ) for idx, group in enumerate(qa_tuples_by_paragraph) ] limited_tasks_infocreation = [run_task_with_limit(task) for task in tasks] for future in tqdmasyncio.tqdm.as_completed(limited_tasks_infocreation): await future engine_wrapper = EngineWrapper( model=LARGE_LOGICAL_MODEL, api_key=API_KEY, base_url=BASE_URL, mode=MODE, # quantization="gptq" # modify if you want to do stuff with the aphrodite branch ) import os import json convs_info = control_flow_functions.read_json_files_info(multi_turn_convs_info_dir) import os import json import random import itertools import asyncio multi_turn_convs_dir = config["PATH"]["OUTPUT"] + "/multi_turn_convs" if not os.path.exists(multi_turn_convs_dir): os.makedirs(multi_turn_convs_dir) multi_turn_convs = [] tasks = [ control_flow_functions.create_conversation( idx, info, engine_wrapper, multi_turn_convs, multi_turn_convs_dir, assistant_mode=ASSISTANT_MODE, completion_mode=COMPLETION_MODE, logging_level=LOG_LEVEL, ) for idx, info in enumerate(convs_info) ] limited_tasks_convwriting = [run_task_with_limit(task) for task in tasks] for future in tqdmasyncio.tqdm.as_completed(limited_tasks_convwriting): await future # # Yay! Now you have a dataset! # ### GPT wrote the cell below. I think it successfully converts things to ShareGPT format for use with axolotl, but I am not sure because I don't know that format very well and haven't used Axolotl. However, the json produced by the second function looks fine. import os import json # Make ShareGPT-format dataset (I think, still need verification it actually works) control_flow_functions.convert_directory_to_list( config["PATH"]["OUTPUT"] + "/multi_turn_convs/" ) # Make dataset in a format that has all the information. See README for details on this format. control_flow_functions.convert_directory_and_process_conversations( config["PATH"]["OUTPUT"] + "/multi_turn_convs/" ) with open(config["PATH"]["OUTPUT"] + "/processed_master_list.json", "r") as f: first = f.read() data = json.loads(first) # For curiosity's sake, you can find out how many lines of dialogue you generated def filter_and_flatten(lst): flat_list = [] # Loop through each sublist in the main list for sublst in lst: # Check if the first element of the sublist is itself a list (subsublist1) if isinstance(sublst[0], list): # Extend the flat_list with the elements from subsublist1 flat_list.extend(sublst[0]) return flat_list len(filter_and_flatten(data)) asyncio.run(main()) "" but i get this error: "" PS C:\Users\bower\augmentoolkit> & C:/Users/bower/AppData/Local/Programs/Python/Python311/python.exe c:/Users/bower/augmentoolkit/processing.py Traceback (most recent call last): File "c:\Users\bower\augmentoolkit\processing.py", line 440, in <module> asyncio.run(main()) File "C:\Users\bower\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "C:\Users\bower\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\bower\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 654, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "c:\Users\bower\augmentoolkit\processing.py", line 16, in main config = yaml.safe_load(f) ^^^^^^^^^^^^^^^^^ File "C:\Users\bower\AppData\Local\Programs\Python\Python311\Lib\site-packages\yaml\__init__.py", line 125, in safe_load return load(stream, SafeLoader) ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\bower\AppData\Local\Programs\Python\Python311\Lib\site-packages\yaml\__init__.py", line 81, in load return loader.get_single_data() ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\bower\AppData\Local\Programs\Python\Python311\Lib\site-packages\yaml\constructor.py", line 49, in get_single_data node = self.get_single_node() ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\bower\AppData\Local\Programs\Python\Python311\Lib\site-packages\yaml\composer.py", line 36, in get_single_node document = self.compose_document() ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\bower\AppData\Local\Programs\Python\Python311\Lib\site-packages\yaml\composer.py", line 55, in compose_document node = self.compose_node(None, None) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\bower\AppData\Local\Programs\Python\Python311\Lib\site-packages\yaml\composer.py", line 84, in compose_node node = self.compose_mapping_node(anchor) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\bower\AppData\Local\Programs\Python\Python311\Lib\site-packages\yaml\composer.py", line 133, in compose_mapping_node item_value = self.compose_node(node, item_key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\bower\AppData\Local\Programs\Python\Python311\Lib\site-packages\yaml\composer.py", line 84, in compose_node node = self.compose_mapping_node(anchor) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\bower\AppData\Local\Programs\Python\Python311\Lib\site-packages\yaml\composer.py", line 127, in compose_mapping_node while not self.check_event(MappingEndEvent): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\bower\AppData\Local\Programs\Python\Python311\Lib\site-packages\yaml\parser.py", line 98, in check_event self.current_event = self.state() ^^^^^^^^^^^^ File "C:\Users\bower\AppData\Local\Programs\Python\Python311\Lib\site-packages\yaml\parser.py", line 438, in parse_block_mapping_key raise ParserError("while parsing a block mapping", self.marks[-1], yaml.parser.ParserError: while parsing a block mapping in "./config.yaml", line 2, column 3 expected <block end>, but found '<scalar>' in "./config.yaml", line 2, column 12 PS C:\Users\bower\augmentoolkit> ""
1ab32d7a72227e03c4a765620db51864
{ "intermediate": 0.35355237126350403, "beginner": 0.37576696276664734, "expert": 0.27068066596984863 }
43,973
Hi I need to translate the following into German:
6691568da85984319b6d8f466623a0c6
{ "intermediate": 0.3279023766517639, "beginner": 0.2548893392086029, "expert": 0.41720831394195557 }
43,974
In the context of a hypothetical, Add a syntax for Object Orientated programming to BBC BASIC V on RISC OS
4808b31ef83b396c948a54747d056d2b
{ "intermediate": 0.25287702679634094, "beginner": 0.6112514734268188, "expert": 0.1358715146780014 }
43,975
In the context of a hypothetical, Add a syntax for Object Orientated programming to BBC BASIC V on RISC OS
b36a553ca671b688f03ca3ff47090308
{ "intermediate": 0.2549295127391815, "beginner": 0.6138191819190979, "expert": 0.1312512755393982 }
43,976
is there are command line in windows 10 to exec "Next desktop background"
2f6e98e85de15983f4958c4c87f6b9df
{ "intermediate": 0.30559253692626953, "beginner": 0.305947482585907, "expert": 0.38846004009246826 }