Skip to content

Instantly share code, notes, and snippets.

View zerefwayne's full-sized avatar

Aayush Joglekar zerefwayne

View GitHub Profile
@zerefwayne
zerefwayne / spotify-auth.go
Created June 4, 2023 16:03
Script to get user access token for spotify
package main
import (
"encoding/base64"
"fmt"
"io/ioutil"
"log"
"math/rand"
"net/http"
"net/url"
@zerefwayne
zerefwayne / binary_search.cpp
Last active June 22, 2021 06:21
Algorithms C++
int search(vector<int>& nums, int target) {
int l = 0;
int r = nums.size() - 1;
int m;
while(l <= r) {
m = l + (r-l)/2;
if(nums[m] == target) {
return m;
}
if(nums[m] < target) {
user nginx;
# can handle 1000 concurrent connections
events {
worker_connections 1000;
}
# forwards http requests
http {
# http server
server {
# listens the requests coming on port 80
version: '3.3'
#services describe the containers that will start
services:
# api is the container name for our Go API
api:
# It will look for a dockerfile in the project root and build it
build: "."
# Exposes the port 5000 from a container and binds it to a random port
ports:
version: '3.3'
#services describe the containers that will start
services:
# api is the container name for our Go API
api:
# It will look for a dockerfile in the project root and build it
build: "."
# Exposes the port 5000 from a container and binds it to a random port
ports:
- "5000:5000"
@zerefwayne
zerefwayne / Dockerfile
Last active June 17, 2020 17:45
load-balancing-go-api-nginx
# Base image for building the go project
FROM golang:1.14-alpine AS build
# Updates the repository and installs git
RUN apk update && apk upgrade && \
apk add --no-cache git
# Switches to /tmp/app as the working directory, similar to 'cd'
WORKDIR /tmp/app
@zerefwayne
zerefwayne / main.go
Last active June 17, 2020 16:15
load-balancing-go-api-nginx
package main
import (
"fmt"
"log"
"net/http"
)
// handleHello GET /hello
func handleHello(w http.ResponseWriter, r *http.Request) {
// Node defines the basic building of the binary tree
type Node struct {
// Data data for the node
Data interface{}
// Defines the sleep time during processing to simulate delay
Sleep time.Duration
// Left Child
Left *Node
// Right Child
Right *Node
@zerefwayne
zerefwayne / generate-https-certificates.sh
Created May 10, 2020 06:47
Generate certificates for HTTPS
openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr
cp server.key server.key.org
openssl rsa -in server.key.org -out server.key
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose && docker-compose --version