Skip to content

Instantly share code, notes, and snippets.

@Segmentational
Segmentational / .gitlab-ci.yml
Last active January 25, 2025 02:22
Go, Cobra, CLI, Homebrew, Makefile, GitLab, Go-Releaser
stages:
- Testing
- Version
- Build
- Registry
Unit-Tests:
stage: Testing
image: golang:1.22-alpine
script:
@Segmentational
Segmentational / Makefile
Created January 24, 2025 21:47
Generic GO Build Makefile
#!/usr/bin/env make
Name := example
Remotes = $(shell git remote -v 2>/dev/null | xargs printf)
Dirty = $(shell git diff --shortstat 2>/dev/null 2>/dev/null | tail -n1)
Version = $(shell [ -f VERSION ] && head VERSION || echo "0.0.0")
@Segmentational
Segmentational / main.go
Created August 13, 2024 08:15
Go HTTP Proxy
package main
import (
"fmt"
"log"
"net/http"
"net/http/httputil"
"net/url"
"strings"
"time"
// Package namesgenerator generates random names.
//
// This package is officially "frozen" - no new additions will be accepted.
//
// For a long time, this package provided a lot of joy within the project, but
// at some point the conflicts of opinion became greater than the added joy.
//
// At some future time, this may be replaced with something that sparks less
// controversy, but for now it will remain as-is.
//
@Segmentational
Segmentational / Deployment.yaml
Created February 25, 2024 01:50
Kubernetes Deployment Downward API Environment Variables
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-deployment
labels:
name: api-deployment
spec:
replicas: 2
selector:
@Segmentational
Segmentational / Dockerfile
Last active February 18, 2024 23:29
Optimized GO HTTP Server Dockerfile - Kubernetes, Private VCS Compatible
# syntax = docker/dockerfile:1.0-experimental
FROM golang:1.22-alpine as BUILD
# ARG NETRCPASSWORD
# ENV NETRCPASSWORD "${NETRCPASSWORD}"
# ENV GOPRIVATE "github.com/example/*"
ENV GOOS "linux"
ENV GOVCS "*:all"
@Segmentational
Segmentational / main.go
Created December 18, 2023 08:59 — forked from creack/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"strconv"
@Segmentational
Segmentational / Security.Bash
Created August 2, 2023 20:12
Fedora, CentOS, Security Update Script
#!/bin/bash --posix
# -*- Coding: UTF-8 -*- #
# -*- System: Linux -*- #
# -*- Usage: *.* -*- #
# See Bash Set-Options Reference Below
set -euo pipefail # (0)
set -o xtrace # (6)
@Segmentational
Segmentational / Template.Bash
Created August 2, 2023 19:59
Default Bash Template, Personal
#!/bin/bash --posix
# -*- Coding: UTF-8 -*- #
# -*- System: Linux -*- #
# -*- Usage: *.* -*- #
# Author: Jacob Sanders (GitHub - Segmentational)
# See Bash Set-Options Reference Below
@Segmentational
Segmentational / clean.bash
Created November 10, 2022 17:46
Node Directory + JS Clean-Up
find . -name "node_modules" -type "d" -exec "rm -rf {} || true" \;
find . -name "*.js" -type "f" -exec rm -f {} \;
find . -name "*.js.map" -type "f" -exec rm -f {} \;
find . -name "*.d.ts" -type "f" -exec rm -f {} \;
find . -name "*.ts.map" -type "f" -exec rm -f {} \;
find . -name "*.d.ts.map" -type "f" -exec rm -f {} \;