This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
//// Get the current time. | |
myTime := time.Now() // get current time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/gin-gonic/gin" | |
"go-ip-whitelist/middlewares" | |
"net/http" | |
) | |
var IPWhitelist = map[string]bool{ | |
"127.0.0.1": true, |