Skip to content

Instantly share code, notes, and snippets.

View spdeepak's full-sized avatar
🏠
Working from home

Deepak spdeepak

🏠
Working from home
View GitHub Profile
@spdeepak
spdeepak / poll_cache.go
Created March 13, 2025 17:57
Polling in go for caching
package cache
import (
"sync"
"time"
)
type PollCache[K comparable, V any] struct {
data sync.Map
pollFunc func() map[K]V
@spdeepak
spdeepak / docker_postgres.md
Last active September 29, 2021 08:46
Postgres Docker

Run Postgres

docker run -d -p 5433:5432 --name postgres -e POSTGRES_PASSWORD=admin -e POSTGRES_USER=adminUser postgres:latest

Access postgres

docker exec -it postgres bash

Login to psql as adminUser

psql -U adminUser

Create DB

@spdeepak
spdeepak / qrcode_wifi.sh
Created July 12, 2021 06:58
Generate QR code for your wifi network on mac
brew install qrencode
qrencode -t utf8 'WIFI:T:WPA;S:network;P:password;;'
@spdeepak
spdeepak / RedisCacheServiceApplication.java
Last active December 29, 2018 18:21
Redis Cache, Message Queue example
package com.spdeepak.redis;
import com.spdeepak.redis.entity.LineItem;
import com.spdeepak.redis.entity.Order;
import com.spdeepak.redis.repository.LineItemRepository;
import com.spdeepak.redis.repository.OrderRepository;
import com.spdeepak.redis.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.microsoft.azure.servicebus.Message;
import com.microsoft.azure.servicebus.QueueClient;
import com.microsoft.azure.servicebus.ReceiveMode;
import com.microsoft.azure.servicebus.primitives.ConnectionStringBuilder;
import com.microsoft.azure.servicebus.primitives.ServiceBusException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@spdeepak
spdeepak / JAVA_HOME.md
Last active September 18, 2018 07:57
How to set JAVA_HOME on mac

Use the below command to see the version of the JDK installed

/usr/libexec/java_home -V

OR

java -version

Open .bash_profile

vim .bash_profile

Write the following to the .bash_profile (For default JDK 8 or change to 1.9/1.10/1.11 respectively for versions)

export JAVA_HOME=$(/usr/libexec/java_home -v1.8)

Run the .bash_profile script by the following command

source .bash_profile

@spdeepak
spdeepak / iterm2-solarized.md
Last active October 2, 2021 07:11 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

#1. Start MongoDB container
docker run -p 27017:27017 --name macmongo -e MONGO_INITDB_ROOT_PASSWORD=root -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_DATABASE=testdatabase -d mongo:latest
#2. Open MongoDB shell
docker exec -it macmongo mongo --authenticationDatabase admin -u root -p
@spdeepak
spdeepak / mysqlOnDocker.sh
Last active August 2, 2018 13:56
Run MySQL using Docker
#Start MySQL
#MYSQL_ROOT_PASSWORD - for root password
#MYSQL_DATABASE - for a startup database
#MYSQL_USER, MYSQL_PASSWORD - Now you now what this parameter might be
#For more stuff read this page -> https://hub.docker.com/_/mysql/
#1. Start MySQL with a root password, the root admin username will be root
docker run --name mysql1 -e MYSQL_ROOT_PASSWORD=root -d mysql:latest
#2. Start MySQL without a password. But read the logs to see the password
public class ConsoleColors {
// Reset
public static final String RESET = "\033[0m"; // Text Reset
// Regular Colors
public static final String BLACK = "\033[0;30m"; // BLACK
public static final String RED = "\033[0;31m"; // RED
public static final String GREEN = "\033[0;32m"; // GREEN
public static final String YELLOW = "\033[0;33m"; // YELLOW
public static final String BLUE = "\033[0;34m"; // BLUE