Skip to content

Instantly share code, notes, and snippets.

Igor Skrynkovskyy h2rd

Block or report user

Report or block h2rd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@h2rd
h2rd / revert-a-commit.md
Created Apr 1, 2019 — forked from gunjanpatel/revert-a-commit.md
Git HowTo: revert a commit already pushed to a remote repository
View revert-a-commit.md

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}'

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

@h2rd
h2rd / copy.sh
Last active Oct 17, 2018
Copy keys from one redis to another
View copy.sh
source_host=localhost
source_port=6379
source_db=0
target_host=localhost
target_port=6379
target_db=1
#copy all keys without preserving ttl!
redis-cli -h $source_host -p $source_port -n $source_db keys * | while read key; do echo "Copying $key"; redis-cli --raw -h $source_host -p $source_port -n $source_db DUMP "$key" | head -c -1|redis-cli -x -h $target_host -p $target_port -n $target_db RESTORE "$key" 0; done
@h2rd
h2rd / schedule.rb
Created Oct 12, 2018 — forked from arteezy/schedule.rb
Template for Whenever + rbenv config
View schedule.rb
set :rbenv, '"$HOME/.rbenv/shims":"$HOME/.rbenv/bin"'
job_type :rake, 'cd :path && PATH=:rbenv:"$PATH" :environment_variable=:environment bundle exec rake :task --silent :output'
job_type :runner, 'cd :path && PATH=:rbenv:"$PATH" bin/rails runner -e :environment ":task" :output'
set :output, 'log/whenever.log'
@h2rd
h2rd / tiller-rbac-config.yaml
Created Aug 16, 2018
tiller rbac config kube 1.8+
View tiller-rbac-config.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: tiller
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: tiller
View vagrant
v () {
command="cd /vagrant; $@"
vagrant ssh -c $command
}
vb () {
command="cd /vagrant; bundle exec $@"
vagrant ssh -c $command
}
@h2rd
h2rd / git-change-commit-messages.md
Created Feb 21, 2018 — forked from nepsilon/git-change-commit-messages.md
How to change your commit messages in Git? — First published in fullweb.io issue #55
View git-change-commit-messages.md

How to change your commit messages in Git?

At some point you’ll find yourself in a situation where you need edit a commit message. That commit might already be pushed or not, be the most recent or burried below 10 other commits, but fear not, git has your back 🙂.

Not pushed + most recent commit:

git commit --amend

This will open your $EDITOR and let you change the message. Continue with your usual git push origin master.

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

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
View gist:ac68ec5ec2d4eadeeb45152136615bc2
## Useful Commands
Get kubectl version
kubectl version
Get cluster info:
@h2rd
h2rd / update-tags.md
Created Jan 5, 2018 — forked from alecsgone/update-tags.md
Update github tags with new commits
View update-tags.md
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 Nov 14, 2017 — forked from thiagooak/kill-rmq-connections.sh
kill ALL rabbitmq connections
View kill-rmq-connections.sh
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" }'
You can’t perform that action at this time.