Skip to content

Instantly share code, notes, and snippets.

View weavejester's full-sized avatar

James Reeves weavejester

View GitHub Profile
/* ==UserStyle==
@name LemmyES (WIP)
@version 0.0.1
@namespace userstyles.world/user/weaveester
@description A style for Lemmy inspires by old.reddit.com and RES.
@author weavejester
@license MIT
==/UserStyle== */
@-moz-document domain("lemmy.world"), domain("lemmy.ml"), domain("beehaw.org"), domain("feddit.de") {
{:duct.profile/base
{:duct.core/project-ns film-ratings
:duct.router/ataraxy
{:routes
{[:get "/"] [:film-ratings.handler/index]
"/add-film"
{:get [:film-ratings.handler.film/show-create]
[:post {film-form :form-params}] [:film-ratings.handler.film/create film-form]}
[:get "/list-films"] [:film-ratings.handler.film/list]}}
commands:
bye:
short: Prints a farewell
long: Prints 'Goodbye NAME' to STDOUT.
flags:
name:
type: string
desc: a person's name
short: n
default: World
commands:
urlimport:
short: Imported command
run: echo imported
greet:
short: Imported greet from URL
run: echo imported greet
{:duct.core/project-ns site-cljs-example
:duct.core/environment :development
:duct.module/logging {}
:duct.module.web/site {}
:duct.server.http/jetty
{:handler #ig/ref :example/root-handler}
[:duct.core/handler :example/root-handler]
(ns example.handler
(:require [compojure.api.sweet :as api :refer [context GET]]
[clojure.java.jdbc :as jdbc]
[hikari-cp.core :as hikari-cp]
[org.httpkit.server :as httpkit]
[ring.util.http-response :as response]))
(def db
{:datasource
(hikari-cp/make-datasource
@weavejester
weavejester / homoiconicity.md
Last active June 21, 2021 04:36
Homoiconicity in Clojure

Many programming languages are designed to favour writing code over writing literal data. For example, in Python the syntax for accessing an instance variable on an object is:

student.name

But to access a value in a dictionary data structure:

{:duct.logging/timbre
{:level :info
:appenders {:println #ref :duct.logging.timbre/println}}
:duct.logging.timbre/println
{:stream :auto}
:duct.server/jetty
{:port 3000
:handler #ref duct.bridge/handler}
precision mediump float;
varying vec2 vTextureCoord;
uniform sampler2D uSampler;
uniform vec2 dimensions;
void main(void) {
vec2 pixelSize = vec2(1.0) / dimensions;
vec4 pixel = texture2D(uSampler, vTextureCoord);
vec4 pixelUp = texture2D(uSampler, vTextureCoord - vec2(0.0, pixelSize.y));
;; I'd begin by using protocols to define the I/O boundaries of the endpoint.
;; The protocols can be extended to support the database and mailer component
;; when in production, and for testing a mock implementation can be used instead.
(defprotocol UsersDatabase
(authenticate [db credentials])
(create-user [db user]))
(defprotocol Mailer
(send-email [mailer email]))