Skip to content

Instantly share code, notes, and snippets.

View joyheron's full-sized avatar

Joy Heron joyheron

View GitHub Profile
@joyheron
joyheron / ComplateConfiguration.java
Created July 2, 2020 09:27
Migrating from Nashorn to graaljs
package my.lovely.pkg;
import org.complate.core.ComplateRenderer;
import org.complate.core.ComplateSource;
import org.complate.graal.GraalComplateRenderer;
import org.complate.spring.mvc.ComplateViewResolver;
import org.complate.spring.source.ResourceComplateSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@joyheron
joyheron / index.html
Created November 12, 2019 21:16
Responsive Navigation optimized for Mobile
<!DOCTYPE html>
<html>
<head>
<title>Responsive Nav</title>
<style>
:root {
--space-xs: 0.25rem;
--space-sm: 0.5rem;
--space-md: 0.75rem;
--space-lg: 1.25rem;
@joyheron
joyheron / custom-elements.cljs
Last active January 22, 2020 10:02
Define Custom Elements in ClojureScript
;; Solution based on https://stackoverflow.com/questions/50295703/create-custom-elements-v1-in-es5-not-es6
(defn define-element! [name on-connect]
(let [my-el (fn [] (this-as this (.construct js/Reflect js/HTMLElement #js [] (.-constructor this))))
_ (set! (.. my-el -prototype) (.create js/Object (.-prototype js/HTMLElement)))
_ (set! (.. my-el -prototype -constructor) my-el)
_ (.setPrototypeOf js/Object my-el js/HTMLElement)
_ (set! (.. my-el -prototype -connectedCallback) on-connect)]
(.define js/customElements name my-el)))
(define-element! :my-element #(.log js/console "hi!"))
@joyheron
joyheron / index.html
Last active March 29, 2019 09:32
Layout with CSS example
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<style>
.navbar + .container {
margin-top: 2rem;
}
</style>
</head>
<body>
@joyheron
joyheron / gist:8a60e27b97626774a21009a159f4791e
Last active September 12, 2018 02:02
Complate String Render in Spring Boot
public class StringRenderer {
private static final String RENDER_FUNCTION_NAME = "render";
private final Resource resourceBundle;
private final ScriptingEngine engine;
public StringRenderer(Resource resourceBundle, ScriptingEngine engine) {
this.resourceBundle = resourceBundle;
this.engine = engine;
@joyheron
joyheron / cookie-jar.scala
Created October 2, 2017 07:49
Scala Version of Cookie Jar
@joyheron
joyheron / cookie-jar.hs
Last active March 5, 2018 21:12
Haskell Solution to Cookie Jar