Skip to content

Instantly share code, notes, and snippets.

View RICH0423's full-sized avatar
🎯
Focusing

Rich RICH0423

🎯
Focusing
View GitHub Profile
@RICH0423
RICH0423 / metallb-macos.md
Created May 20, 2025 02:44 — forked from RafalSkolasinski/metallb-macos.md
Kind & Minikube with MetalLB on MacOS

Dev K8s Networking on MacOS

Context

Unlike Linux on MacOS Docker runs inside VM. This causes issues when trying to access containers directly as their IP is not reachable from host network. It is especially annoying when trying to get a local development environment for K8s.

This short guides aim to solve the problem. Solution is: https://github.com/chipmk/docker-mac-net-connect

@RICH0423
RICH0423 / Application.java
Created December 1, 2022 09:51
Spring Boot authentication with GCP OpenID
package com.rich.gcp.app;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.gax.core.CredentialsProvider;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
@RICH0423
RICH0423 / postgre-check-connection.py
Last active April 6, 2022 06:37
Testing PostgreSQL connection with Python
import psycopg2
#establishing the connection
conn = psycopg2.connect(
database="postgres", user='postgres', password='12345678', host='127.0.0.1', port= '5432'
)
#Creating a cursor object using the cursor() method
cursor = conn.cursor()
#Executing an MYSQL function using the execute() method
@RICH0423
RICH0423 / run_redis.sh
Created February 14, 2022 03:45
run Redis and set password in docker for dev env
docker run -d \
-h redis \
-e REDIS_PASSWORD=passw0rd \
-v redis-data:/data \
-p 6379:6379 \
--name redis \
--restart always \
redis:6.2.6-alpine /bin/sh -c 'redis-server --appendonly yes --requirepass ${REDIS_PASSWORD}'
@RICH0423
RICH0423 / WordCount.java
Created May 4, 2020 03:19
implement a simple WordCount program using the high-level Kafka Streams DSL
package com.rich.stream.example;
import org.apache.kafka.common.serialization.Serdes;
import org.apache.kafka.common.utils.Bytes;
import org.apache.kafka.streams.KafkaStreams;
import org.apache.kafka.streams.StreamsBuilder;
import org.apache.kafka.streams.StreamsConfig;
import org.apache.kafka.streams.Topology;
import org.apache.kafka.streams.kstream.KeyValueMapper;
import org.apache.kafka.streams.kstream.Materialized;
@RICH0423
RICH0423 / fibonacci.go
Created July 31, 2019 07:36
Implement Fibonacci sequence with GO closure
package main
import (
"fmt"
)
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
prev1, prev2 := 0, 1
@RICH0423
RICH0423 / nginx-deployment.yaml
Created July 11, 2019 06:45
Run a Nginx application on K8S (using Minikube)
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment # Deployment name
spec:
selector: # defines how the Deployment finds which Pods to manage
matchLabels:
app: nginx
replicas: 2
template: # The Pods are labeled app:nginx using the labels field
@RICH0423
RICH0423 / Array2ListDemo.java
Created February 2, 2018 06:07
Program to Convert 'int' Array to 'List' of Integer
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class Array2ListDemo {
public static void main(String[] args) {
/**** Converting a Primitive 'int' Array to List ****/
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
// by default uses a Bean by the name of corsConfigurationSource
.cors().and()
...
}
@RICH0423
RICH0423 / Main.java
Created January 24, 2018 03:38
Converting Collection to Map with JDK 8 Collectors
package com.example;
import static java.lang.System.out;
import java.util.*;
import java.util.function.BinaryOperator;
import java.util.stream.Collectors;
public class Main {