Skip to content

Instantly share code, notes, and snippets.

View abelaska's full-sized avatar
👍

Alois Bělaška abelaska

👍
View GitHub Profile
@abelaska
abelaska / pom.xml
Created June 3, 2020 15:30
Spring Boot + GraalVM Maven profile
<profiles>
<profile>
<id>graal</id>
<properties>
<graalvm.version>20.1.0</graalvm.version>
<spring-graal-native.version>0.6.1.RELEASE</spring-graal-native.version>
<start-class>cz.monetplus.idport.sdk.management.operator.Application</start-class>
</properties>
<pluginRepositories>
<pluginRepository>
@abelaska
abelaska / Helper.java
Created May 28, 2020 07:19
Annotate classes at runtime with ByteBuddy
// add @JsonDeserialize(using = JsonDeserializer.None.class) to classes
// inspired by https://stackoverflow.com/a/49320259/1638047
@SneakyThrows
Class<? extends ManagementResource> annotateResourceClass(Class<? extends ManagementResource> clazz) {
ClassPool classPool = ClassPool.getDefault();
CtClass ctClass = classPool.get(clazz.getName());
if (ctClass.isFrozen()) {
return clazz;
}
@abelaska
abelaska / Kind.java
Created May 12, 2020 06:48
Java Jackson @JsonSubTypes
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
@Data
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind", visible = true)
@JsonSubTypes({
//resource "null_resource" "apply_kubernetes_update" {
// depends_on = [
// module.eks_cluster
// ]
//
// triggers = {
// tf_sha1 = sha1(file("${path.module}/kubernetes.tf"))
// }
//
@abelaska
abelaska / google-img-resize.mdown
Last active August 12, 2020 05:50
Google’s authentication-less on-the-fly image resizing service

Google's authentication-less on-the-fly image resizing service

I found it while poking around the Google+ HTML. Jotting down some notes felt like a good idea, so here goes. If you know more about this API, let me know, please!

(Word of warning: I spent ~30 minutes on both my experimentation and this here write-up, so it might not be the most thought-provoking, brilliant thing you read today.)

@abelaska
abelaska / editable.js
Last active June 23, 2018 08:16
React Inline contenteditable
// @flow
/* global document */
export default ({
onCommit,
maxLength = -1,
state = {}
}: {
state?: {
originalValue?: string
const show = ({ url }, resolve, reject) => {
const width = Math.max(1000, Math.floor(window.outerWidth * 0.8));
const height = Math.max(630, Math.floor(window.outerHeight * 0.5));
const left = Math.floor(window.screenX + (window.outerWidth - width) / 2);
const top = Math.floor(window.screenY + (window.outerHeight - height) / 8);
const wOptions = [
'toolbar=0',
'scrollbars=1',
'status=0',
https://github.com/paralect/robomongo/issues/1106
try {
await UserSession.get(ctx.id).update({ pingedAt: r.now() }, { durability: 'soft' });
} catch (e) {
if (e.name === 'DocumentNotFoundError') {
await UserSession
.insert({ id: ctx.id, userId: ctx.user.id, pingedAt: r.now() }, { durability: 'soft' });
} else {
log.error(`Failed to update user session ${ctx.id}`, {
error: err
});