Skip to content

Instantly share code, notes, and snippets.

Avatar

Scott Newcomer snewcomer

  • @AuditBoard
  • Wisconsin
  • Twitter @puekey
View GitHub Profile
@snewcomer
snewcomer / cal_time_pred_outlook.py
Last active January 20, 2023 03:20
Microsoft Outlook Export
View cal_time_pred_outlook.py
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
View cal_time_pred.py
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
View cal_time.py
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
View cal.py
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
View gist:900d06725096b837d2403366919f7287
"
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
View utils-untrusted-html.js
// 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
View autotracking.js
// 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 {
View dropdown-question.md

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
View fast-relative-time-string.ts
const minute = 60;
const hour = minute * 60;
const day = hour * 24;
const week = day * 7;
const month = day * 30;
const year = day * 365;
/**
* Convert a date to a relative time string, such as
* "a minute ago", "in 2 hours", "yesterday", "3 months ago", etc.
@snewcomer
snewcomer / in-list-test.js
Last active March 7, 2022 20:16
array.includes vs set.has
View in-list-test.js
const makeArray = (size) => [...Array(size)].map(() => size);
const small = makeArray(1000);
const medium = makeArray(10000000);
const large = makeArray(100000000);
const solution1 = (arr) => {
arr.includes(arr.length - 1);
};