Skip to content

Instantly share code, notes, and snippets.

View daniellansun's full-sized avatar

Daniel Sun daniellansun

View GitHub Profile

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@daniellansun
daniellansun / App.java
Created April 26, 2022 14:37 — forked from thomasdarimont/App.java
Example for defining a refreshable Groovy Script in Spring Boot with Java Config - at least thats the current state of affairs :)
package demo;
import java.util.concurrent.TimeUnit;
import org.springframework.aop.TargetSource;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@daniellansun
daniellansun / DemoApplication.java
Created April 22, 2022 02:26 — forked from ehdez73/DemoApplication.java
Create Beans programatically with Spring Boot
package com.example;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@daniellansun
daniellansun / SimpleFuture.java
Created May 5, 2021 13:40 — forked from klausbrunner/SimpleFuture.java
A very simple implementation of the Java Future interface, for passing a single value to some waiting thread. Uses a CountdownLatch to ensure thread safety and provide blocking-with-timeout functionality required by Future. Cancellation isn't supported.
public final class ResultFuture implements Future<Result> {
private final CountDownLatch latch = new CountDownLatch(1);
private Result value;
@Override
public boolean cancel(boolean mayInterruptIfRunning) {
return false;
}
@Override
@daniellansun
daniellansun / UsesGroovyShell.groovy
Created December 28, 2019 17:09 — forked from itzg/UsesGroovyShell.groovy
Enabling Groovy invokedynamic ("indy") support in a Gradle build
// ....
def compilerConfig = new CompilerConfiguration()
compilerConfig.optimizationOptions.indy = true
def shell = new GroovyShell(compilerConfig)

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date:

Greach 2018 awesome list

What is this?

A compilation of all the links to slides and repositories used in workshops or shown by the speakers.

Why

It can be difficult to retrieve all that material on twitter after the conference.

Contents

@daniellansun
daniellansun / Hello.java
Created January 13, 2018 21:04 — forked from headius/Hello.java
"Hello, %s" using method handles two different ways
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
public class Hello {
private static final MethodHandles.Lookup lookup = MethodHandles.lookup();
public static void main(String[] args) throws Throwable {
System.out.println("Hello, " + args[0]);
}
@daniellansun
daniellansun / ReflectTest.java
Created December 26, 2017 06:11 — forked from spullara/ReflectTest.java
Invokedynamic all in one example
package indy;
import java.lang.invoke.CallSite;
import java.lang.invoke.ConstantCallSite;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.Constructor;
import org.objectweb.asm.ClassWriter;
@Grab(group='org.gperfutils', module='gbench', version='0.4.3-groovy-2.4')
String a = 'The quick brown fox'
String b = 'jumps over the lazy dog'
int x = 1
double y = 2
benchmark {
'simple concat' {
String concat = a + ' ' + b + ' ' + x + ' ' + y