Skip to content

Instantly share code, notes, and snippets.

View atc0005's full-sized avatar

Adam Chalkley atc0005

View GitHub Profile
package main
import (
"fmt"
"github.com/vmware/govmomi"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/types"
"net/url"
)
@atc0005
atc0005 / http_get.go
Created June 30, 2023 21:08 — forked from mobleyc/http_get.go
Creating a custom HTTP Transport and Client with Go
package main
import (
"fmt"
"io/ioutil"
"net"
"net/http"
"os"
"time"
)
@atc0005
atc0005 / unique elements in a slice
Created June 23, 2023 12:10 — forked from johnwesonga/unique elements in a slice
Go code that ensures elements in a slice are unique
package main
import "fmt"
func uniqueNonEmptyElementsOf(s []string) []string {
unique := make(map[string]bool, len(s))
us := make([]string, len(unique))
for _, elem := range s {
if len(elem) != 0 {
if !unique[elem] {
@atc0005
atc0005 / local-ruby-gem.md
Created November 17, 2022 22:31 — forked from zulhfreelancer/local-ruby-gem.md
How to use a local Ruby gem in Rails project?

Situation

You are working on a Rails app that uses a gem named abc. This gem is hosted on RubyGems and the source code of the gem is available at https://github.com/your-username/abc.

You created a new branch locally for your gem (new-feature). You wanted to modify the gem and load it directly to your local Rails app. And, you don't want to push the gem changes to GitHub and publish the gem to RubyGems just yet.

You want all the changes that you made in your local gem directory get reflected immediately in your local Rails app without requiring you to run gem build and gem install command in the gem's local directory.

Steps

@atc0005
atc0005 / main.go
Created August 29, 2022 16:14 — forked from andrewsomething/main.go
Report download statistics for GitHub release assets
package main
import (
"context"
"encoding/json"
"flag"
"fmt"
"os"
"strings"
"text/tabwriter"
@atc0005
atc0005 / main.go
Created July 26, 2022 20:25 — forked from StarBuckR/main.go
Golang Ldap Authentication, Bind and Search, including Anonymous Bind
package main
import (
"fmt"
"log"
"github.com/go-ldap/ldap/v3"
)
const (
@atc0005
atc0005 / openssl_commands.md
Created February 16, 2022 22:42 — forked from p3t3r67x0/openssl_commands.md
Some list of openssl commands for check and verify your keys

openssl

Install

Install the OpenSSL on Debian based systems

sudo apt-get install openssl
@atc0005
atc0005 / curl_post_json.md
Created April 8, 2020 15:35 — forked from ungoldman/curl_post_json.md
post a JSON file with curl

How do you POST a JSON file with curl??

You can post a json file with curl like so:

curl -X POST -H "Content-Type: application/json" -d @FILENAME DESTINATION

so for example:

package main
import (
"encoding/json"
"io/ioutil"
"net/http"
"os"
"regexp"
"time"
)
@atc0005
atc0005 / Makefile
Created October 17, 2019 17:55 — forked from TheHippo/Makefile
Golang Makefile example
OUT := binariy-name
PKG := gitlab.com/group/project
VERSION := $(shell git describe --always --long --dirty)
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/)
GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/)
all: run
server:
go build -i -v -o ${OUT} -ldflags="-X main.version=${VERSION}" ${PKG}