Skip to content

Instantly share code, notes, and snippets.

View Tee-Stark's full-sized avatar
🌩️
learning Cloud & DevOps

Timmy Omolana Tee-Stark

🌩️
learning Cloud & DevOps
View GitHub Profile
@Tee-Stark
Tee-Stark / main.go
Created May 10, 2023 15:41
An implementation of a IP whitelisting system in Golang. Only IP addresses listed in `IPWhitelist` with a value of true will be able to access the restricted endpoint.
package main
import (
"github.com/gin-gonic/gin"
"go-ip-whitelist/middlewares"
"net/http"
)
var IPWhitelist = map[string]bool{
"127.0.0.1": true,
@Tee-Stark
Tee-Stark / IP WhiteIisting.md
Created May 9, 2023 15:32 — forked from Brymes/IP WhiteIisting.md
IP WhiteIisting with Golang(Go) Gin

IP WhiteIisting with Golang(Go) Gin

Securing endpoints to specific IP addresses to prevent unauthorized access is a common practice in Backend engineering particularly for sensitive endpoints.

An Example is Securing Webhook endpoints E.g. Paystack

The files Attached

  • main.go :: Houses the server
  • middleware.go :: Houses the IP whitelisting function
@Tee-Stark
Tee-Stark / trackingAce.js
Created September 25, 2022 23:35
Algorithm to track Ace while shuffling deck of cards by splitting into two halves
function shuffleDeckAndReturnAcePosition(cardsCount, shufflesArr) {
let cards = Array.from({ length: cardsCount }, (v, i) => i + 1);
let acePosition = cards[cards.length - 1];
let mid = Math.floor(cards.length / 2);
for (let shuffle of shufflesArr) {
// split cards into two decks
let topHalf = cards.slice(0, mid);
let bottomHalf = cards.slice(mid);
// handle case for negative numbers by reversing top and bottom decks
if (shuffle < 0) {
@Tee-Stark
Tee-Stark / goTimeManipulation.go
Created September 1, 2022 21:07
Just a collection of some time and date manipulation functions in Go
package main
import (
"fmt"
"time"
)
func main() {
//// Get the current time.
myTime := time.Now() // get current time