Skip to content

Instantly share code, notes, and snippets.

View taniomi's full-sized avatar
🤔

Milena Tanioka taniomi

🤔
View GitHub Profile
@taniomi
taniomi / get_unique_process_names.ps1
Last active October 7, 2025 17:11
Script to get unique process names for GlazeWM configuring
# List unique running processes names
Get-Process | Select-Object ProcessName | Sort-Object ProcessName -Unique
# If execution is blocked
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
@taniomi
taniomi / query_datatypes_sqlserver.sql
Created July 28, 2025 18:15
Query datatypes of table columns in SQL Server
SELECT
COLUMN_NAME,
DATA_TYPE,
CHARACTER_MAXIMUM_LENGTH,
NUMERIC_PRECISION,
NUMERIC_SCALE,
IS_NULLABLE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'schema'
AND TABLE_NAME = 'name';
@taniomi
taniomi / bump_version.py
Created May 22, 2025 21:37
Bump version from project in `pyproject.toml`, commit the bump and `git tag` it
import sys
import re
from pathlib import Path
import subprocess
def bump_version(file_path, version):
"""Replace the version string in the given file."""
content = Path(file_path).read_text(encoding="utf-8")
new_content = re.sub(r'version\s*=\s*"[v]?[0-9]+\.[0-9]+\.[0-9]+"', f'version = "{version}"', content)
Path(file_path).write_text(new_content, encoding="utf-8")
@taniomi
taniomi / databricks-error-received-command-c-on-object-id-p0.md
Created May 19, 2025 15:52
Databricks Error: Received command c on object id p0

Problem

You see the error message INFO:py4j.java_gateway:Received command c on object id p0 after running Python code with imported libraries.

INFO:py4j.java_gateway:Received command c on object id p0
INFO:py4j.java_gateway:Received command c on object id p0
INFO:py4j.java_gateway:Received command c on object id p0
INFO:py4j.java_gateway:Received command c on object id p0
@taniomi
taniomi / invoice_id.sql
Created April 10, 2025 19:49
Id creation and formatting with computed column in SQLServer
-- Add auto-incrementing primary key column starting from 1 and incrementing 1
ALTER TABLE dbo.invoice
ADD Id INT IDENTITY(1,1) PRIMARY KEY;
-- Add computed column with formatted InvoiceId (e.g., F-00000042)
ALTER TABLE dbo.invoice
ADD InvoiceId AS (
'F-' + RIGHT('00000000' + CAST(Id AS VARCHAR(8)), 8)
) PERSISTED;
@taniomi
taniomi / microsoft-entra-id-login-sql-server.sql
Last active July 28, 2025 18:12
Create a Microsoft Entra ID role in SQL Server for logging with MFA in SQL Server
DECLARE @role SYSNAME = 'role';
-- 1. Create database role
EXEC('CREATE ROLE [' + @role + ']');
-- 2. Create user from Microsoft Entra ID group and add to the role
EXEC('CREATE USER [dw-group-' + @role + '] FROM EXTERNAL PROVIDER;');
EXEC('ALTER ROLE [' + @role + '] ADD MEMBER [dw-group-' + @role + '];');
-- 3. Grant permissions dynamically
@taniomi
taniomi / grant_select_on_all_schemas_except.sql
Created March 11, 2025 13:26
Grants select on all schemas except for specified ones
DECLARE @sql NVARCHAR(MAX) = '';
SELECT @sql +=
'GRANT SELECT ON SCHEMA::' + QUOTENAME(name) + ' TO [role];' + CHAR(13)
FROM sys.schemas
WHERE name NOT IN ('dbo', 'dev')
AND name NOT LIKE 'db_%'; -- Exclude schemas starting with "db_"
PRINT @sql; -- Check generated SQL before executing
EXEC sp_executesql @sql;
@taniomi
taniomi / list_cols.py
Last active March 11, 2025 13:27
Identify columns in a pandas dataframe where at least one value is a list
import pandas as pd
# Identify columns where at least one value is a list
list_columns = [col for col in df.columns if df[col].apply(lambda x: isinstance(x, list)).any()]
print("Columns containing lists:", list_columns)
@taniomi
taniomi / df_replace.py
Created March 10, 2025 14:55
Easily replace values in the entire pandas dataframe
df.replace(to_replace='nan', value=None, inplace=True)
df.replace(to_replace='[]', value=None, inplace=True)
df.replace(to_replace='', value=None, inplace=True)
@taniomi
taniomi / transform_template.py
Last active March 14, 2025 14:35
Transform: define data type template
bit_cols = [
'active',
'anonymousResponse',
'deleted',
'isAdditionalQuestion'
]
datetime2_cols = [
'date',
'answerDate'
]