Skip to content

Instantly share code, notes, and snippets.

View hanrw's full-sized avatar
🎯
Focusing

itshan hanrw

🎯
Focusing
View GitHub Profile
@hanrw
hanrw / README.md
Created July 28, 2022 03:41 — forked from noamtamim/README.md
Markdown with PlantUML

How to use PlantUML with Markdown

PlantUML is a really awesome way to create diagrams by writing code instead of drawing and dragging visual elements. Markdown is a really nice documentation tool.

Here's how I combine the two, to create docs with embedded diagrams.

Step 0: Setup

Get the command-line PlantUML from the download page or your relevant package manager.

@hanrw
hanrw / EntityConfiguration.kt
Created May 21, 2022 05:14
Spring create domain entity
import org.apache.commons.logging.LogFactory
import org.springframework.beans.BeansException
import org.springframework.context.ApplicationContext
import org.springframework.context.ApplicationContextAware
import org.springframework.context.annotation.ImportResource
import org.springframework.context.support.GenericXmlApplicationContext
import org.springframework.core.io.Resource
import org.springframework.stereotype.Component
import javax.annotation.PostConstruct
@hanrw
hanrw / ECDSA-secp256k1-example.java
Created May 1, 2022 13:27 — forked from nakov/ECDSA-secp256k1-example.java
ECDSA with secp256k1 in Java: generate ECC keys, sign, verify
import org.bouncycastle.util.encoders.Hex;
import org.web3j.crypto.*;
import java.math.BigInteger;
public class ECCExample {
public static String compressPubKey(BigInteger pubKey) {
String pubKeyYPrefix = pubKey.testBit(0) ? "03" : "02";
String pubKeyHex = pubKey.toString(16);
String pubKeyX = pubKeyHex.substring(0, 64);

Mastering Programming - by Kent Beck

From years of watching master programmers, I have observed certain common patterns in their workflows. From years of coaching skilled journeyman programmers, I have observed the absence of those patterns. I have seen what a difference introducing the patterns can make. Here are ways effective programmers get the most out of their precious 3e9 seconds on the planet. The theme here is scaling your brain. The journeyman learns to solve bigger problems by solving more problems at once. The master learns to solve even bigger problems than that by solving fewer problems at once. Part of the wisdom is subdividing so that integrating the separate solutions will be a smaller problem than just solving them together.

Time

Slicing - Take a big project, cut it into thin slices, and rearrange the slices to suit your context. I can always slice projects finer and I can always find new permutations of the slices that meet different needs

@hanrw
hanrw / SecurityConfig.java
Created May 7, 2021 08:48
Cors on EnableWebFluxSecurity
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpHeaders;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.web.server.SecurityWebFilterChain;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.reactive.CorsConfigurationSource;
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
import java.util.ArrayList;
@hanrw
hanrw / gist:f5c7f99ef8d7246c7d1b76cee5aa696f
Created August 23, 2020 04:24
parse not and or json to code
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.server.{Directives, Route}
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import spray.json._
import scala.concurrent.{ExecutionContextExecutor, Future}
/**
@hanrw
hanrw / nginx-config-for-nexus_registry
Last active May 22, 2020 13:34
nginx proxy nexus3 docker mirror
upstream nexus_admin { server 192.168.2.233:8081 ; }
upstream nexus_registry { server 192.168.2.233:8082 ; }
server {
listen 80;
listen 443 ssl;
server_name registry.docker.com;
access_log /dev/null;
error_log /var/nginx/logs/registry.docker.com.error.log;
ssl_certificate /etc/nginx/cert/registry.docker.com_server.crt;
@hanrw
hanrw / .bash_profile
Last active March 17, 2022 03:49 — forked from donchesworth/.bash_profile
switch between java versions
# Simple way ============================
function setjdk() {
if [ $# -ne 0 ]; then
if [ -n "${JAVA_HOME+x}" ]; then
removeFromPath "$JAVA_HOME/bin"
fi
export JAVA_HOME=`/usr/libexec/java_home -v $@`
export PATH=$JAVA_HOME/bin:$PATH
fi
@hanrw
hanrw / CreateJob.sh
Created September 20, 2019 07:41 — forked from stuart-warren/CreateJob.sh
Create a job in Jenkins (or folder) using the HTTP API
# check if job exists
curl -XGET 'http://jenkins/checkJobName?value=yourJobFolderName' --user user.name:YourAPIToken
# with folder plugin
curl -s -XPOST 'http://jenkins/job/FolderName/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# without folder plugin
curl -s -XPOST 'http://jenkins/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# create folder
@hanrw
hanrw / .htaccess
Created August 8, 2019 10:14 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/