Skip to content

Instantly share code, notes, and snippets.

View nilesh-akhade's full-sized avatar

Nilesh Akhade nilesh-akhade

View GitHub Profile
@nilesh-akhade
nilesh-akhade / main.go
Created April 8, 2022 10:16
Write a program that runs a TCP service to reverse a string
package main
import (
"bufio"
"fmt"
"net"
"os"
"strings"
)
@nilesh-akhade
nilesh-akhade / my-auto-theme
Last active May 11, 2022 04:41
Script that auto switches VSCode and Ubuntu themes to Dark or Light mode
#!/bin/bash
# Script that auto switches VSCode and Ubuntu themes to Dark or Light
# depending on time of day
# Copy this file to /usr/local/bin/my-auto-theme
# Add following lines to crontab -e
# 0 9 * * * bash /usr/bin/local/my-auto-theme light
# 0 17 * * * bash /usr/bin/local/my-auto-theme dark
# @reboot bash /usr/bin/local/my-auto-theme

Provider Free Storage $/TB/mo Koofr 10 GB €10/mo JioCloud 2 GB NA Amazon Drive 5 GB $ 6.99/mo $59.99/yr Amazon S3 5 GB Depends Adobe Document Cloud 2 GB NA Provider Free Storage From $/TB/mo Cheapest $/TB Encrypted? Terabox 1024 GB No paid plans available No paid plans available No information available Keybase 250 GB No paid plans available No paid plans available Encrypted Storj 150 GB $4/mo + BW $4/mo + BW Encrypted

@nilesh-akhade
nilesh-akhade / BEFORE.md
Created July 25, 2022 09:56
docker build layer cache

Change in COMMIT_SHA invalidates cache

Change in env variable value affects layer cache of all the instructions that comes after ENV.

$ cat Dockerfile
FROM alpine
ARG COMMIT_SHA
ENV COMMIT_SHA ${COMMIT_SHA}
RUN apk add --no-cache curl
@nilesh-akhade
nilesh-akhade / main.go
Last active July 29, 2022 06:22
Go custom error handling example
package main
import (
"errors"
"fmt"
)
var MyCustomError *ErrCustom
type ErrCustom struct{}
@nilesh-akhade
nilesh-akhade / main.go
Created September 5, 2022 13:15
Golang - Read JSON with leading white spaces or invalid characters
package main
import (
"bufio"
"encoding/json"
"fmt"
"io"
"log"
"strings"
)
@nilesh-akhade
nilesh-akhade / pdfsizereducer.sh
Created September 6, 2022 07:47
Reduces file size of PDF files using ghostscript and pdfcpu
#!/bin/bash
infile=$1
if [[ -z $2 ]]; then
expsz_kb=120
else
expsz_kb=$2
fi
expsz=$((expsz_kb*1000))
file_size=$(stat -c%s "$infile")
@nilesh-akhade
nilesh-akhade / OWASP_Kuberneres.md
Created September 13, 2022 10:10
Attempt to map OWASP Top10 security risks with Aqua's Trivy Scanner

OWASP to Trivy Checks Mapping

  • OWASP#1 Insecure Workload Configurations

    • Trivy checks - KSV001, KSV014, KSV017
  • OWASP#2 Supply Chain Vulnerabilities

    • Manual - Image Integrity
    • Manual - SBOM
    • Manual - Image Signing
  • Manual - Image Composition

@nilesh-akhade
nilesh-akhade / main.go
Last active September 22, 2022 06:35
Implement an iterator to retrieve Baskets and Bouquets from Plucker. The Plucker is an iterator which returns either Flower or Fruit from `orchard.json`
package main
import "fmt"
type Iterator interface {
Next() interface{}
HasNext() bool
}
type Flower struct {
@nilesh-akhade
nilesh-akhade / main.go
Created January 5, 2023 12:47
Unmarshal logs marshaled by `logrus.TextFormatter`
package main
import (
"encoding/json"
"fmt"
"regexp"
)
func main() {
s := `time="2022-12-29T14:42:24Z" level=info msg="starting \"n=ew\" restore" logSource='pkg/co=ntroller/restore_controller.go:478' restore=velero/test-13`