Skip to content

Instantly share code, notes, and snippets.

View davissp14's full-sized avatar

Shaun Davis davissp14

View GitHub Profile
@davissp14
davissp14 / config.yml
Created January 19, 2020 18:34 — forked from phra/config.yml
Update Chrome to latest version on CircleCI 2.0
- run: #STABLE
name: Install Chromedriver latest version
command: |
sudo apt-get update
sudo apt-get install lsb-release libappindicator3-1
curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome.deb
sudo sed -i 's|HERE/chrome"|HERE/chrome" --no-sandbox|g' /opt/google/chrome/google-chrome
rm google-chrome.deb
@davissp14
davissp14 / sentinel_reconfig.py
Last active July 15, 2016 16:26
Repair / Reconfigure Sentinel Script
#!/usr/bin/python
# This was written to help with common sentinel misconfigurations.
# This script will loop through each of your sentinels nodes and properly reconfigure them to monitor the master node.
# Instructions
# 1. Modify the instance variable values to reflect your setup.
# 2. Run the script.
import sys
class MaxHeap
def self.heapify(arr, i)
l = left(i)
r = right(i)
heap_size = arr.size - 1
if l <= heap_size && arr[l] > arr[i]
@davissp14
davissp14 / gist:5e4619c9369823999bfb
Created April 25, 2015 02:01
Binary Search Tree
class Node
attr_accessor :left, :right, :parent, :key
def initialize(key)
@parent = @left = @right = nil
@key = key
end
end
class BST
@davissp14
davissp14 / gist:86b32aa86f3e79c2b566
Created April 25, 2015 01:59
Queue using a fixed size array
class Queue
def initialize(size=10)
raise 'InvalidInputType' unless size.is_a?(Fixnum)
@store = Array.new(size)
@size = size
@tail = @head = 0
end
def enqueue(ele)
@davissp14
davissp14 / gist:f8eee1d04978016a2327
Created April 25, 2015 01:57
Stack using a fixed size array
class Stack
def initialize(size=10)
raise "InvalidSizeInput" unless size.is_a?(Fixnum)
@store = Array.new(size)
@size = size
@top = 0
end
def push(ele)
class Node
attr_accessor :key, :value, :left, :right, :size
def initialize(key, value)
@key = key
@value = value
@size = 0
@left, @right = nil, nil
end
end
@davissp14
davissp14 / gist:5617792
Created May 21, 2013 06:14
Implementation of Insertion sort. Ascending / Descending
def insertion_sort(array)
for j in 1...array.length
i = j - 1
key = array[j]
while i >= 0 && array[i] > key
array[i+1] = array[i]
i = i - 1
end
array[i+1] = key
end
@davissp14
davissp14 / gist:5462670
Created April 25, 2013 20:01
Multi level symbolizer with tail recursion.
#Example
# Input: {"first1"=>"hi", "first2"=>{"second"=>"gah", "second1"=>{"third1"=>"toot"}, "second2"=>"gah3"}}
# Output: {:first1=>"hi", :first2=>{:second=>"gah", :second1=>{:third1=>"toot"}, :second2=>"gah3"}}
def symbolize(hash)
toprocess = [hash]
while h = toprocess.shift
h.keys.each do |k|
v = h[k]
if v.is_a?(Hash)
@davissp14
davissp14 / multi-level symbolizer
Created April 25, 2013 19:48
Symbolize each level of your hash...
#Example
# Input: {"first1"=>"hi", "first2"=>{"second"=>"gah", "second1"=>{"third1"=>"toot"}, "second2"=>"gah3"}}
# Output: {:first1=>"hi", :first2=>{:second=>"gah", :second1=>{:third1=>"toot"}, :second2=>"gah3"}}
def symbolize(hash)
temp_hash = {}
hash.map do |k,v|
temp_hash[k.to_sym] = v
if v.is_a?(Hash)
temp_hash[k.to_sym] = symbolize(v)