Skip to content

Instantly share code, notes, and snippets.

View Hardeep18's full-sized avatar
🚀
Focusing

Hardeep Hardeep18

🚀
Focusing
View GitHub Profile
@Hardeep18
Hardeep18 / ec2.py
Created February 13, 2020 14:00 — forked from mprabhuram/ec2.py
EC2 automation with Python library Boto - Part1
# Script to automate EC2 with python
import boto
import time
#set the environment variables in the command line:
# export AWS_ACCESS_KEY_ID=< Your AWS Access Key ID >
# export AWS_SECRET_ACCESS_KEY=< Your AWS Secret Access Key
@Hardeep18
Hardeep18 / create-ssh-node.sh
Created February 8, 2020 12:21 — forked from Evildethow/create-ssh-node.sh
Jenkins: Create SSH node, using bash and curl
#!/usr/bin/env bash
set -o nounset -o errexit -o pipefail
usage() {
cat <<EOM
Usage:
$(basename $0) [OPTIONS]
$(basename $0) [ -j | --jenkins-url | -n | --node-name | -s | -d | --desc | --slave-home | -e | --executors | -sh | --ssh-host | -sp | --ssh-port
| -c | --cred-id | -l | --labels | -u | --user-id | -p | --password | -h | --help ]
# check if job exists
curl -XGET 'http://jenkins/checkJobName?value=yourJobFolderName' --user user.name:YourAPIToken
# with folder plugin
curl -s -XPOST 'http://jenkins/job/FolderName/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# without folder plugin
curl -s -XPOST 'http://jenkins/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# create folder
@Hardeep18
Hardeep18 / local_hab_workstation.md
Created September 17, 2019 13:13 — forked from smford22/local_hab_workstation.md
Local Habitat Windows Workstation for Mac OS X with Vagrant and VirtualBox

Local Habitat Windows Workstation for Mac OS X with Vagrant and VirtualBox

The following document describes how to setup a Mac OS X workstation for developing Habitat Packages for Windows using Vagrant and VirtualBox

Software Tools Prereqs:

Before you begin you should have the following tools installed on your Mac workstation:

  • Vagrant
  • VirtualBox
  • vagrant-reload plugin - Open a terminal and run the command vagrant plugin install vagrant-reload
@Hardeep18
Hardeep18 / prometheus.md
Created May 2, 2019 02:38 — forked from ipeacocks/prometheus.md
Prometheus 2.x installation on Ubuntu 16.04 server.

Installing Prometheus on Ubuntu 16.04

This gist is a compilation of two tutorials. You can find the original tutorials here and here. What should you know before using this? Everything can be executed from the home folder. For easier cleanup at the end you can make directory where you'll download everything, and then just use rm -rf .. Although, you should be careful. If some strange bugs arise unexpectedly somewhere sometimes, just keep in mind that some user names have underscores in them (this is probably nothing to worry about).

Create Users

sudo adduser --no-create-home --disabled-login --shell /bin/false --gecos "Prometheus Monitoring User" prometheus
sudo adduser --no-create-home --disabled-login --shell /bin/false --gecos "Node Exporter User" node_exporter
sudo adduser --no-create-home --disabled-login --shell /bin/false --gecos "Alertm
@Hardeep18
Hardeep18 / postgres-cheatsheet.md
Created March 14, 2019 05:53 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@Hardeep18
Hardeep18 / s3-public-bucket-policy.json
Created March 12, 2019 06:52 — forked from ScottPhillips/s3-public-bucket-policy.json
Amazon S3 Bucket Policy : Restrict Access to Specific Referer
{
"Version":"2008-10-17",
"Id":"http referer policy example",
"Statement":[
{
"Sid":"Allow get requests referred by www.mysite.com and mysite.com",
"Effect":"Allow",
"Principal":"*",
"Action":"s3:GetObject",
"Resource":"arn:aws:s3:::YOUR_S3_BUCKET_NAME/*",
/* Space out content a bit */
body {
padding-top: 20px;
padding-bottom: 20px;
}
/* Everything but the jumbotron gets side spacing for mobile first views */
.header,
.marketing,
.footer {
@Hardeep18
Hardeep18 / docker-registry-clean.sh
Created January 25, 2019 14:51 — forked from qoomon/docker-registry-clean.sh
Docker Registry v2 / Remove orphan layers left by the "file" storage backend of the docker registry, heavily inspired by https://gist.github.com/shepmaster/53939af82a51e3aa0cd6
#!/bin/sh
base_dir=/var/lib/registry/docker/registry/v2
repository_dir=$base_dir/repositories
image_dir=$base_dir/blobs
output_dir=$(mktemp -d)
all_images=$output_dir/all
used_images=$output_dir/used
#!/bin/bash
# Copyright 2015 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#