Skip to content

Instantly share code, notes, and snippets.

View dwdraju's full-sized avatar

Raju Dawadi dwdraju

View GitHub Profile
@dwdraju
dwdraju / bash_strict_mode.md
Created November 3, 2023 01:15 — forked from vncsna/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation

set -e, -u, -o, -x pipefail

The set lines

  • These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
  • With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
  • set -euxo pipefail is short for:
set -e
set -u
@dwdraju
dwdraju / create-gce-instance.go
Created June 14, 2020 16:05 — forked from martinomburajr/create-gce-instance.go
How to create a Google Compute Engine Instance using REST calls in Golang.
func CreateGCEInstance() {
//STEP 1 - INIT DATA - Add all your initialization data e.g. projectid, zones, accessTokens.
project := "<your-project-here>"
zone := "<your-zone-here>" //e.g. europe-west1-d
accessToken := "" ////retrieve from https://developers.google.com/oauthplayground/ select relevant compute engine scopes e.g. devstorage/read_write and auth/compute
endpoint := fmt.Sprintf("https://www.googleapis.com/compute/v1/projects/%s/zones/%s/instances", project, zone)
//STEP 2 - REQUEST BODY
//Create a REST representation of whats required. see https://cloud.google.com/compute/docs/reference/rest/v1/instances/insert
reqBody := struct {
@dwdraju
dwdraju / SSL.md
Created May 30, 2020 12:15 — forked from gangsta/SSL.md
How to Setting Up a Comodo SSL Cert

How to Setting Up a Comodo SSL Cert

  • I advice you to buy SSL Certs from officially Comodo only , or some SSL reseller whose you trust.

These are the steps I went through to set up an SSL cert. Purchase the cert

Prior to purchasing a cert, you need to generate a private key, and a CSR file (Certificate Signing Request). You’ll be asked for the content of the CSR file when ordering the certificate:

openssl req -new -newkey rsa:2048 -nodes -keyout example_com.key -out example_com.csr
@dwdraju
dwdraju / curl.md
Created March 28, 2019 04:40 — forked from btoone/curl.md
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API.

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@dwdraju
dwdraju / speech_api.sh
Created September 13, 2018 09:49 — forked from bretmcg/speech_api.sh
Call the Google Cloud Speech API from command line
#!/bin/bash
# This is not an official Google product.
# Copyright 2016 Google Inc. 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
#
@dwdraju
dwdraju / .gitlab-ci.yml
Created August 13, 2018 16:14 — forked from jlis/.gitlab-ci.yml
AWS ECS and ECR deployment via Docker and Gitlab CI
image: docker:latest
variables:
REPOSITORY_URL: <AWS ACCOUNT ID>.dkr.ecr.eu-central-1.amazonaws.com/<ECS REPOSITORY NAME>
REGION: eu-central-1
TASK_DEFINTION_NAME: <TASK DEFINITION NAME>
CLUSTER_NAME: <CLUSTER NAME>
SERVICE_NAME: <SERVICE NAME>
services:
@dwdraju
dwdraju / http_get_request.go
Created May 5, 2018 06:36
golang http post request
package main
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
@dwdraju
dwdraju / .gitlab-ci.yml
Created March 9, 2018 12:08 — forked from foklepoint/.gitlab-ci.yml
Build and Push images to GCP Container Registry with Gitlab CI
image: docker:latest
# When using dind, it's wise to use the overlayfs driver for
# improved performance.
variables:
DOCKER_DRIVER: overlay
GCP_PROJECT_ID: CHANGE-TO-GCP-PROJECT-ID
IMAGE_NAME: image_id
services:
@dwdraju
dwdraju / haproxy_letsencrypt.md
Created January 20, 2018 10:32 — forked from lmmendes/haproxy_letsencrypt.md
# HAProxy and Let's Encrypt

HAProxy and Let's Encrypt

HAProxy is a open-source TCP/HTTP load-balancing proxy server supporting native SSL, keep-alive, compression CLI, and other modern features.

Let’s Encrypt is a free, automated, and open certificate authority (CA), run for the public’s benefit. Let’s Encrypt is a service provided by the Internet Security Research Group (ISRG).

Concept

@dwdraju
dwdraju / letsencrypt.go
Created January 19, 2018 17:48 — forked from nathan-osman/letsencrypt.go
Obtain a Let's Encrypt certificate from the ACME staging server using golang.org/x/crypto/acme
package main
import (
"context"
"crypto"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"