Skip to content

Instantly share code, notes, and snippets.

View johannschopplich's full-sized avatar

Johann Schopplich johannschopplich

View GitHub Profile
@lukaskleinschmidt
lukaskleinschmidt / blueprint.yaml
Created April 18, 2024 14:46
Kirby 4 query pages from a searchengine for the pages field
fields:
articles:
type: pages
query: kirby.collection('articles')
@hrishioa
hrishioa / load_and_process_open_source_licenses.ts
Created May 6, 2023 06:23
Simple Typescript file demonstrating chunked, chained LLM calls to process large amounts of text.
// Requires the gpt library from https://github.com/hrishioa/socrate and the progress bar library.
// Created by Hrishi Olickel (hrishioa@gmail.com) (@hrishioa). Reach out if you have trouble running this.
import { ThunkQueue } from '../../utils/simplethrottler';
import {
AcceptedModels,
Messages,
askChatGPT,
getMessagesTokenCount,
getProperJSONFromGPT,
@Atinux
Atinux / sse.ts
Last active April 22, 2024 20:39
SSE endpoint example with Nuxt 3
// ~/server/api/sse.ts
export default defineEventHandler(async (event) => {
if (!process.dev) return { disabled: true }
// Enable SSE endpoint
setHeader(event, 'cache-control', 'no-cache')
setHeader(event, 'connection', 'keep-alive')
setHeader(event, 'content-type', 'text/event-stream')
setResponseStatus(event, 200)
@DavidWells
DavidWells / github-proxy-client.js
Last active March 15, 2024 08:28
Full Github REST api in 34 lines of code
/* Ultra lightweight Github REST Client */
// original inspiration via https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb
const token = 'github-token-here'
const githubClient = generateAPI('https://api.github.com', {
headers: {
'User-Agent': 'xyz',
'Authorization': `bearer ${token}`
}
})
@DavidWells
DavidWells / javascript-proxy-as-rest-client.js
Last active October 6, 2023 18:39
Using a javascript proxy as low code REST client
/* Using a JavaScript proxy for a super low code REST client */
// via https://dev.to/dipsaus9/javascript-lets-create-aproxy-19hg
// also see https://towardsdatascience.com/why-to-use-javascript-proxy-5cdc69d943e3
// also see https://github.com/fastify/manifetch
// also see https://github.com/flash-oss/allserver
// and https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb
const createApi = (url) => {
return new Proxy({}, {
get(target, key) {
@jonathantneal
jonathantneal / command.js
Last active October 26, 2022 07:20
Executable JavaScript Modules
":" //#;exec /usr/bin/env node --input-type=module - $@<$0
import process from 'process'
const { argv } = process
console.log(argv)
export class cloneable {
public static deepCopy<T>(source: T): T {
return Array.isArray(source)
? source.map(item => this.deepCopy(item))
: source instanceof Date
? new Date(source.getTime())
: source && typeof source === 'object'
? Object.getOwnPropertyNames(source).reduce((o, prop) => {
Object.defineProperty(o, prop, Object.getOwnPropertyDescriptor(source, prop)!);
o[prop] = this.deepCopy((source as { [key: string]: any })[prop]);
class BetterMap<k, v> extends Map<k, v> {
update(key:k, updater: (v:v, k:k) => v, notset:v = undefined) {
if(this.has(key)) this.set(key, updater(this.get(key), key))
else this.set(key, notset)
}
filter(predicate: (v:v, k:k) => boolean) {
const newMap = new BetterMap<k, v>()
const entries = Array.from(this.entries())
for(const [key, value] of entries) {

Simple Contact-Form in Kirby 3

As a starting point I've used the latest Starterkit (Beta 4) combined with the core from the latest Nightly Build (18-08-06).

First, set email-properties in your config. I would recommend using a mail-service like Mailgun (via SMTP) because setting everything up on your own server is cumbersome, error-prone, and unsecure. But of course, it's up to you.

site/config/config.php:

<?php
@argyleink
argyleink / easings.css
Created February 26, 2018 22:34
Handy CSS properties for easing functions
:root {
--ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);
--ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19);
--ease-in-quart: cubic-bezier(0.895, 0.03, 0.685, 0.22);
--ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06);
--ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035);
--ease-in-circ: cubic-bezier(0.6, 0.04, 0.98, 0.335);
--ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
--ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);
--ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);