CREATE OR REPLACE TEMP TABLE AVERAGE_RATINGS_BY_YEAR_GENRE AS | |
WITH T1 AS ( -- T1 -> Common Table Expression (CTE) | |
SELECT r.rating, r.year, unnest(f.genres) AS genre | |
FROM Films f JOIN Ratings r ON (r.film_id = f.film_id) | |
) | |
SELECT year, genre, avg(rating) AS average_rating | |
FROM T1 | |
GROUP BY year, genre | |
ORDER BY year DESC, genre |
from mistralai import Mistral | |
client = Mistral(api_key=MISTRAL_API_KEY) | |
model_instructions = "..." | |
# for chunk in ... | |
def with_synchronous_streaming(user_prompt: str): | |
messages = [ | |
{ |
We all remember from our fundamental mathematics classes the emphasis on the irrationality of
Well, it turns out that we can extend this theorem more broadly to the square roots of prime numbers with the same kind of demonstration, and that's what we're going to demonstrate here in this article. But first, let's have some reminders about what prime numbers are.
Let
// @lib/utils.ts | |
import { twMerge } from 'tailwind-merge' | |
import { clsx, ClassValue } from 'clsx' | |
export function cn(...inputs: ClassValue[]) { | |
return twMerge(clsx(inputs)) | |
} |
const sleep = async (ms) => { | |
await new Promise(resolve => { | |
setTimeout(() => resolve(0), ms) | |
}) | |
} | |
await sleep(2000) |
const findSmallestInterval = (numbers) => { | |
numbers.sort((a, b) => a - b) | |
let r = Number.MAX_SAFE_INTEGER | |
numbers.forEach((e, i) => { | |
if (i + 1 > numbers.length) | |
return | |
const d = Math.abs(e - numbers[i + 1]) |
const arrayCalculation = (specialArray, depth = 1) => { | |
const r = [] | |
specialArray.forEach((e) => { | |
if (Number.isInteger(e)) | |
r.push(e) | |
if (Array.isArray(e)) | |
r.push(arrayCalculation(e, depth + 1)) | |
}) | |
return depth * r.reduce((acc, cv) => acc + cv, 0) |
const flattenDepth = (arr, depth = 1) => | |
arr.reduce( | |
(acc, cv) => [ | |
...acc, | |
...(depth === 0 || !Array.isArray(cv) | |
? [cv] | |
: flattenDepth(cv, depth - 1)) | |
], | |
[] | |
); |
const zip = (...rows) => | |
rows[0].map((_, i) => rows.map((row) => row[i])) | |
const zip2 = (arr, ...arrs) => | |
arr.map((val, i) => arrs.reduce((acc, cv) => [...acc, cv[i]], [val])) | |
const zip3 = (...arrs) => { | |
let r = [] | |
for (let i = 0; i < arrs.length; i++) { |