Skip to content

Instantly share code, notes, and snippets.

View onyxraven's full-sized avatar
😺

Justin Hart onyxraven

😺
View GitHub Profile
@onyxraven
onyxraven / asdf-alias
Created November 3, 2020 16:34 — forked from andrewthauer/asdf-alias
asdf-alias
#!/usr/bin/env bash
#
# description:
# Symlink a short name to an exact version
#
# usage:
# asdf-alias <plugin> <name> [<version> | --auto | --remove]"
# asdf-alias <plugin> --auto"
# asdf-alias <plugin> [--list]"
#
@onyxraven
onyxraven / getstream.sh
Last active September 12, 2018 21:25
Stream a Kinesis shard on the Commandline
#!/usr/bin/env bash
# prereqs: awscli, awslocal (for now), jq
set -e
streamname=$1
iteratorType=${2:-LATEST}
shard=$(awslocal kinesis describe-stream --stream-name $streamname --query 'StreamDescription.Shards[0].ShardId' --output text)
iterator=$(awslocal kinesis get-shard-iterator --stream-name $streamname --shard-id $shard --shard-iterator-type $iteratorType --output text)
@onyxraven
onyxraven / find_principals.rb
Created February 15, 2017 23:24
Find IAM principals with any of the given actions
require 'json'
users = JSON.parse(`aws iam list-users`)['Users'].map { |u| u['Arn'] }
groups = JSON.parse(`aws iam list-groups`)['Groups'].map { |u| u['Arn'] }
roles = JSON.parse(`aws iam list-roles`)['Roles'].map { |u| u['Arn'] }
all = users + groups + roles
actions = ARGV
@onyxraven
onyxraven / zincr_roundrobin.lua
Created July 30, 2014 20:28
Lua/Redis round-robin increment set
local numbers_list = redis.call('ZRANGE', KEYS[1], 0, -1, 'WITHSCORES')
local numbers = {}
--every other value is a key
for idx = 1, #numbers_list, 2 do
numbers[numbers_list[idx]] = numbers_list[idx + 1]
end
--add missing numbers at '0' and immediately return first one
for _, f in pairs(ARGV) do
if numbers[f] == nil then
redis.call('ZADD', KEYS[1], 1, f)
### Keybase proof
I hereby claim:
* I am onyxraven on github.
* I am onyxraven (https://keybase.io/onyxraven) on keybase.
* I have a public key whose fingerprint is 7AFF A019 A34D B4CC E268 699A 6FE7 3398 DD61 DFCB
To claim this, I am signing this object:
@onyxraven
onyxraven / ec2_ssh_config.py
Last active December 18, 2015 19:18 — forked from ozkatz/ec2_ssh_config.py
Add option for identity file ssh config
#!/usr/bin/env python
import os
import sys
import argparse
try:
from boto.ec2.connection import EC2Connection
except ImportError:
sys.stderr.write('Please install boto ( http://docs.pythonboto.org/en/latest/getting_started.html )\n')
sys.exit(1)
@onyxraven
onyxraven / request_cache_store.rb
Last active December 15, 2015 05:09
A stab at using RequestStore (https://github.com/steveklabnik/request_store) as a rails Cache::Store
class RequestCacheStore < ActiveSupport::Cache::Store
# Delete all entries with keys matching the pattern.
#
# Options are passed to the underlying cache implementation.
#
# All implementations may not support this method.
def delete_matched(matcher, options = nil)
options = merged_options(options)
instrument(:delete_matched, matcher.inspect) do
@onyxraven
onyxraven / dirsync-monitor.rb
Created December 23, 2012 21:22
ruby fsevent wrapper to sync directories
#!/usr/bin/env ruby
#requires osx fsevent
#requires growl with network registration enabled (at least once)
#requires the below rubygems
#requires rsync
require 'rubygems'
require 'rb-fsevent'
require 'ruby-growl'
@onyxraven
onyxraven / sync.sh
Last active December 10, 2015 02:18
rsync wrapper script
#!/bin/bash
#requires gnu getopt
#requires rsync
GETOPT="/opt/local/bin/getopt"
rsynccmd="rtlzv --exclude=compile --exclude=cache"
localdir='/Volumes/Work/dev'
devdir='/home/username/dev'
devhost="dev"