Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
"log"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/elasticbeanstalk"
"github.com/aws/aws-sdk-go/service/elbv2"
)
@niski84
niski84 / gist:5d9d6760ae9cba9fb37755d8af874704
Created April 23, 2024 21:58
forcefully detach ebs from ec2
package main
import (
"context"
"fmt"
"log"
"strings"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
@niski84
niski84 / gist:431e10f4d86c8089cac23fd6e9bb45ff
Created April 23, 2024 20:51
Delete all ec2's ebs volume and snapshots with option to save last snapshot
package main
import (
"context"
"fmt"
"log"
"sort"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
@niski84
niski84 / gist:1568adae441c5bf4ae4804e677ed3255
Last active December 12, 2023 17:56
collect input and pass to func
package main
import (
"fmt"
"os"
"strings"
"flag"
)
type Input struct {
@niski84
niski84 / gist:b0ae7d536ea9323c587f66fa4020e8f6
Created November 28, 2023 19:36
jira server using http basic
package main
import (
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
@niski84
niski84 / gist:d0a9c61b44c10b11540aee15a6fbdc5e
Last active November 9, 2023 01:29
custom html parsing for health check report
package main
import (
"bytes"
"fmt"
"golang.org/x/net/html"
"strings"
)
@niski84
niski84 / gist:22043ba2bcee79e0ce32c0cb26fa9ade
Last active September 16, 2023 02:36
detect screen saver running on windows package
// Package screensaver provides functions for detecting screensaver status on Windows.
package screensaver
import (
"syscall"
"unsafe"
)
// import user32.dll
var (
@niski84
niski84 / gist:f3263e0f18d16aba5cf4fa59f0a03d91
Last active September 14, 2023 01:54
discover if 7z installed on windows
// Find7zLocation checks for the existence of the 7z executable and returns its path and version.
func Find7zLocation() (string, string, error) {
// Check if 7z is in the PATH
path, err := exec.LookPath("7z")
if err == nil {
// Run '7z i' to get version information
cmd := exec.Command(path, "i")
output, err := cmd.CombinedOutput()
if err != nil {
package main
import "testing"
func TestCreateRDSSnapshot(t *testing.T) {
tests := []struct {
input CreateSnapshotInput
expect bool
}{
{CreateSnapshotInput{DBIdentifier: "mydbinstance"}, true},