Skip to content

Instantly share code, notes, and snippets.

-- handle string float, numeric, integer
SAFE_CAST(
REGEXP_REPLACE(col, r"[^0-9eE+\\-\\.]", "")
AS FLOAT64)
-- handle string boolean
CASE
WHEN col IS NULL THEN NULL
WHEN LOWER(TRIM(col)) IN ("true", "1", "yes", "y", "t") THEN TRUE
WHEN LOWER(TRIM(col)) IN ("false", "0", "no", "n", "f") THEN FALSE
def get_table_info(project_id, dataset_id, table_id, sample_size=5):
table_ref = f"{project_id}.{dataset_id}.{table_id}"
# Get schema
table = client.get_table(table_ref)
schema = table.schema
# Get sample data
query = f"""
SELECT *
import difflib
def fuzzy_insert(words, new_word, threshold=0.6):
# 1️⃣ Calculate similarity scores
similarities = [
(i, difflib.SequenceMatcher(None, new_word, w).ratio())
for i, w in enumerate(words)
]
# 2️⃣ Find best match
import torch
import torchaudio
import numpy as np
import soundfile as sf
from speechbrain.pretrained import SpeakerRecognition
from scipy.spatial.distance import cosine
# ============================
# CONFIG
import sounddevice as sd
import soundfile as sf
import numpy as np
import queue
import datetime
import os
# ==============================
# CONFIG
# ==============================
import webrtcvad
import collections
import sys
import wave
import contextlib
from pydub import AudioSegment
def read_wave(path):
with contextlib.closing(wave.open(path, 'rb')) as wf:
import collections
import sys
import wave
import time
import webrtcvad
import pyaudio
# Audio settings
FORMAT = pyaudio.paInt16
CHANNELS = 1
# Most compatible way – use .loc / .iat if DataFrame, indexing if ndarray
loudness = float(features['loudness_sma3_amean'].item()
if hasattr(features, '__getitem__') and 'loudness_sma3_amean' in features
else features[smile.feature_names.index('loudness_sma3_amean')])
voicing_key = 'voicingProb_sma3nz_amean'
voicing = 0.0
if voicing_key in smile.feature_names:
idx = smile.feature_names.index(voicing_key)
voicing = float(features[voicing_key].item()
import pyaudio
import numpy as np
import opensmile
import time
import datetime
import collections
import soundfile as sf # pip install soundfile
# ================= Configuration =================
SAMPLE_RATE = 16000
@ducnh1022
ducnh1022 / game_hanzi.html
Created February 8, 2026 04:12
game hanzi
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>VerbVibe - Trilingual Master</title>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap" rel="stylesheet">
<style>
:root {
--primary-blue: #A2D2FF;