Skip to content

Instantly share code, notes, and snippets.

View dmidlo's full-sized avatar

David Midlo dmidlo

View GitHub Profile
@dmidlo
dmidlo / resume_session.ps1
Last active August 10, 2024 04:40
resume_session.ps1
## ScriptName: last_session.ps1
## author: David Midlo ([email protected])
##
## Purpose: This PowerShell script is designed as a proof of concept for resuming a long-running
## process in a script that processes user accounts from Active Directory. The script stores progress
## in a file (`USERS.clixml`) so that it can resume from where it left off if interrupted, avoiding the
## need to restart from the beginning. This is particularly useful for environments
## where processing large numbers of user accounts may take significant time.
##
## Disclaimer: No warranty and all that! This is a proof of concept script only! There is no
@dmidlo
dmidlo / jank_percent_complete.sh
Last active March 13, 2023 13:20
After a weird bug with devonthink, no progress bar was displayed but the operation was happily moving forward. Since I still had shell access, I wanted to still be able to monitor what I knew would be a long-running file transfer. Requires total expected files to provided as an argument. Very narrow use case and moreover, this doesn't cover many…
#!/opt/local/bin/zsh
##################################
##################################
##################################
get_file_count () {
echo $(echo "$(ls | wc -l)-1" | bc)
}
start_file_count=$(get_file_count)
@dmidlo
dmidlo / PLSQL - Function - Increment an Integer.sql
Created June 5, 2018 17:09
PLSQL - Function - Increment an Integer
-- Solution 1
CREATE OR REPLACE FUNCTION increment(i integer) RETURNS integer as $$
BEGIN
return i + 1;
END;
$$ LANGUAGE plpgsql;
-- Soluution 2
CREATE FUNCTION increment(i integer) RETURNS integer
AS 'select $1 + 1;'
let webdriver = require('selenium-webdriver'),
chrome = require('selenium-webdriver/chrome'),
By = webdriver.By
until = webdriver.until;
let options = new chrome.Options();
options.setChromeBinaryPath('/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary');
options.addArguments(['headless','disable-gpu']);
let driver = new webdriver.Builder().forBrowser('chrome').setChromeOptions(options).build();
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
###### Powerlevel9k Settings
POWERLEVEL9K_MODE="awesome-patched"
ZSH_THEME="powerlevel9k/powerlevel9k"
@dmidlo
dmidlo / pltask.zsh
Last active October 17, 2017 19:17
#pltask functions
## pltask is a lightweight facade to taskwarrior for use with Powerlevel9k's Second Prompt Prefix (by dmidlo @querentCode)
## Be sure to set search.case.sensitive=no within .taskrc
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX="\n"
pltask () {
setNewlinePrompt () {
POWERLEVEL9K_MULTILINE_SECOND_PROMPT_PREFIX="%K{white}%F{black}\n $1 %f%k%F{white}%f $ "
plugins=(... zsh-syntax-highlighting history-substring-search)
###### Zsh-Syntax-Highlighting Settings
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor)
ZSH_HIGHLIGHT_STYLES[cursor]='bold'
ZSH_HIGHLIGHT_STYLES[alias]='fg=green,bold'
ZSH_HIGHLIGHT_STYLES[suffix-alias]='fg=green,bold'
ZSH_HIGHLIGHT_STYLES[builtin]='fg=green,bold'
ZSH_HIGHLIGHT_STYLES[function]='fg=green,bold'
ZSH_HIGHLIGHT_STYLES[command]='fg=green,bold'
plugins=(... zsh-syntax-highlighting)
bindkey '^ ' autosuggest-accept