Skip to content

Instantly share code, notes, and snippets.

View tlehman's full-sized avatar

Tobi Lehman tlehman

View GitHub Profile
@tlehman
tlehman / gem-dependencies.rb
Last active September 5, 2024 21:48
Get transitive gem dependencies
#!/usr/bin/env ruby
require 'set'
def get_gem_dependencies(gem_name, version = nil)
require 'open-uri'
require 'yaml'
url = if version
"https://rubygems.org/api/v2/rubygems/#{gem_name}/versions/#{version}.yaml"
else
@tlehman
tlehman / bump-mods.rb
Created August 20, 2024 18:46
Bump Puppetfile module versions to latest
# Bump the module versions in the Puppetfile to the latest version
# published on https://forge.puppet.com
#
# How to use: `cd` to the directory where your Puppetfile is, then run `ruby bump-mods.rb` and then check your git diff
# to verify that the upgrades look correct.
require 'open-uri'
require 'rss'
def parse_puppetfile_get_mod_versions
module_re = /^mod 'puppetlabs-([a-z\_\-]+)', *'([0-9\.]+)'$/i
@tlehman
tlehman / blog_setup.pp
Last active January 3, 2024 04:54
Introduction to Puppet Part 3 Manifest (incrementally building it up instead of the all-at-once approach in Part 1)
# introduced in https://tlehman.blog/p/introduction-to-puppet
# refined in https://tlehman.blog/p/introduction-to-puppet-part-3
node default {
# Ensure the required packages are installed
package { ['ruby', 'bundler', 'libyaml-dev']:
ensure => installed,
}
exec { 'gem install rails -v 7.1.2':
cwd => '/',
@tlehman
tlehman / blog_setup.pp
Last active January 2, 2024 23:28
Introduction to Puppet Part 1 Manifest
# introduced in https://tlehman.blog/p/introduction-to-puppet
# refined in https://tlehman.blog/p/introduction-to-puppet-part-2
node default {
# Ensure the required packages are installed
package { ['nginx', 'ruby', 'ruby-railties']:
ensure => installed,
}
# Configure Nginx to listen on port 80 and proxy to port 3000
file { '/etc/nginx/sites-available/default':
@tlehman
tlehman / blog.pp
Created November 30, 2023 22:06
blog catalog
node 'your-blog-name' {
# Ensure the required packages are installed
package { ['nginx', 'ruby', 'rails']:
ensure => installed,
}
# Configure Nginx to listen on port 80 and proxy to port 3000
file { '/etc/nginx/sites-available/default':
ensure => file,
#!/bin/bash
GRAPH_NAME=tlehman
function roam_api_get_blocks_containing_string() {
curl -X POST "https://api.roamresearch.com/api/graph/$GRAPH_NAME/q" --location-trusted \
-H "accept: application/json" \
-H "Authorization: Bearer $ROAM_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"query\" : \"[:find ?block-str :in \$ ?search-string :where [?b :block/uid ?block-uid] [?b :block/string ?block-str] [(clojure.string/includes? ?block-str ?search-string)]]\", \"args\": [\"$1\"]}"
#include <stdio.h>
#include <string.h>
#include <openssl/sha.h>
#include <openssl/ripemd.h>
#include <bitcoin/bitcoin.h>
#define BIP39_ENTROPY_LEN 32
#define BIP39_MNEMONIC_LEN 12
void bip39_to_address(const char *mnemonic, const char *password)
@tlehman
tlehman / ec2-with-maxpods.csv
Created December 6, 2022 19:00
EC2 types with their EKS Kubernetes maxpods limit
ec2type mem_gb vcpu network_gigabits maxpods
vt1.3xlarge 24 12 3.12 58
vt1.6xlarge 48 24 6.25 234
c6gd.medium 2 1 10 8
x2gd.medium 16 1 10 8
m6gd.medium 4 1 10 8
r6gd.medium 8 1 10 8
r6g.medium 8 1 10 8
m6g.medium 4 1 10 8
c6g.medium 2 1 10 8
@tlehman
tlehman / gocui-example.go
Created June 21, 2022 18:43
Simple example of gocui that responds to the arrow keys by moving the message around on the screen
package main
import (
"errors"
"fmt"
"log"
"github.com/awesome-gocui/gocui"
)
@tlehman
tlehman / gvm.zsh
Last active April 22, 2022 02:47
Go version manager in zsh using autocompletion
#!/usr/bin/zsh
# Go version manager by tlehman
# how to use: call _init_gvm in your .zshrc, then type "gvm -s <tab>" to have it autocomplete with all your installed go versions
function _gvm() {
local state
_arguments '-s[set go version]:go_version:->set_go'
case $state in
set_go)