Skip to content

Instantly share code, notes, and snippets.

View RyanSnodgrass's full-sized avatar

Ryan Snodgrass RyanSnodgrass

View GitHub Profile
@RyanSnodgrass
RyanSnodgrass / include_json.rb
Created March 30, 2022 13:21
Assertion for RSpec that checks if a hash or json object is within another json object
RSpec::Matchers.define :include_json do |expected_json|
match do |actual_json|
expect(hashify(actual_json)).to include(hashify(expected_json))
end
def hashify(object)
return object.stringify_keys if object.class == Hash
JSON.parse(object)
end
end
@RyanSnodgrass
RyanSnodgrass / Dockerfile
Created December 22, 2021 14:02
Example Dockerfile and Compose for Fenrir
##########==============================##########
from ruby:2.4.10 AS ruby-base
##########==============================##########
# install bundler version that matches Gemfile
RUN gem install bundler -v '1.17.3'
# throw errors if Gemfile has been modified since Gemfile.lock
# RUN bundle config --global frozen 1
@RyanSnodgrass
RyanSnodgrass / .vimrc
Created December 16, 2021 22:08
My personal .vimrc settings
set number
syntax on
highlight LineNr ctermfg=grey
@RyanSnodgrass
RyanSnodgrass / bubble_sort.rb
Last active December 7, 2021 14:28
Practice by implementing bubble sort in Ruby
require 'byebug'
require 'rspec'
class BubbleSort
attr_reader :arr
def initialize(input)
@arr = input
end
def bubble_bubble
@RyanSnodgrass
RyanSnodgrass / Dockerfile.rails.boilerplate
Created November 20, 2021 16:52
My Ruby on Rails starter template. Use this to generate a new Rails app
FROM ruby:3.0
# Add nodejs to apt package manager
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
# Install nodejs
RUN apt-get install -y nodejs
# Install Yarn
RUN npm install --global yarn
from concurrent.futures import ThreadPoolExecutor
import concurrent.futures
import time
import logging
from datetime import datetime, date
import pandas as pd
from itertools import count
from panopto_soap import (
import concurrent.futures
def cancel_further_threads(self, futures, number_of_finished_page):
for fut, page in futures.items():
if page > number_of_finished_page:
fut.cancel()
return futures
@RyanSnodgrass
RyanSnodgrass / pager.py
Created January 7, 2021 14:25
Iterator that returns the next n numbers as a list.
class Pager:
"""Iterator that returns the next n numbers as a list."""
def __init__(self, set_size=10):
self.set_size = set_size
self.start = 1
def __iter__(self):
return self
@RyanSnodgrass
RyanSnodgrass / ryans-ec2-user-data.sh
Last active October 25, 2017 14:44
This goes in the user-data section of ec2 instance generation.
#!/bin/bash
yum update -y
yum -y install git
pip install ansible
mkdir /etc/ansible
touch /etc/ansible/hosts
echo localhost >> /etc/ansible/hosts
runuser -l ec2-user -c 'ansible-galaxy install rvm_io.ruby'
@RyanSnodgrass
RyanSnodgrass / ec2-ansible-playbook.yml
Last active April 28, 2022 23:04
My work in progress to install what's needed for fenrir on AWS EC2 instances
---
# ansible-pull -U https://gist.githubusercontent.com/RyanSnodgrass/92d91e7262d788a9a2abdab6da3126f2 ec2-ansible-playbook.yml
-
hosts: all
roles:
-
role: rvm_io.ruby
rvm1_install_flags: --auto-dotfiles
rvm1_install_path: /usr/local/rvm
rvm1_rubies: