Skip to content

Instantly share code, notes, and snippets.

View dmbdesignpdx's full-sized avatar
⚰️

Daniel Blake dmbdesignpdx

⚰️
View GitHub Profile
@dmbdesignpdx
dmbdesignpdx / 2024.css
Created February 17, 2025 18:24
Notes on the latest features in CSS for 2024
/*
* Scroll-based animations
*/
@supports (animation-timeline: view()) { ... }
@media (prefers-reduced-motion: no-preference) { ... }
@keyframes appear {
from {
opacity: 0;
@dmbdesignpdx
dmbdesignpdx / update_sequence.sql
Last active January 11, 2025 02:17
PostgreSQL -- Update the sequence value of a serial id
-- Example with a table called "roles"
-- Get the sequence name
select pg_get_serial_sequence('roles', 'role_id');
-- Result: roles_role_id_seq
-- Set the new value
select setval('roles_role_id_seq', <NEW_VALUE>, true);
@dmbdesignpdx
dmbdesignpdx / morph_columns.py
Created January 11, 2025 02:01
Pandas Learning -- Tinkering around with functions Standardize
def morph_columns(df: DataFrame, char: str = '_') -> DataFrame:
""" Standardize and remove spaces of column names of a given dataframe
"""
def mapper(item: str) -> str:
""" Set item to lowercase and replace spaces with desired character
"""
if ' ' in item:
return item.replace(' ', char).lower()
@dmbdesignpdx
dmbdesignpdx / clean_dataframe.py
Created January 11, 2025 01:30
Pandas Learning -- Tinkering around with functions
""" Note:
Why not just use .drop_duplicates()?
Well, there is a known issue with that method increasing memory usage
"""
def clean_dataframe(df: DataFrame) -> DataFrame:
""" Removes duplicate and null rows and returns the resulting dataframe
"""
duplicate_rows = df[df.duplicated()]
indices = [row[0] for row in duplicate_rows.itertuples()]
@dmbdesignpdx
dmbdesignpdx / semantic.html
Created February 12, 2020 19:46
HTML Semantic Structure
<html>
<head>
<title>Semantic Structure</title>
</head>
<body>