Skip to content

Instantly share code, notes, and snippets.


Josh Holbrook jfhbrook

Block or report user

Report or block jfhbrook

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jfhbrook / PasswordPrompt.ps1
Created Oct 6, 2019
password prompt in powershell on windows 10
View PasswordPrompt.ps1
# Simple and nasty password prompt
# Adapted from
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$form = New-Object System.Windows.Forms.Form
$form.Text = 'Credentials Time!'
$form.Size = New-Object System.Drawing.Size(240,130)
$form.StartPosition = 'CenterScreen'
jfhbrook / package.bas
Last active Oct 3, 2019
sketch for an Excel AddIns manager
View package.bas
' Good practice for people to install Addins Manager 2006 manually
' This is consistent with things like vundle and also will lead to
' the least surprise when opening a fresh workbook for the first time
Applications.AddIns("AddIns Manager 2006").installed = True
' Use an s3 bucket or ceph or similar to host addins files = "s3://joshs-cool-s3-bucket"
' Use a super simple version ranges dsl
' note, the v should be required to ensure Excel never thinks it's a number
View databases.toml
connstring = "postgresql+psycopg2://josh:{password}@localhost:5432/josh"
password_cmd = "kdialog --password 'Playground password?'"
class Select:
def __init__(self):
self.actions = []
def get(self, selector):
self.actions.append({'action': 'get', 'selector': selector})
def select(self, obj):
this = obj
for action in self.actions:
import warnings
from my_package.new_module import example_export as _example_export
def example_export():
'my_package.legacy_module.example_export is deprecated in favor of my_package.new_module.example_export'
jfhbrook / recs.sql
Last active Sep 20, 2019
sketch of using cosine similarities to compare entities in sql :)
View recs.sql
with recommendations as (
i.n as i,
j.n as j,
(i.x * j.x + i.y * j.y) / ((i.x * i.x + i.y * i.y)^0.5 * (j.x * j.x + j.y * j.y)^0.5) as similarity
from points i
cross join points j
where i.n <> j.n
select j from recommendations where i = %id order by similarity desc limit 3;
import time
import dumb_blocking_library
while True:
for event in dumb_blocking_library.get_new_events():
View average_rating_by_genre
from collections import Counter
rating_sums_by_genre = Counter()
counts_by_genre = Counter()
for app in AppleStore_free:
genre = app[-5]
rating_sums_by_genre[genre] += float(app[5])
counts_by_genre[genre] += 1

I tried changing my username and home directory on my Windows 10 machine recently, and I got 95% of the cases out of the way, but npm is one of the last ones. The error you're seeing means that npm thinks that my home directory is at c:\Users\Joshua Holbrook instead of c:\Users\Josh. 🙃 So the question is, how do I trace this back to the code that decides where my home directory is?

jfhbrook / org-config.el
Created Aug 25, 2019
snippet in my .spacemacs for configuring agenda and refile targets
View org-config.el
(with-eval-after-load 'org
(let* ((life-home "~/life/")
(get-path (lambda (fname) (expand-file-name (concat life-home fname))))
(board-files (mapcar get-path `("" "")))
(project-files (file-expand-wildcards (concat life-home "projects/*.org")))
(docs-files (cons (funcall get-path "") nil))
(agenda-files board-files)
(refile-files (append board-files project-files docs-files))
(refile-config (lambda (fname level) (cons fname (cons :maxlevel 1)))))
(setq org-agenda-files agenda-files)
You can’t perform that action at this time.