Skip to content

Instantly share code, notes, and snippets.

View h2rd's full-sized avatar

Igor Skrynkovskyy h2rd

View GitHub Profile
@h2rd
h2rd / sidekiq_delete_jobs.md
Created February 19, 2018 15:15 — forked from eparreno/sidekiq_delete_jobs.md
How to delete Sidekiq jobs in a Rails app using ActiveJobs

How to delete Sidekiq jobs in a Rails app using ActiveJobs

Sidekiq jobs can be enqueued or scheduled. Enqueued means that they are gonna be picked up as soon as possible, scheduled jobs will be enqueued at some specific time.

job_id and jid

When using ActiveJobs, Rails will return a job_id after sending the job to ActiveJobs

job = UserMailer.send_invite(params).deliver_later
## Useful Commands
Get kubectl version
kubectl version
Get cluster info:
@h2rd
h2rd / update-tags.md
Created January 5, 2018 16:13 — forked from alexrqs/update-tags.md
Update github tags with new commits
Create a branch with the tag
	git branch {tagname}-branch {tagname}
	git checkout {tagname}-branch
Include the fix manually if it's just a change ....
	git add .
	git ci -m "Fix included" # or cherry-pick the commit, whatever is easier
	git cherry-pick {num_commit}
@h2rd
h2rd / kill-rmq-connections.sh
Created November 14, 2017 13:45 — forked from thiagooak/kill-rmq-connections.sh
kill ALL rabbitmq connections
rabbitmqctl list_connections pid port state user vhost recv_cnt send_cnt send_pend name | awk '{print "rabbitmqctl close_connection \"" $1 "\" \"manually closing idle connection\"" | "/bin/bash" }'
@h2rd
h2rd / create-registry-secret.sh
Created September 17, 2017 23:55 — forked from olalonde/create-registry-secret.sh
Create a registry secret in Kubernetes
#!/bin/bash
rm /tmp/image-pull-secret.yaml
login_cmd=$(aws ecr get-login)
username=$(echo $login_cmd | cut -d " " -f 4)
password=$(echo $login_cmd | cut -d " " -f 6)
endpoint=$(echo $login_cmd | cut -d " " -f 9)
auth=$(echo "$username:$password" | /usr/bin/base64)
configjson="{ \"auths\": { \"${endpoint}\": { \"auth\": \"${auth}\" } } }"
@h2rd
h2rd / cors-nginx.conf
Created September 3, 2017 20:35 — forked from alexjs/cors-nginx.conf
Slightly tighter CORS config for nginx
#
# Slightly tighter CORS config for nginx
#
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs
#
# Despite the W3C guidance suggesting that a list of origins can be passed as part of
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox)
# don't seem to play nicely with this.
#
FROM ubuntu:latest
ADD start.sh /bin/start.sh
RUN chmod +x /bin/start.sh
# Add crontab file in the cron directory
ADD crontab /etc/cron.d/thecron
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/thecron
#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs docker rmi --force
# remove unused volumes:
find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
docker ps --all | tail -n +2 | awk '{print $1}' | xargs docker rm
@h2rd
h2rd / HaversinFormula.go
Created July 27, 2017 22:16 — forked from cdipaolo/HaversinFormula.go
Golang functions to calculate the distance in meters between long,lat points on Earth.
// haversin(θ) function
func hsin(theta float64) float64 {
return math.Pow(math.Sin(theta/2), 2)
}
// Distance function returns the distance (in meters) between two points of
// a given longitude and latitude relatively accurately (using a spherical
// approximation of the Earth) through the Haversin Distance Formula for
// great arc distance on a sphere with accuracy for small distances
//