Skip to content

Instantly share code, notes, and snippets.

View iyashjayesh's full-sized avatar
🥇
Creating! Building! Inspiring!

Yash Chauhan iyashjayesh

🥇
Creating! Building! Inspiring!
View GitHub Profile
@iyashjayesh
iyashjayesh / sqs_adapter.go
Created February 26, 2024 12:19
[Golang-AWS(SQS)] Code to receive and delete messages from SQS as soon as it's processed.
package main
import (
"fmt"
"os"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
@iyashjayesh
iyashjayesh / RateLimiter.go
Created March 31, 2023 20:02
Implementing Rate Limiting in Go APIs.
package main
import (
"fmt"
"sync"
"time"
)
type RateLimiter struct {
sync.Mutex
@iyashjayesh
iyashjayesh / main.go
Created March 28, 2023 10:03
An example Go program that demonstrates Polymorphism, Encapsulation, Abstraction, and Composition(Inheritance)
package main
import "fmt"
// Encapsulation: defining a private field in a struct
type person struct {
name string
age int
}
@iyashjayesh
iyashjayesh / main.go
Created March 28, 2023 06:07
Example of asynchronous message processing in Go using channels and goroutines
package main
import (
"fmt"
"math/rand"
"sync"
"time"
)
type Message struct {
@iyashjayesh
iyashjayesh / main.go
Created March 15, 2023 17:20
Convert (b,mb,gb,tb,pb) Memory data to kb using regex in Golang
package main
import (
"fmt"
"regexp"
"strconv"
"strings"
)
func main() {
@iyashjayesh
iyashjayesh / main.go
Last active June 30, 2022 10:59
Golang Logrus Simple Implementation
package main
import (
"github.com/sirupsen/logrus"
)
func main() {
var log = logrus.New()
log.SetFormatter(&logrus.JSONFormatter{
// DisableTimestamp: false, // Default: false
@iyashjayesh
iyashjayesh / main.go
Last active June 30, 2022 07:12
How to use Time package to get Time & date in various formats.
// You can edit this code!
package main
import (
"log"
"time"
)
func main() {
// get current time in UTC timezone
@iyashjayesh
iyashjayesh / main.java
Created June 30, 2022 06:09
Java Program to get Ip address and Hostname
import java.io.*;
import java.net.*;
public class InetSampleCode {
public static void main(String[] args) {
try {
InetAddress id = InetAddress.getLocalHost();
System.out.println("Host Name: " + id.getHostName());
System.out.println("IP Address: " + id.getHostAddress());
} catch (Exception e) {
@iyashjayesh
iyashjayesh / main.go
Created June 30, 2022 05:45
Program to get the IP Address and Hostname
package main
import (
"log"
"net"
"os"
)
func main() {
hostname, _ := os.Hostname() // get hostname
addrs, err := net.LookupIP(hostname) // returns a slice of the IP addresses of the host
// lookupIP looks up host using the local resolver. It returns a slice of that host's IPv4 and IPv6 addresses.
@iyashjayesh
iyashjayesh / onebyone_rotate.cpp
Created July 18, 2020 07:28
One by One rotation of Array - Time Complexity O(n*d)
// C++ program to rotate an array by d elements
#include <bits/stdc++.h>
using namespace std;
/*Function to left Rotate arr[] of size n by 1*/
void leftRotatebyOne(int arr[], int n)
{
int temp = arr[0], i;
for (i = 0; i < n - 1; i++)
arr[i] = arr[i + 1];