Skip to content

Instantly share code, notes, and snippets.

@Tharwat96
Tharwat96 / git useful commands.sh
Last active September 3, 2020 10:27
git scripts
# sort all branches in repository by date updated
git for-each-ref --sort=committerdate refs/heads/ --format="%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))" --no-merged=origin/HEAD refs/remotes/origin
@Tharwat96
Tharwat96 / create_users.groovy
Last active November 9, 2020 09:50
Jenkins Useful Groovy Scripts
import hudson.model.*
import hudson.security.*
import hudson.tasks.Mailer
def userId = args[0]
def password = args[1]
def email = args[2]
def instance = jenkins.model.Jenkins.instance
def existingUser = instance.securityRealm.allUsers.find {it.id == userId}
@Tharwat96
Tharwat96 / aws_commands.sh
Last active September 6, 2020 10:04
aws cli useful commands
# describe ec2 instance
aws ec2 --region us-east-1 describe-instances --instance-ids i-xxxxxxxxxxx
# associate iam instance profile to running instance
aws ec2 associate-iam-instance-profile --instance-id i-xxxxxxxxxxx --iam-instance-profile Name=xxxxxxxxx
@Tharwat96
Tharwat96 / git.sh
Created November 23, 2020 03:14
git commands
# delete last commit without losing changes
git reset HEAD^