Skip to content

Instantly share code, notes, and snippets.

@gaurish
gaurish / winrm_utils_v2.py
Last active August 6, 2025 05:03
Improved WinRM utilities with better error handling and syntax fixes
#!/usr/bin/env python3
"""
Improved WinRM utilities with better error handling and syntax fixes
"""
import winrm
import base64
import json
from typing import Dict, List, Optional, Tuple, Any
import time
import re
@gaurish
gaurish / Dockerfile
Last active March 7, 2023 17:29
Sample App to show how to use SSL / Secure connection to connect to AWS RDS using Python
FROM python:3
WORKDIR /usr/src/app
ADD https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem .
ARG DATABASE_URL
ENV DATABASE_URL=$DATABASE_URL
COPY requirements.txt ./
RUN pip install mysql-connector-python
ADD mysql_connect.py .
CMD [ "python", "./mysql_connect.py" ]
#!/bin/bash
shopt -s extdebug
function mothership2() {
CLUSTER=punchh-prod-2
PROFILE=mothership
REGION=us-west-2
NAMESPACE=mothership2
}
function service() {
@gaurish
gaurish / Versions
Last active April 3, 2021 20:09
write:errno=0 SSL api.push.apple.com
# openssl version
OpenSSL 1.1.1d 10 Sep 2019
# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster
# Running on Docker.
@gaurish
gaurish / scaler.py
Created August 7, 2020 02:07
Scale down all services in a ECS cluster.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import boto3
from pprint import pprint
ecs_cluster = 'my_cluster_mame'
client = boto3.client('ecs', region_name='us-east-1')

Keybase proof

I hereby claim:

  • I am gaurish on github.
  • I am gaurish (https://keybase.io/gaurish) on keybase.
  • I have a public key ASDUFHFszCkZizcKi-nfGolA-dO41pobZ0jueNi9EnPQYwo

To claim this, I am signing this object:

@gaurish
gaurish / redisinfo.go
Created February 2, 2018 10:34
Redis Info as JSON over HTTP powered by Go
package main
import (
"encoding/json"
"log"
"net/http"
"os"
"strings"
"fmt"
#!/bin/bash
yum update -y
yum install httpd24 -y
service httpd start
chkconfig httpd on
EC2_AVAIL_ZONE=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone`
INSTANCE_ID=`curl -s http://169.254.169.254/latest/meta-data/instance-id/`
echo "<html><body><h1>Hello, this is Instance ID
${INSTANCE_ID} located in ${EC2_AVAIL_ZONE}</h1></body></html>" > /var/www/html/index.html
@gaurish
gaurish / redisinfo.go
Created March 20, 2017 21:46
Returns redis memory info as JSON over HTTP for monitoring
package main
import (
"encoding/json"
"log"
"net/http"
"os"
"strings"
"fmt"
, [2017-01-01T19:03:35.482568 #8908] INFO -- default-ubuntu-1404: -----> Creating <default-ubuntu-1404>...
I, [2017-01-01T19:03:37.537206 #8908] INFO -- default-ubuntu-1404: Bringing machine 'default' up with 'virtualbox' provider...
I, [2017-01-01T19:03:37.985949 #8908] INFO -- default-ubuntu-1404: ==> default: Importing base box 'bento/ubuntu-14.04'...
I, [2017-01-01T19:03:47.400931 #8908] INFO -- default-ubuntu-1404: ^MProgress: 20%^MProgress: 30%^MProgress: 40%^MProgress: 50%^MProgress: 60%^MProgress: 70%^MProgress: 80%^MProgress: 90%^M==> default: Matching MAC address for NAT networking...
I, [2017-01-01T19:03:47.541321 #8908] INFO -- default-ubuntu-1404: ==> default: Checking if box 'bento/ubuntu-14.04' is up to date...
I, [2017-01-01T19:03:52.775636 #8908] INFO -- default-ubuntu-1404: ==> default: A newer version of the box 'bento/ubuntu-14.04' is available! You currently
I, [2017-01-01T19:03:52.775702 #8908] INFO -- default-ubuntu-1404: ==> default: have version '2.2.7'. The latest is version '