Skip to content

Instantly share code, notes, and snippets.

View SolomonHD's full-sized avatar

Solomon Hilliard SolomonHD

  • Emory University
  • Atlanta,GA
View GitHub Profile
@SolomonHD
SolomonHD / 25FEB15 Quiz
Created February 25, 2015 14:13
Palindrome
require 'minitest/autorun'
require 'minitest/pride'
def palindrome?(input)
input.downcase!
array = input.split(" ")
array = array.join
input2 = array.to_s
if input2 == input2.reverse
return true
@SolomonHD
SolomonHD / 26FEB15
Created February 26, 2015 14:24
26FEB15 New Ruby
require 'minitest/autorun'
require 'minitest/pride'
# Write a method which accepts an array and returns a sum of the elements in the
# array. Specifying a second parameter (e.g. 3) will allow you to sum all the
# items starting from index 3. Specifying three parameters will allow you to sum
# between two indices (e.g. everything between 3 and 6, inclusive).
# WRITE YOUR CODE HERE. Name your method `subsum`.
def subsum(array, x = -1, y = -1)
@SolomonHD
SolomonHD / 02MAR15.rb
Created March 2, 2015 14:20
02MAR15 Quiz
require 'minitest/autorun'
require 'minitest/pride'
# Write a class which has an initialize method, a reader method, a private
# method, and a class method.
# WRITE YOUR CODE HERE.
class Goat
def initialize(name = "default")
@name = name
class OddArray
def initialize(odd_array)
@odd_array = odd_array
end
def to_a
odd_only_array = []
@odd_array.each do |number|
if number.class == Fixnum && number.odd?
odd_only_array << number
@SolomonHD
SolomonHD / 04MAR15
Created March 4, 2015 14:07
04MAR15 Gist Solomon
require 'minitest/autorun'
require 'minitest/pride'
# Write two classes which inherit from the Vehicle class below. You will also
# need to add a method to the Vehicle class during this challenge.
class Vehicle
def initialize(make, model)
@make = make
@SolomonHD
SolomonHD / 05MAR15
Created March 5, 2015 14:12
05MAR15 Its about MODULEs guys
require 'minitest/autorun'
require 'minitest/pride'
# Write code which will be included in the human class which will give humans
# intelligent and bipedal behavior.
# WRITE YOUR CODE BELOW THIS COMMENT...
module Intelligent
NUMBER_OF_BRAINS = 1
@SolomonHD
SolomonHD / ec2_name_mapping.yml
Last active July 6, 2018 14:10
EC2 Name Mapping
---
- name: Build list of instance IDs by instance name
ec2_instance_facts:
region: "{{ region }}"
filters:
"tag:NightlyBackup": "Yes"
# "tag:Name": "{{ groups['backup'] }}"
register: ec2_facts
- debug:
@SolomonHD
SolomonHD / delegates.rb
Created December 11, 2018 16:44
Cantaloupe delegates.rb with CGI enabled
require 'net/http'
require 'uri'
require 'json'
require 'java'
##
# Delegate script to connect Cantaloupe to Fedora. It slices a piece of
# Cantaloupe for Samvera to consume.
#
# This is a first pass and doesn't have a lot of error checking built in yet.
@SolomonHD
SolomonHD / ssh-to-ec2-by-tag-name
Last active October 11, 2019 18:17
Bash function for SSH into EC2 by Name Tag
<< ////
This function will ssh into a EC2 based on Name tags. You can ssh in via public or private IP This function requires awscli to work
There are several optional environment variables:
AWS_PROFILE = Control which profile is active with this variable, if this is unset the function will use AWS_DEFAULT_PROFILE instead
SSH_EC2_KEY_FILE = path to the key file for the user
SSH_EC2_USER = name of the user that logs in, if this variable is unset the value is ec2-user
To use this function do the following commands
(from command line)
@SolomonHD
SolomonHD / delegates.rb
Created December 2, 2019 22:04
Delegates file for S3
require 'net/http'
require 'uri'
require 'json'
require 'java'
##
# Delegate script to connect Cantaloupe to Fedora. It slices a piece of
# Cantaloupe for Samvera to consume.
#
# This is a first pass and doesn't have a lot of error checking built in yet.