Skip to content

Instantly share code, notes, and snippets.

View kmatt's full-sized avatar
😐

Matt Keranen kmatt

😐
  • SE US
View GitHub Profile
#
# This shell prompt config file was created by promptline.vim
#
function __promptline_host {
local only_if_ssh="0"
if [ $only_if_ssh -eq 0 -o -n "${SSH_CLIENT}" ]; then
if [[ -n ${ZSH_VERSION-} ]]; then print %m; elif [[ -n ${FISH_VERSION-} ]]; then hostname -s; else printf "%s" \\h; fi
fi
}
@kmatt
kmatt / pl_to_sql.py
Last active November 19, 2024 02:05 — forked from bthaman/df_to_sql_fast.py
Polars dataframe to SQL Server using pyodbc, without Pandas or SQLAlchemy dependencies
def pl_to_sql(df, table, replace=False):
"""
to_sql() without Pandas
Appends or overwrites a SQL Server table using data from a DataFrame
Parameters:
df (DataFrame): df used to create/append table
table (str): Name of existing SQL Server table
replace (bool): Truncate before insert
Returns:
@kmatt
kmatt / SQLAgentScripter.ps1
Created January 9, 2024 16:52 — forked from tcartwright/SQLAgentScripter.ps1
POWERSHELL: Generates SQL Server Agent objects to sql files
[cmdletbinding()]
Param(
[Parameter(Mandatory=$true)]
[string[]]$servers,
[ValidateScript({
if(-Not ($_ | Test-Path )) {
throw "Folder does not exist"
}
return $true
@kmatt
kmatt / zfsCommands.md
Created December 1, 2023 17:31 — forked from aaiezza/zfsCommands.md
ZFS

Here are some helpful commands for managing ZFS and ZPool on Ubuntu

VDEV

Useful for populating /etc/zfs/vdev_id.conf:

printDisks() {
    for i in /dev/sd[b-i]; do
        fdisk -l $i
@kmatt
kmatt / clojure-learning-list.md
Created January 18, 2023 04:09 — forked from ssrihari/clojure-learning-list.md
An opinionated list of excellent Clojure learning materials

An opinionated list of excellent Clojure learning materials

These resources (articles, books, and videos) are useful when you're starting to learn the language, or when you're learning a specific part of the language. This an opinionated list, no doubt. I've compiled this list from writing and teaching Clojure over the last 10 years.

  • 🔴 Mandatory (for both beginners and intermediates)
  • 🟩 For beginners
  • 🟨 For intermediates

Table of contents

  1. Getting into the language
@kmatt
kmatt / mssql_insert_json.py
Created January 17, 2023 02:37 — forked from gordthompson/mssql_insert_json.py
Alternative to_sql() *method* for mssql+pyodbc
# Alternative to_sql() *method* for mssql+pyodbc or mssql+pymssql
#
# adapted from https://pandas.pydata.org/docs/user_guide/io.html#io-sql-method
import json
import pandas as pd
import sqlalchemy as sa
def mssql_insert_json(table, conn, keys, data_iter):
@kmatt
kmatt / mssql_df_upsert.py
Created January 12, 2023 20:20 — forked from gordthompson/mssql_df_upsert.py
Build a T-SQL MERGE statement and upsert a DataFrame
# version 1.2 - 2022-11-01
import pandas as pd
import sqlalchemy as sa
def df_upsert(data_frame, table_name, engine, schema=None, match_columns=None):
"""
Perform an "upsert" on a SQL Server table from a DataFrame.
Constructs a T-SQL MERGE statement, uploads the DataFrame to a
@kmatt
kmatt / MacOSLogoutHook.txt
Last active November 23, 2022 19:19 — forked from RxDx/MacOSLogoutHook.txt
MacOS: Run script before shutdown
Create a file:
$ vim /Users/Shared/logoutHook.sh
File content:
#!/bin/bash
say 'Hasta la vista baby!'
Set execution permission:
$ sudo chmod +x /Users/Shared/logoutHook.sh
@kmatt
kmatt / .zshrc
Created February 18, 2022 04:18 — forked from aiqc/.zshrc
zsh_prompt.txt
# ========= PROMPT =========
# Version control information
autoload -Uz vcs_info
precmd() { vcs_info }
# Format the vcs_info_msg_0_ variable
zstyle ':vcs_info:git:*' formats ' %b '
# Render the prompt
setopt PROMPT_SUBST
@kmatt
kmatt / LearnGoIn5mins.md
Created January 6, 2021 04:41 — forked from prologic/LearnGoIn5mins.md
Learn Go in ~5mins