Skip to content

Instantly share code, notes, and snippets.

View snewcomer's full-sized avatar

Scott Newcomer snewcomer

View GitHub Profile
@snewcomer
snewcomer / toast.sql
Last active May 1, 2023 16:44
toast queries
SELECT nspname || '.' || relname AS "relation",
pg_size_pretty(pg_total_relation_size(C.oid)) AS “total_size”
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
AND C.relkind <> 'i'
AND nspname ~ '^pg_toast'
ORDER BY pg_total_relation_size(C.oid) DESC
LIMIT 150;
# Import module for data manipulation
import pandas as pd
# Import module for linear algebra
import numpy as np
# Import module for Fuzzy string matching
from fuzzywuzzy import fuzz, process
# Import module for regex
import re
# Import module for iteration
import itertools
@snewcomer
snewcomer / cal_time_pred_outlook.py
Last active January 20, 2023 03:20
Microsoft Outlook Export
import pandas as pd
import numpy as np
from datetime import datetime, time
from sklearn.linear_model import Lasso, Ridge, LogisticRegression
from sklearn.metrics import classification_report, confusion_matrix
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from sklearn.metrics import r2_score, mean_squared_error, roc_auc_score
import pandas as pd
import numpy as np
from datetime import datetime, time
#import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from sklearn.metrics import r2_score, mean_squared_error
from sklearn.ensemble import RandomForestClassifier
@snewcomer
snewcomer / cal_time.py
Created January 8, 2023 15:56
Busy in 30 min intervals
import pandas as pd
import numpy as np
from datetime import datetime
import matplotlib.pyplot as plt
cal = pd.read_csv('cal.csv')
# clean summary
cal = cal.query("summary not in ('Mid-week Meditation', 'Coffee Chat: Meet our New Hires!', 'PED Lunch & Learn Hold', 'AskPeople')")
cal = cal[cal['summary'].str.contains("Company Holiday") == False]
@snewcomer
snewcomer / cal.py
Last active January 6, 2023 15:20
cal training data
import pandas as pd
from datetime import datetime
cal = pd.read_csv('cal.csv')
# clean summary
cal = cal.query("summary not in ('Mid-week Meditation', 'Coffee Chat: Meet our New Hires!')")
cal = cal[cal['summary'].str.contains("Company Holiday") == False]
# clean dtstart
@snewcomer
snewcomer / gist:900d06725096b837d2403366919f7287
Created November 25, 2022 12:48
postgres-table-hit-ratio.sql
"
with table_stats as (
select psut.relname,
psut.n_live_tup,
1.0 * psut.idx_scan / greatest(1, psut.seq_scan + psut.idx_scan) as index_use_ratio
from pg_stat_user_tables psut
order by psut.n_live_tup desc
),
table_io as (
select psiut.relname,
@snewcomer
snewcomer / utils-untrusted-html.js
Created October 19, 2022 18:13
ember untrusted html
// NOTE: DO NOT DISABLE THIS ON YOUR OWN!
// This lint is disabled here knowing that the contract for this
// helper is that no untrusted content is passed in. If you disable
// this lint and use htmlSafe elsewhere, you could risk opening up an
// XSS vulnerability.
// eslint-disable-next-line name-xss/avoid-xss-risks
import { htmlSafe } from '@ember/template';
const DEFAULT_SAFE_TAGS = ['strong', 'em', 'b', 'i', 'u', 'br'];
@snewcomer
snewcomer / autotracking.js
Created April 1, 2022 16:47 — forked from pzuraq/autotracking.js
Autotracking Simplified
// The global revision clock. Every time state changes, the clock increments.
let $REVISION = 0;
// The current dependency tracker. Whenever we compute a cache, we create a Set
// to track any dependencies that are used while computing. If no cache is
// computing, then the tracker is null.
let CURRENT_TRACKER = null;
// Storage represents a root value in the system - the actual state of our app.
class Storage {

Let's Make A Dropdown

Here, we intend a component that can be used for something like a user menu in a nav. Maybe you've heard it called "popover" or something like that.

It is not meant to be a select element, or used in a <form>.

Goals:

  • make a component that other developers can consume as an addon
  • it should be accessible