{"n": 1, "prompt": "Reverse a string in Python.", "answer": "```python\ndef reverse_string(s):\n return s[::-1]\n\nprint(reverse_string(\"Hello World\"))\n```\n\nIn this code, the function `reverse_string` takes a string as input and returns its reverse.", "words": 23, "prose_words": 15, "code_first": true, "tok_s": 3.6} {"n": 2, "prompt": "Flatten a nested list in Python.", "answer": "```python\ndef flatten(nested_list):\n flat_list = []\n for item in nested_list:\n if isinstance(item, list):\n flat_list.extend(flatten(item))\n else:\n flat_list.append(item)\n return flat_list\n\nnested_list = [1, 2, [3, 4], 5]\nprint(flatten(nested_list)) # Output: [1, 2, 3, 4, 5]\n```\n\nIn this code, we define a function `flatten` that takes a nested list as input.", "words": 49, "prose_words": 15, "code_first": true, "tok_s": 112.4} {"n": 3, "prompt": "Read a CSV file into a list of dictionaries in Python.", "answer": "```python\nimport csv\n\ndef read_csv_to_dicts(file_path):\n with open(file_path, 'r') as f:\n reader = csv.DictReader(f)\n return list(reader)\n\n# usage\ncsv_file_path = 'yourfile.csv'\ndict_list = read_csv_to_dicts(csv_file_path)\n```\n\nIn this code, `csv.DictReader` is used to read the CSV file and convert each row into a dictionary.", "words": 42, "prose_words": 18, "code_first": true, "tok_s": 111.6} {"n": 4, "prompt": "Check if a number is prime in Python.", "answer": "```python\ndef check_prime(n):\n if n <= 1:\n return False\n elif n == 2:\n return True\n elif n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\n# Test the function\nprint(check_prime(11)) # Output: True\nprint(check_prime(4)) # Output: False\n```\n\nIn this code, we first handle some special cases.", "words": 67, "prose_words": 9, "code_first": true, "tok_s": 114.1} {"n": 5, "prompt": "Merge two sorted lists in Python.", "answer": "```python\ndef merge_sorted_lists(list1, list2):\n merged_list = []\n i = j = 0\n\n while i < len(list1) and j < len(list2):\n if list1[i] < list2[j]:\n merged_list.append(list1[i])\n i += 1\n else:\n merged_list.append(list2[j])\n j += 1\n\n # If there are remaining elements in either list, add them to the merged list\n while i < len(list1):\n merged_list.append(list1[i])\n i += 1\n\n while j < len(list2):\n merged_list.append(list2[j])\n j += 1\n\n return merged_list\n\n# Test the function\nlist1 = [1, 3, 5, 7]\nlist2 = [2, 4, 6, 8]\nprint(merge_sorted_lists(list1, list2)) # Output: [1, 2, 3, 4, 5, 6, 7, 8]\n```\n\nIn this code, we initialize two pointers `i` and `j` to the start of both lists.", "words": 111, "prose_words": 16, "code_first": true, "tok_s": 114.0} {"n": 6, "prompt": "Count word frequency in a string in Python.", "answer": "```python\ndef count_word_frequency(string):\n # Convert the string to lowercase and split it into words\n words = string.lower().split()\n\n # Create an empty dictionary to store the word frequencies\n freq_dict = {}\n\n # Iterate over each word in the list of words\n for word in words:\n # If the word is already in the dictionary, increment its count\n if word in freq_dict:\n freq_dict[word] += 1\n # Otherwise, add the word to the dictionary with a count of 1\n else:\n freq_dict[word] = 1\n\n return freq_dict\n\n# Test the function\nstring = \"Hello world! Hello everyone. This is a test string.\"\nprint(count_word_frequency(string))\n```\n\nThis will output:", "words": 102, "prose_words": 3, "code_first": true, "tok_s": 112.9} {"n": 7, "prompt": "Remove duplicates from a list while keeping the order in Python.", "answer": "```python\ndef remove_duplicates(lst):\n seen = set()\n result = []\n for item in lst:\n if item not in seen:\n seen.add(item)\n result.append(item)\n return result\n\n# Test the function\nprint(remove_duplicates([1, 2, 3, 4, 5, 1, 2, 3, 6]))\n```\n\nThis will output: `[1, 2, 3, 4, 5, 6]`", "words": 45, "prose_words": 9, "code_first": true, "tok_s": 113.1} {"n": 8, "prompt": "Write a Python decorator that times a function.", "answer": "```python\nimport time\n\ndef timer(func):\n def wrapper(*args, **kwargs):\n start_time = time.time()\n result = func(*args, **kwargs)\n end_time = time.time()\n print(f'{func.__name__} took {end_time - start_time:.4f} seconds to execute')\n return result\n return wrapper\n\n@timer\ndef example_function(n):\n sum = 0\n for i in range(1, n+1):\n sum += i\n return sum\n\nexample_function(100000)\n```\n\nIn this code, the `timer` decorator takes a function as an argument and returns a new function.", "words": 65, "prose_words": 17, "code_first": true, "tok_s": 112.2} {"n": 9, "prompt": "Read JSON from a file in Python.", "answer": "```python\nimport json\n\n# Open the JSON file\nwith open('filename.json', 'r') as f:\n # Load the JSON data into a Python dictionary\n data = json.load(f)\n\n# Now you can access the data like this:\nprint(data['key'])\n```\n\nIn this example, `'filename.json'` is the name of your JSON file.", "words": 47, "prose_words": 11, "code_first": true, "tok_s": 112.2} {"n": 10, "prompt": "Sort a list of dictionaries by a key in Python.", "answer": "```python\n# Sample list of dictionaries\nlist_of_dicts = [{'name': 'John', 'age': 25}, {'name': 'Jane', 'age': 30}, {'name': 'Jack', 'age': 20}]\n\n# Sort the list by age key in ascending order\nsorted_list = sorted(list_of_dicts, key=lambda x: x['age'])\n\nprint(sorted_list)\n```\n\nThis will output:", "words": 41, "prose_words": 3, "code_first": true, "tok_s": 113.6} {"n": 11, "prompt": "Write a Fibonacci generator in Python.", "answer": "```python\ndef fibonacci():\n a, b = 0, 1\n while True:\n yield a\n a, b = b, a + b\n\n# Usage example:\nfib_gen = fibonacci()\nfor _ in range(10):\n print(next(fib_gen))\n```\n\nIn this code, `fibonacci` is a generator function that yields Fibonacci numbers.", "words": 43, "prose_words": 12, "code_first": true, "tok_s": 113.2} {"n": 12, "prompt": "Check if a string is a palindrome in Python.", "answer": "```python\ndef is_palindrome(s):\n # Remove spaces and convert to lowercase for case-insensitive comparison\n s = s.replace(\" \", \"\").lower()\n \n # Compare the string with its reverse\n return s == s[::-1]\n\n# Test the function\nprint(is_palindrome(\"A man a plan a canal Panama\")) # True\nprint(is_palindrome(\"Hello, World!\")) # False\n```\n\nIn this code, we first remove all spaces from the input string and convert it to lowercase.", "words": 64, "prose_words": 17, "code_first": true, "tok_s": 111.7} {"n": 13, "prompt": "Write a debounce function in TypeScript.", "answer": "```typescript\nfunction debounce(func: (...args: any[]) => void, wait: number) {\n let timeout: ReturnType | null = null;\n\n return function(...args: any[]) {\n const later = () => {\n clearTimeout(timeout);\n func(...args);\n };\n\n clearTimeout(timeout);\n timeout = setTimeout(later, wait);\n };\n}\n```\n\nYou can use this debounce function like so:", "words": 47, "prose_words": 8, "code_first": true, "tok_s": 111.5} {"n": 14, "prompt": "Write a throttle function in JavaScript.", "answer": "```javascript\nfunction throttle(func, wait) {\n let timeout;\n return function(...args) {\n const context = this;\n clearTimeout(timeout);\n timeout = setTimeout(() => func.apply(context, args), wait);\n };\n}\n```\n\nYou can use it like this:", "words": 31, "prose_words": 6, "code_first": true, "tok_s": 111.9} {"n": 15, "prompt": "Deep clone an object in JavaScript.", "answer": "```javascript\nfunction deepClone(obj) {\n return JSON.parse(JSON.stringify(obj));\n}\n```\n\nThis function works by first converting the input object to a JSON string, and then parsing that string back into a new object.", "words": 31, "prose_words": 23, "code_first": true, "tok_s": 113.2} {"n": 16, "prompt": "Fetch JSON from a URL with error handling in JavaScript.", "answer": "```javascript\nfetch('https://example.com/api/data')\n .then(response => {\n if (!response.ok) {\n throw new Error(`HTTP error, status = ${response.status}`);\n }\n return response.json();\n })\n .then(data => console.log(data))\n .catch(error => console.error('There has been a problem with your fetch operation:', error));\n```\n\nIn this code:", "words": 38, "prose_words": 3, "code_first": true, "tok_s": 109.4} {"n": 17, "prompt": "Group an array of objects by a key in TypeScript.", "answer": "```typescript\ninterface Person {\n name: string;\n age: number;\n}\n\nconst people: Person[] = [\n { name: 'John', age: 25 },\n { name: 'Jane', age: 30 },\n { name: 'Jack', age: 28 }\n];\n\n// Group by age\nconst groupedByAge = people.reduce((acc, person) => {\n if (!acc[person.age]) {\n acc[person.age] = [];\n }\n acc[person.age].push(person);\n return acc;\n}, {} as { [key: number]: Person[] });\n\nconsole.log(groupedByAge); // Output: {25: [{name: 'John', age: 25}], 30: [{name: 'Jane', age: 30}]}\n```\n\nIn this example, we have an array of `Person` objects.", "words": 86, "prose_words": 10, "code_first": true, "tok_s": 111.9} {"n": 18, "prompt": "Write a sleep function using promises in JavaScript.", "answer": "```javascript\nfunction sleep(ms) {\n return new Promise(resolve => setTimeout(resolve, ms));\n}\n```\n\nYou can use this function to pause your code execution for a specified amount of time.", "words": 28, "prose_words": 16, "code_first": true, "tok_s": 112.9} {"n": 19, "prompt": "Remove duplicates from an array in JavaScript.", "answer": "```javascript\nlet arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3];\nlet uniqueArr = Array.from(new Set(arr));\nconsole.log(uniqueArr);\n```\n\nIn this code, we first create an array `arr` with some duplicate values.", "words": 37, "prose_words": 13, "code_first": true, "tok_s": 112.3} {"n": 20, "prompt": "Format a date as YYYY-MM-DD in JavaScript.", "answer": "```javascript\nlet date = new Date();\nlet year = date.getFullYear();\nlet month = String(date.getMonth() + 1).padStart(2, '0');\nlet day = String(date.getDate()).padStart(2, '0');\n\nconsole.log(`${year}-${month}-${day}`);\n```\n\nThis code will print the current date in the format YYYY-MM-DD.", "words": 35, "prose_words": 11, "code_first": true, "tok_s": 112.1} {"n": 21, "prompt": "Check if an object is empty in JavaScript.", "answer": "```javascript\nfunction isEmpty(obj) {\n return Object.keys(obj).length === 0;\n}\n\n// Example usage:\nlet obj1 = {};\nlet obj2 = { key: 'value' };\n\nconsole.log(isEmpty(obj1)); // true\nconsole.log(isEmpty(obj2)); // false\n```\n\nIn this function, `Object.keys(obj)` returns an array of all the keys in the object.", "words": 44, "prose_words": 14, "code_first": true, "tok_s": 111.2} {"n": 22, "prompt": "Capitalize the first letter of each word in JavaScript.", "answer": "```javascript\nfunction capitalizeFirstLetterOfEachWord(str) {\n return str.replace(/\\w\\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});\n}\n\nconsole.log(capitalizeFirstLetterOfEachWord(\"hello world\")); // Outputs: \"Hello World\"\n```\n\nIn this code, `replace` method is used with a regular expression to find each word in the string.", "words": 36, "prose_words": 18, "code_first": true, "tok_s": 111.0} {"n": 23, "prompt": "SQL query for the ten customers with the highest total spend.", "answer": "```sql\nSELECT customer_id, SUM(total_spend) as total_spent\nFROM orders\nGROUP BY customer_id\nORDER BY total_spent DESC\nLIMIT 10;\n```\n\nThis SQL query will return the top 10 customers based on their total spend.", "words": 32, "prose_words": 14, "code_first": true, "tok_s": 112.5} {"n": 24, "prompt": "SQL to delete duplicate rows and keep the lowest id.", "answer": "```sql\nWITH RankedRows AS (\n SELECT *,\n ROW_NUMBER() OVER (PARTITION BY column1, column2 ORDER BY id) as rn\n FROM your_table\n)\nDELETE FROM RankedRows\nWHERE rn > 1;\n```\n\nIn this query: - `column1`, `column2` are the columns you want to check for duplicates.", "words": 44, "prose_words": 15, "code_first": true, "tok_s": 111.0} {"n": 25, "prompt": "SQL query to count orders per month.", "answer": "```sql\nSELECT \n MONTH(order_date) AS Month, \n COUNT(*) AS OrdersCount\nFROM \n orders\nGROUP BY \n YEAR(order_date), MONTH(order_date)\nORDER BY \n Year, Month;\n```\n\nThis SQL statement will return the number of orders for each month.", "words": 31, "prose_words": 12, "code_first": true, "tok_s": 111.7} {"n": 26, "prompt": "SQL query to find the second highest salary.", "answer": "```sql\nSELECT Salary \nFROM Employees \nWHERE Salary < (SELECT MAX(Salary) FROM Employees)\nORDER BY Salary DESC\nLIMIT 1;\n```\n\nThis SQL statement works by first finding the maximum salary in the Employees table, and then selecting all salaries that are less than this maximum.", "words": 44, "prose_words": 25, "code_first": true, "tok_s": 109.8} {"n": 27, "prompt": "Bash one liner to rename all .txt files to .md.", "answer": "```bash\nfor file in *.txt; do mv \"$file\" \"${file%.txt}.md\"; done\n```\n\nThis script will iterate over all `.txt` files in the current directory and rename them by removing `.txt` extension and adding `.md`.", "words": 33, "prose_words": 22, "code_first": true, "tok_s": 109.1} {"n": 28, "prompt": "Find files larger than 100 MB with a shell command.", "answer": "```bash\nfind . -type f -size +100M\n```\n\nThis command will search the current directory and all subdirectories for files larger than 100MB.", "words": 23, "prose_words": 15, "code_first": true, "tok_s": 113.1} {"n": 29, "prompt": "Git command to undo the last commit but keep the changes.", "answer": "```bash\ngit checkout HEAD~1 -- .\n```\n\nThis command will revert the last commit, but it will not remove any uncommitted changes.", "words": 22, "prose_words": 15, "code_first": true, "tok_s": 113.2} {"n": 30, "prompt": "Git command to delete all merged local branches.", "answer": "```bash\ngit branch --merged | xargs git branch -d\n```\n\nThis will list all the branches that have been merged into your current branch and then delete them.", "words": 28, "prose_words": 18, "code_first": true, "tok_s": 113.4} {"n": 31, "prompt": "Count the lines in all .js files with a shell command.", "answer": "```bash\nfind . -name \"*.js\" | xargs wc -l\n```\n\nThis command will find all `.js` files in the current directory and its subdirectories, and then count the number of lines in each file.", "words": 34, "prose_words": 24, "code_first": true, "tok_s": 111.1} {"n": 32, "prompt": "Tail a log file and show only lines containing ERROR.", "answer": "```bash\ntail -f /path/to/logfile | grep \"ERROR\"\n```\n\nThis command will follow the log file (`/path/to/logfile`) and print any line that contains the word \"ERROR\".", "words": 25, "prose_words": 17, "code_first": true, "tok_s": 111.6} {"n": 33, "prompt": "Read a file line by line in Go.", "answer": "```go\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tfile, err := os.Open(\"filename.txt\")\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tdefer file.Close()\n\n\tscanner := bufio.NewScanner(file)\n\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tfmt.Println(line)\n\t}\n\n\tif err := scanner.Err(); err != nil {\n\t\tfmt.Println(err)\n\t}\n}\n```\n\nIn this code, we first open the file and check if there was an error.", "words": 64, "prose_words": 15, "code_first": true, "tok_s": 110.8} {"n": 34, "prompt": "Write a minimal HTTP server in Go that returns hello.", "answer": "```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n)\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"Hello\")\n}\n\nfunc main() {\n\thttp.HandleFunc(\"/\", handler)\n\tfmt.Println(\"Server is running on port 8080...\")\n\tif err := http.ListenAndServe(\":8080\", nil); err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\nThis program creates a simple HTTP server that listens for requests on the root path (\"/\").", "words": 57, "prose_words": 16, "code_first": true, "tok_s": 111.0} {"n": 35, "prompt": "Rust struct with serde Serialize and Deserialize.", "answer": "```rust\nuse serde::{Serialize, Deserialize};\n\n#[derive(Serialize, Deserialize)]\nstruct MyStruct {\n field1: String,\n field2: i32,\n}\n```\n\nIn this example, `MyStruct` is a struct that contains two fields: `field1` of type `String` and `field2` of type `i32`.", "words": 35, "prose_words": 20, "code_first": true, "tok_s": 112.4} {"n": 36, "prompt": "Read a file into a String in Rust.", "answer": "```rust\nuse std::fs;\n\nfn main() {\n let filename = \"example.txt\";\n\n match fs::read_to_string(filename) {\n Ok(content) => println!(\"File content: {}\", content),\n Err(error) => eprintln!(\"Error reading file: {:?}\", error),\n }\n}\n```\n\nIn this code, `fs::read_to_string` is used to read the entire contents of a file into a String.", "words": 46, "prose_words": 17, "code_first": true, "tok_s": 111.6} {"n": 37, "prompt": "Binary search in Java.", "answer": "```java\npublic class BinarySearch {\n public static int binarySearch(int[] array, int target) {\n int left = 0;\n int right = array.length - 1;\n\n while (left <= right) {\n int mid = left + (right - left) / 2; // Prevents overflow\n\n if (array[mid] == target) {\n return mid; // Target found\n } else if (array[mid] < target) {\n left = mid + 1;\n } else {\n right = mid - 1;\n }\n }\n\n return -1; // Target not found\n }\n\n public static void main(String[] args) {\n int[] array = {2, 3, 4, 10, 40};\n int target = 10;\n\n int result = binarySearch(array, target);\n\n if (result == -1) {\n System.out.println(\"Element not present in the array\");\n } else {\n System.out.println(\"Element found at index \" + result);\n }\n }\n}\n```\n\nIn this code, `binarySearch` method takes an array and a target value as input.", "words": 142, "prose_words": 14, "code_first": true, "tok_s": 111.7} {"n": 38, "prompt": "Singleton class in Java.", "answer": "```java\npublic class Singleton {\n // 1. Private static variable of the same type\n private static Singleton instance;\n\n // 2. Private constructor to prevent instantiation from outside\n private Singleton() {}\n\n // 3. Public method to get the single instance\n public static Singleton getInstance() {\n if (instance == null) {\n instance = new Singleton();\n }\n return instance;\n }\n\n // Other methods can be added here\n}\n```\n\nThis class ensures that only one instance of `Singleton` is created, and provides a global point of access to it.", "words": 86, "prose_words": 20, "code_first": true, "tok_s": 109.9} {"n": 39, "prompt": "Convert a list of strings to uppercase with LINQ in C#.", "answer": "```csharp\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nclass Program\n{\n static void Main()\n {\n List listOfStrings = new List() { \"hello\", \"world\", \"LINQ\" };\n\n var upperCaseList = listOfStrings.Select(s => s.ToUpper());\n\n foreach (var str in upperCaseList)\n {\n Console.WriteLine(str);\n }\n }\n}\n```\n\nIn this code, we first create a list of strings.", "words": 51, "prose_words": 10, "code_first": true, "tok_s": 109.9} {"n": 40, "prompt": "Reverse a linked list in C.", "answer": "```c\n#include \n#include\n\n// Node structure\nstruct Node {\n int data;\n struct Node* next;\n};\n\n// Function to create a new node\nstruct Node* newNode(int data) {\n struct Node* temp = (struct Node*)malloc(sizeof(struct Node));\n temp->data = data;\n temp->next = NULL;\n return temp;\n}\n\n// Function to reverse the linked list\nvoid reverseList(struct Node** head_ref) {\n struct Node* prev = NULL;\n struct Node* current = *head_ref;\n struct Node* next;\n\n while (current != NULL) {\n next = current->next; // Store next node\n current->next = prev; // Reverse current node's pointer\n prev = current; // Move pointers one position ahead\n current = next;\n }\n\n *head_ref = prev; // Update head reference\n}\n\n// Function to print the linked list\nvoid printList(struct Node* node) {\n while (node != NULL) {\n printf(\"%d \", node->data);\n node = node->next;\n }\n}\n\nint main() {\n struct Node* head = newNode(1);\n head->next = newNode(2);\n head->next->next = newNode(3);\n\n printf(\"Original list: \");\n printList(head);\n\n reverseList(&head);\n\n printf(\"\\nReversed list: \");\n printList(head);\n\n return 0;\n}\n```\n\nIn this program, we first create a linked list with three nodes.", "words": 174, "prose_words": 12, "code_first": true, "tok_s": 111.0} {"n": 41, "prompt": "Regex that matches an email address.", "answer": "```python\nimport re\n\ndef validate_email(email):\n pattern = r\"[^@]+@[^@]+\\.[^@]+\"\n if re.search(pattern, email):\n return True\n else:\n return False\n```\n\nThis function takes an email as input and checks whether it matches the pattern for a valid email address.", "words": 36, "prose_words": 19, "code_first": true, "tok_s": 111.4} {"n": 42, "prompt": "Explain what this does: for i in range(0, len(a), 2): print(a[i])", "answer": "```python\nfor i in range(0, len(a), 2):\n print(a[i])\n```\n\nThis code iterates over the elements of list `a` starting from index 0 and incrementing by 2 each time.", "words": 28, "prose_words": 19, "code_first": true, "tok_s": 112.8} {"n": 43, "prompt": "Fix: for i in range(10) print(i)", "answer": "```python\nfor i in range(10):\n print(i)\n```\n\nThis code will print numbers from 0 to 9.", "words": 16, "prose_words": 9, "code_first": true, "tok_s": 112.8} {"n": 44, "prompt": "Dockerfile for a Node.js app.", "answer": "```dockerfile\n# Use an official Node.js runtime as the base image\nFROM node:14\n\n# Set the working directory in the container\nWORKDIR /app\n\n# Copy package*.json files to the working directory\nCOPY package*.json ./\n\n# Install any needed packages specified in package.json\nRUN npm install\n\n# If your app has a `index.js`, copy it to the working directory\nCOPY index.js .\n\n# Make port 3000 available to the world outside this container\nEXPOSE 3000\n\n# Run app.js when the container launches\nCMD [\"node\", \"index.js\"]\n```\n\nThis Dockerfile will build a Node.js application and run it in a Docker container.", "words": 99, "prose_words": 14, "code_first": true, "tok_s": 110.9} {"n": 45, "prompt": "Write a pytest unit test for a function add(a, b).", "answer": "```python\nimport pytest\n\ndef add(a, b):\n return a + b\n\n@pytest.mark.parametrize(\"a, b, expected\", [\n (1, 2, 3),\n (-1, -2, -3),\n (0, 5, 5),\n (10, -5, 5)\n])\ndef test_add(a, b, expected):\n assert add(a, b) == expected\n```\n\nIn this example, we have a function `add` that takes two arguments and returns their sum.", "words": 53, "prose_words": 16, "code_first": true, "tok_s": 112.1} {"n": 46, "prompt": "Make an async HTTP GET request in Python with aiohttp.", "answer": "```python\nimport aiohttp\n\nasync def fetch(session, url):\n async with session.get(url) as response:\n return await response.text()\n\nasync def main():\n async with aiohttp.ClientSession() as session:\n html = await fetch(session, 'http://python.org')\n print(html)\n\n# Run the asyncio event loop\nimport asyncio\nloop = asyncio.get_event_loop()\nloop.run_until_complete(main())\n```\n\nIn this example, we first import the necessary modules: `aiohttp` for making HTTP requests and `asyncio` for running asynchronous code.", "words": 62, "prose_words": 20, "code_first": true, "tok_s": 110.4} {"n": 47, "prompt": "Convert a callback based function to a promise in JavaScript.", "answer": "```javascript\nfunction fetchData(url) {\n return new Promise((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n xhr.open('GET', url);\n xhr.onload = () => {\n if (xhr.status === 200) {\n resolve(JSON.parse(xhr.responseText));\n } else {\n reject(new Error('Request failed'));\n }\n };\n xhr.onerror = () => reject(new Error('Network error'));\n xhr.send();\n });\n}\n```\n\nIn this example, `fetchData` is a function that returns a promise.", "words": 58, "prose_words": 11, "code_first": true, "tok_s": 111.0} {"n": 48, "prompt": "TypeScript interface for a user with id, name and optional email.", "answer": "```typescript\ninterface User {\n id: number;\n name: string;\n email?: string; // Optional property\n}\n```\n\nIn this example, `id` is required and of type `number`, `name` is also required and of type `string`.", "words": 33, "prose_words": 18, "code_first": true, "tok_s": 111.6} {"n": 49, "prompt": "CSS to center a div horizontally and vertically.", "answer": "```css\n.parent {\n display: flex;\n justify-content: center; /* Center horizontally */\n align-items: center; /* Center vertically */\n}\n```\n\nIn this example, the parent container is set to `display: flex`.", "words": 30, "prose_words": 11, "code_first": true, "tok_s": 112.6} {"n": 50, "prompt": "HTML form with an email field and a submit button.", "answer": "```html\n\n\n\n Email Form\n\n\n
\n
\n
\n \n
\n\n\n```\n\nIn this form, the `action` attribute specifies where to send the form data when the user submits it.", "words": 44, "prose_words": 18, "code_first": true, "tok_s": 110.5}