Skip to content

Instantly share code, notes, and snippets.

View hayderimran7's full-sized avatar

Imran Hayder hayderimran7

View GitHub Profile
@hayderimran7
hayderimran7 / groovy-create-user.md
Last active April 10, 2024 17:29
Jenkins Groovy enable security and create a user in groovy script

This is a snippet that will create a new user in jenkins and if security has been disabled , it will enable it :)

import jenkins.model.*
import hudson.security.*

def instance = Jenkins.getInstance()

def hudsonRealm = new HudsonPrivateSecurityRealm(false)
hudsonRealm.createAccount("MyUSERNAME","MyPASSWORD")
instance.setSecurityRealm(hudsonRealm)
@hayderimran7
hayderimran7 / EKS_RDS_VPC_Peering_script.sh
Last active January 8, 2024 04:59
VPC Peering Between EKS and RDS postgres
#!/bin/bash -xe
## Create a VPC Peering connection between EKS and RDS Postgres
echo """ run this script as:
./eks-rds-peering.sh
+ read -p 'Enter name of EKS Cluster: ' EKS_CLUSTER
Enter name of EKS Cluster: xolv-dev-cluster
+ EKS_VPC=eksctl-xolv-dev-cluster-cluster/VPC
+ EKS_PUBLIC_ROUTING_TABLE=eksctl-xolv-dev-cluster-cluster/PublicRouteTable
+ read -p 'Enter name of RDS: ' RDS_DB_NAME
Enter name of RDS: sfstackuat
@hayderimran7
hayderimran7 / iam_role_jq_jmesqmatching.md
Last active November 21, 2023 07:36
get IAM Role matching a name using jq and aws cli

Intro

To use aws cli, its common to invoke built-in features like --filters and --query however they aren't avaiable for all the commands.

for my use case i wanted to get a role matching a name, i.e. regex pattern . that was very easy using jq

one-liner to get Role ARN of a role macthing name

if i want to get a role matching name eksctl-dev-cluster-addon-iamserviceaccount then to get ARN of that role is simply doing

@hayderimran7
hayderimran7 / gist:9246dd195f785cf4783d
Created February 13, 2015 22:38
How to solve "sudo: no tty present and no askpass program specified" when trying to run a shell from Jenkins
Running shell scripts that have contain sudo commands in them from jenkins might not run as expected. To fix this, follow along
Simple steps:
1. On ubuntu based systems, run " $ sudo visudo "
2. this will open /etc/sudoers file.
3. If your jenkins user is already in that file, then modify to look like this:
jenkins ALL=(ALL) NOPASSWD: ALL
4. save the file by doing Ctrl+O (dont save in tmp file. save in /etc/sudoers, confirm overwrite)
5. Exit by doing Ctrl+X
6. Relaunch your jenkins job
@hayderimran7
hayderimran7 / disable.sh
Created April 6, 2023 05:20 — forked from mtunjic/disable.sh
Disable bunch of #$!@ in Catalina
#!/bin/bash
# IMPORTANT: Don't forget to logout from your Apple ID in the settings before running it!
# IMPORTANT: You will need to run this script from Recovery. In fact, macOS Catalina brings read-only filesystem which prevent this script from working from the main OS.
# This script needs to be run from the volume you wish to use.
# E.g. run it like this: cd /Volumes/Macintosh\ HD && sh /Volumes/Macintosh\ HD/Users/sabri/Desktop/disable.sh
# WARNING: It might disable things that you may not like. Please double check the services in the TODISABLE vars.
# Get active services: launchctl list | grep -v "\-\t0"
# Find a service: grep -lR [service] /System/Library/Launch* /Library/Launch* ~/Library/LaunchAgents
@hayderimran7
hayderimran7 / python-regex.md
Created April 2, 2023 18:49
python regexes

python regex

chap1 : intro to regex

  • regex: Regular expressions are text patterns that define the form a text string should have.
    • useful for email checking patern
    • matching word "color" and "colour"
    • extra specific info like postal code LOL: "Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems."
@hayderimran7
hayderimran7 / Linux.md
Created April 2, 2023 18:48 — forked from borg-z/Linux.md
My linux snippets for RHCSA

AWK

Get users with uid > 1000

awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534) print $1}' /etc/passwd

Grep

Links:

@hayderimran7
hayderimran7 / admin_sys.md
Created April 2, 2023 18:38 — forked from raphaellarrinaga/admin_sys.md
Bash & admin sys commands

get ocid

/(ocid.*([a-z 0-9]{60})+)/

get part after ocid

/[a-z 0-9]{60}\.(.*)/
@hayderimran7
hayderimran7 / oci-cli-query-examples.md
Created March 31, 2023 18:05
OCI CLI filter results with query

"geting all policies in given tenancy with no freeform tags

policies=$(oci --profile BOAT-OC1 iam policy list --all -c $C --query 'data[?length("freeform-tags")==`0`].name'| jq -r "@sh" )

find number of total policies in compartment

oci --profile BOAT-OC1 iam policy list --all -c $C --query 'data.length(@)'

get list of all compartments