Skip to content

Instantly share code, notes, and snippets.


Mark Holmberg mark-d-holmberg

View GitHub Profile
jamesgmarks / gist:56502e46e29a9576b0f5afea3a0f595c
Last active Oct 30, 2020
View gist:56502e46e29a9576b0f5afea3a0f595c
DECLARE hexStr CHAR(32);
SET hexStr = HEX(b);
SUBSTR(hexStr, 1, 8), '-',
SUBSTR(hexStr, 9, 4), '-',
srevenant / time.ex
Last active Oct 10, 2019
Time bits for use in Elixir. Sometime, it's easier to just fall back to posix time... LMK if you find better ways to do this!
View time.ex
defmodule Utils.Time do
import Utils.Types, only: [str_to_int!: 1, str_to_float: 1]
import Utils.Enum, only: [enum_rx: 2]
# note for future
def iso_time_range(input) when is_binary(input) do
case String.split(input, "/") do
[stime, etime] ->
mark-d-holmberg / rails-5.2.3-ruby-2.6.4-gem-engine
Created Sep 10, 2019
Create a Rails 5.2.3 on Ruby 2.6.4 Gem engine running API JSON mode only
View rails-5.2.3-ruby-2.6.4-gem-engine
rails plugin new elemental -d mysql --mountable -T --dummy-path=spec/dummy --skip-action-mailer -C --skip-turbolinks --skip-action-cable --skip-spring --skip-active-storage --skip-coffee --skip-yarn --api -p
View Node.JS healthcheck
/* bring in configs, and backends, like db */
/* const config = require('config') */
let healthy = true
setInterval(() => {
// check db pools, maybe run a query, etc.
try {
if (db.check_health()) { // but do this with a timelimit that is less than check interval seconds
healthy = true
srevenant / .bashrc
Last active Sep 7, 2018
fast-forward git bash helpers
View .bashrc
# When working on a project with multiple developers master will get ahead of your work.
# To come in sync should you rebase? merge? what is a fast-forward? Lots of discussion
# is available on this, here are a few:
# I prefer a merge/fast-forward, rather than rebase. These helpers assist in that process.
# LMK your thoughts and if you know of a better way! Enjoy!
tkfu / srd_5e_monsters.json
Last active Dec 3, 2020
A JSON file with all the D&D 5e SRD monster data
View srd_5e_monsters.json
"name": "Aboleth",
"meta": "Large aberration, lawful evil",
"Armor Class": "17 (Natural Armor)",
"Hit Points": "135 (18d10 + 36)",
"Speed": "10 ft., swim 40 ft. ",
"STR": "21",
"STR_mod": "(+5)",
"DEX": "9",
elderbas / class_controller.ex
Last active Aug 12, 2020
Elixir — Inserting Multiple Changesets Into Database - create batch
View class_controller.ex
def create_batch(conn, %{"people" => people_params}) do
changesets =, fn class ->
Person.changeset(%Person{}, person)
result = changesets
|> Enum.with_index()
|> Enum.reduce(, fn ({changeset, index}, multi) ->
Ecto.Multi.insert(multi, Integer.to_string(index), changeset)
austra / Largest Binary Gap
Last active Dec 14, 2017
Largest Binary Gap
View Largest Binary Gap
I read about this problem and thought I would try it. Later I found it is a question here too:
My first instinct was, "I know regex can do this, but I hate regex" (Which is also a good reason to get better at regex).
I couldn't quite hoop the syntax so I moved on. Here is what I came up with:
def max_binary_gap(n)
max_gap = 0
arr = n.to_s(2).chars
while arr.size > 2 do
takeit /
Last active Nov 24, 2020
Write to NTFS on macOS Sierra (osxfuse + ntfs-3g)
  1. Install osxfuse:
brew cask install osxfuse
  1. Reboot your Mac.

  2. Install ntfs-3g:

maxmanders /
Created Apr 13, 2017
KMS Envelope Encryption Using OpenSSL And AWS CLI
$ echo "secret" > secret.txt
$ key_material=$(aws kms generate-data-key --key-id <CMK_key_id> --key-spec AES_256)
$ echo ${key_material} | jq ".CiphertextBlob" | sed 's/"//g' | base64 -d > key.enc
$ export key=$(echo ${key_material} | jq ".Plaintext" | sed 's/"//g' | base64 -d)
$ openssl enc -aes-256-cbc -pass env:key -in secret.txt -out secret.txt.enc
$ rm secret.txt
$ ls
key.enc secret.txt.enc
$ key=$(aws-fd-full kms decrypt --ciphertext-blob fileb://key.enc --output text --query Plaintext | base64 -d)
$ openssl enc -d -aes-256-cbc -pass env:key -in secret.txt.enc -out secret.txt
You can’t perform that action at this time.