Skip to content

Instantly share code, notes, and snippets.

View joshm1's full-sized avatar

Josh McDade joshm1

  • SpaceIQ
  • North Carolina
View GitHub Profile
@joshm1
joshm1 / keybase.md
Last active June 25, 2019 14:57
keybase.md

Keybase proof

I hereby claim:

  • I am joshm1 on github.
  • I am joshmcdade (https://keybase.io/joshmcdade) on keybase.
  • I have a public key ASDPuXEtG-MBuB_2sB9bytedLzvTmZxl-eeeAxBYRO_b4wo

To claim this, I am signing this object:

@joshm1
joshm1 / fs2-kafka.scala
Created July 27, 2018 21:56
Playing with fs2, cats-effect, fs2-kafka
package com.spaceiq.spaceplanning
import java.nio.channels.AsynchronousChannelGroup
import java.nio.charset.Charset
import java.time.{Instant, ZoneOffset}
import java.time.format.DateTimeFormatter
import java.util.Formatter.DateTime
import java.util.concurrent.{Executors, TimeUnit}
import cats.effect.{Effect, IO, Sync}
@joshm1
joshm1 / ec2_terminate.sh
Created April 21, 2017 15:30
bash function to delete ec2 instances based on private DNS names
ec2_terminate() {
local private_dns_name=$1
local instance_ids=$(aws ec2 describe-instances \
--filters "Name=private-dns-name,Values=$private_dns_name" | \
jq '.Reservations | .[] | .Instances | .[] | .InstanceId' -r | tr '\n' ' ')
if [ -z $instance_ids ]; then
echo "instances not found for $private_dns_name"
exit 1
fi
SALT_MASTER='172.20.0.9'
DOCKER_OPTS=''
readonly DOCKER_STORAGE='aufs'
apt-get update
apt-get install --yes curl
download-or-bust() {
@joshm1
joshm1 / unregister-scale-resque-workers.rb
Created March 10, 2016 15:06
Unregister stale resque workers
Resque.workers.each do |w|
matches = w.id.match(/^[^:]*:([0-9]*):[^:]*$/)
pid = matches[1]
is_real = w.worker_pids.include?(pid.to_s)
unless is_real
puts "unregister_worker pid=#{pid}"
w.unregister_worker
end
end; nil
@joshm1
joshm1 / gist:2b87310ed336abd927fd
Created November 23, 2015 15:47
kubernetes-master salt failing to update kubelet manifests
root@ip-172-20-0-9:/srv/salt# sudo salt --force-color '*' state.highstate
ip-172-20-0-9.ec2.internal:
----------
ID: pkg-core
Function: pkg.installed
Name: glusterfs-client
Result: True
Comment: Package glusterfs-client is already installed.
Started: 15:42:01.494523
Duration: 1920.381 ms
@joshm1
joshm1 / jenkins.yaml
Created November 2, 2015 15:15
kubernetes jenkins rc and svc
---
apiVersion: v1
kind: Service
metadata:
name: jenkins
spec:
type: LoadBalancer
selector:
name: jenkins
ports:
Aug 24 15:59:33 ip-172-20-0-9 systemd[1]: Started docker container 15e1dabe21b731e177819feeab296c35fb19cfa384ed5facb01bfae9fbaa52b8.
Aug 24 15:59:33 ip-172-20-0-9 systemd[1]: Starting docker container 15e1dabe21b731e177819feeab296c35fb19cfa384ed5facb01bfae9fbaa52b8.
Aug 24 15:59:33 ip-172-20-0-9 docker[1078]: time="2015-08-24T15:59:33.795669111Z" level=error msg="Handler for POST /containers/{name:.*}/start returned error: Cannot start container ff93b837c8aaa05d02853269d59de39fbf5c20c39d2019621e4256b79dbbe636: [8] System error: open /sys/fs/cgroup/cpu,cpuacct/system/system.slice/docker-ff93b837c8aaa05d02853269d59de39fbf5c20c39d2019621e4256b79dbbe636.scope/cpu.shares: no such file or directory"
Aug 24 15:59:33 ip-172-20-0-9 docker[1078]: time="2015-08-24T15:59:33.795735895Z" level=error msg="HTTP Error" err="Cannot start container ff93b837c8aaa05d02853269d59de39fbf5c20c39d2019621e4256b79dbbe636: [8] System error: open /sys/fs/cgroup/cpu,cpuacct/system/system.slice/docker-ff93b837c8aaa05d02853269d59de39fbf5c20c
@joshm1
joshm1 / gist:1615d75925dcdb3bc23e
Created November 20, 2014 20:08
Scala Play compiler error on Twirl template
Information:Compilation completed with 2 errors and 2 warnings in 34 sec
Information:2 errors
Information:2 warnings
Error:scalac:
while compiling: /my-project/modules/common/target/scala-2.10/twirl/main/views/html/error/notFound.template.scala
during phase: jvm
library version: version 2.10.4
compiler version: version 2.10.4
reconstructed args: -nobootcp -javabootclasspath : -deprecation -language:experimental.macros -classpath /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/lib/tools.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Co
@joshm1
joshm1 / symbolize_keys.rb
Created February 3, 2014 16:06
simple symbolize_keys alternative without ActiveSupport
# recursively symolizes keys in a Hash that are strings
# does not modify the original hash; returns a new hash
def symbolize_keys(hash)
hash.to_a.reduce({}) do |acc, (key, val)|
val = symbolize_keys(val) if val.is_a?(Hash)
key = key.to_sym if key.is_a?(String)
acc[key] = val
acc
end
end