Skip to content

Instantly share code, notes, and snippets.

View scottillogical's full-sized avatar

Scott Schulthess scottillogical

  • Zipcar
  • Boston, MA
View GitHub Profile
@scottillogical
scottillogical / ci-port-forward
Last active May 16, 2022 14:41
kubectl port forward in background for concourse
#!/bin/bash
set -eo pipefail
set -x
error1() {
echo "exit whole script!!!"
exit 1
}
SCRIPT_PATH="$(cd "$(dirname "$0")"; pwd -P)"
@scottillogical
scottillogical / health.sh
Created May 30, 2019 13:15
custom diego health checi
#!/bin/sh
TIMEOUT=${HEALTH_CHECK_TIMEOUT:-30}
URL=${HEALTH_CHECK_URL:-localhost:8091/health}
RESPONSE=$(curl --connect-time $TIMEOUT --max-time $TIMEOUT -qs "$URL")
OUTCOME=$?
set -e
if [ ${OUTCOME} -eq 7 ]; then
echo "Failed to connect to ${URL}, cURL returned status ${OUTCOME}. Cheetah may not be started fully yet."
exit $OUTCOME
fi
@scottillogical
scottillogical / gist:7770886dd09cfbdefb0ac63b39501af0
Created November 21, 2018 20:34
detect rabbitmq missing bindings
#!/bin/bash
if [ -z "$RMQ_USERNAME" ]; then
echo "Error:RMQ_USERNAME was not set."
exit 1
fi
if [ -z "$RMQ_PASSWORD" ]; then
echo "Error:RMQ_PASSWORD was not set."
exit 1
fi
@scottillogical
scottillogical / rmq-queue-master-distribution.sh
Created November 6, 2018 21:43
show rabbitmq queue master distribution
for node in $(curl -s -u user:pass http://localhost:15672/api/nodes | jq '.[]' | jq -r '.name'); do echo $node; curl -s -u user:pass http://localhost:15672/api/queues | jq --arg NODE "$node" '.[] | select(.node | contains($NODE)) | .name ' | wc -l ; done
# OUTPT:
# rabbit@6f419d949cc1049ab273a09da19259fd
# 94
# rabbit@b164f368cc1ad8f64b54794f5fec955e
# 381
# rabbit@c5e18a7747eb7fbdd4f53b4b756557f2
# 9
@scottillogical
scottillogical / main.go
Last active May 1, 2018 19:33
golang subscribing to rmq queue created events
package main
import (
"fmt"
"log"
"github.com/streadway/amqp"
)
func failOnError(err error, msg string) {
@scottillogical
scottillogical / gist:03f1470e956b510e5517
Created September 5, 2014 15:25
Errorception reuqirejs
define(function() {
'use strict';
return {
load: function() {
var key = "KEYHERE";
window._errs = [key];
var c = window.onerror;
window.onerror = function() {
var a = arguments;
window._errs.push(a);
@scottillogical
scottillogical / spiral.rb
Last active December 27, 2015 02:59
Write a function that accepts four arguments. The first two arguments are the size of the grid (h x w), filled with ascending integers from left to right, top to bottom, starting from 1. The next two arguments are is the starting positions, the row (r) and column (c). Return an array of integers obtained by spiraling outward anti-clockwise from …
require 'matrix'
def spiral(height, width, start_row, start_col)
@results = []
i = 0
m = Matrix.build(height, width) do |row, col|
i+=1
end
start_row = x = start_row-1
start_col = y = start_col -1
distance = 1
@scottillogical
scottillogical / gist:5910235
Created July 2, 2013 15:23
Stop your 2010 15" macbook pro screen from going black
The bug is related to the discrete graphics card.
Specifically, chrome by default forces osx always to use the discrete graphics card. You can see this by using the tool GfxCardStatus.
Anwyays, to solve this, start chrome from the command line using a flag to force it to use the integrated card.
open -a /Applications/Google\ Chrome.app/ --args --gpu-switching=force_integrated
@scottillogical
scottillogical / gist:5760020
Last active December 18, 2015 09:18
Rails 4 ActiveModel::ForbiddenAttributesError
class ResourcesController < ApplicationController
def create
@resource = Resource.new(params[:resource])
respond_to do |format|
if @resource.save
format.html { redirect_to @resource.skill, notice: 'Resource was successfully created.' }
else
format.html { render @resource.skill }
end
if Rails.env.development?
LOG.sev_threshold = LOGGER::DEBUG
else
LOG.sev_threshold = LOGGER::INFO