Skip to content

Instantly share code, notes, and snippets.

View jaybarra's full-sized avatar
🐕

Jay Barra jaybarra

🐕
View GitHub Profile
@jaybarra
jaybarra / .dir-locals.el
Created December 10, 2025 09:55
typescript dir-locals for working with STAC repos
((nil
. ((indent-tabs-mode . nil)
(c-basic-offset . 2)
(tab-width . 2))))
@jaybarra
jaybarra / filter_emails.el
Last active December 10, 2025 09:53
Quick filter for emails by domain
(defun my/extract-email (line)
"Return the email address found in the LINE."
(when (string-match "<\\([^>]+\\)>" line)
(match-string 1 line)))
(defun my/filter-emails-by-domain (text domain)
"From the TEXT, find all emails with the DOMAIN."
(let* ((lines (split-string text "\n" t))
(result '()))
(dolist (ln lines result)
@jaybarra
jaybarra / mergeMaybe.ts
Created March 22, 2023 19:02
Merge non-trivial keys of objects together
/**
* Merge non-trivial map entries.
* Filters out
* - null
* - undefined
* - NaN
* - empty arrays
* - empty strings
*/
export const mergeMaybe = (map: object, maybeMap?: unknown) => {
@jaybarra
jaybarra / collections.ex
Created March 3, 2023 17:35
Elixir query for collections example
defmodule Cmr.Collections do
alias Finch
alias Jason
@doc """
Returns a list of collections for a provider.
"""
def get_provider_collections(provider) do
query_params = "?provider_id=#{provider.id}"
@jaybarra
jaybarra / aws_profile.zsh
Created December 17, 2021 15:48
Sets the more verbose version of AWS profile environment variables
# Set AWS Profile Environment Variables
_parse_property() {
cut -d '=' -f 2 <<< "$1" | xargs
}
aws_profile() {
profile=false
IFS='='
@jaybarra
jaybarra / parse_semver.clj
Last active July 20, 2021 18:12
Parse semantic versioning
(ns parse-semver
(:require
[clojure.edn :as edn]
[cloure.string :as str])
(defn- version-exceeds-min?
"Takes an array of integer version values and compares if the version exceeds a min"
[versions min-versions]
(let [v (first versions)
m (or (first min-versions) 0)]
@jaybarra
jaybarra / game_of_life.clj
Last active May 23, 2021 23:06
Conways game of life in Clojure
(ns game-of-life)
(defn make-grid
"Return a vector representing a square 2d-array with random cells alive"
[size]
(for [y (range size)
x (range size)]
(> 20 (rand-int 100))))
(defn safe-sqrt
@jaybarra
jaybarra / equivalance.clj
Last active January 3, 2021 12:18
Clojure equivalence helpers for use in testing
(ns util.equivalence)
(defn nearly=
"Double precision equivalency check."
([a b]
(nearly= a b 6))
([a b precision]
(< (Math/abs (- a b))
(Math/pow 10 (- precision)))))