Skip to content

Instantly share code, notes, and snippets.

View HendrikRoth's full-sized avatar

Hendrik Roth HendrikRoth

  • Dusseldorf, Germany
View GitHub Profile
@HendrikRoth
HendrikRoth / ColorPicker.tsx
Created April 15, 2023 00:14 — forked from devstojko/ColorPicker.tsx
Payload Input - ColorPicker
import React, { useCallback } from "react";
import { useField, withCondition } from "payload/components/forms";
import { TextField } from "payload/dist/fields/config/types";
import ColorInput from "../PayloadInput";
import { text } from "payload/dist/fields/validations";
export type Props = Omit<TextField, "type"> & {
path?: string;
@HendrikRoth
HendrikRoth / LinkBlock.ts
Created January 6, 2023 00:05 — forked from ozbeksu/LinkBlock.ts
PayloadCMS Revursive Block
import {Block} from 'payload/types';
const createRecursiveLinksBlock = (current = 0, maxDepth = 3): Block => {
if (current < maxDepth - 1) {
current++;
return {
slug: `Level ${current}`,
fields: [
{
name: 'name',
@HendrikRoth
HendrikRoth / +page.server.ts
Last active December 11, 2023 15:45 — forked from AlessioGr/PayloadCommunicator.ts
Simple helper you can use to communicate with Payload CMS from your application via their REST API. Authorization via API key needs to be enabled in your users collection. More on enabling API keys here: https://payloadcms.com/docs/authentication/config#api-keys
import { getDocumentByID } from "./PayloadCommunicator.ts";
import type { PageServerLoad } from './$types';
export const load = (async ({ params }) => {
return await getDocumentByID('collection', params.id);
}) satisfies PageServerLoad;
@HendrikRoth
HendrikRoth / app.js
Created August 13, 2017 03:47 — forked from shibukawa/app.js
mithril lazy loading
var m = require("mithril");
m.mount(document.querySelector("#menu"), {
view: function() {
return m("ul", [
m("li", m('a[href="/a"]', {config: m.route}, "module A")),
m("li", m('a[href="/b"]', {config: m.route}, "module B")),
m("li", m('a[href="/c"]', {config: m.route}, "module C"))
]);
}
@HendrikRoth
HendrikRoth / install-node-pi.sh
Last active January 31, 2018 11:45 — forked from myrtleTree33/install-node-pi.sh
Install Node JS in 30 seconds for Raspberry Pi / ARM
#!/bin/bash
## Check for versions compiled with ARM at http://nodejs.org/dist/
## Inspired by http://oskarhane.com/raspberry-pi-install-node-js-and-npm/
## Fill in the Node Version here:
##########################################################################
NODE_VERSION="v8.2.1"
#!/bin/bash
#enable job control in script
set -m
# when /etc/couchdb (contains i.g. admin account) was not allready moved to persistant storage, do it and symlink the org. directory
if [ ! -d /var/lib/couchdb/etc/couchdb ]; then
mkdir /var/lib/couchdb/etc
mv /etc/couchdb /var/lib/couchdb/etc/
ln -s /var/lib/couchdb/etc/couchdb/ /etc/couchdb
#!/bin/bash
### BEGIN INIT INFO
# Provides: node-red
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start or stop the node-red server
### END INIT INFO
# Can be downloaded and installed in one go by using this command
@HendrikRoth
HendrikRoth / cssobj-plugin-keyframes.js
Created November 11, 2016 11:38 — forked from futurist/cssobj-plugin-keyframes.js
cssobj-plugin-keyframes.js
const random = +new Date()
export default {
selector: function(sel) {
let match = /^\s*@keyframes (.*)$/i.exec(sel)
return match ? '@keyframes ' + match[1].trim() + random : sel
},
value: function(val, key) {
return key=='animateName' ? val + random : val
}
}
(function () {
// IndexedDB
var indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.OIndexedDB || window.msIndexedDB,
IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || window.OIDBTransaction || window.msIDBTransaction,
dbVersion = 1.0;
// Create/open database
var request = indexedDB.open("elephantFiles", dbVersion),
db,
createObjectStore = function (dataBase) {