Skip to content

Instantly share code, notes, and snippets.

View marcus-at-localhost's full-sized avatar
💭
☕

Marcus marcus-at-localhost

💭
☕
View GitHub Profile
@marcus-at-localhost
marcus-at-localhost / Retrieve Plugin Data.md
Last active February 3, 2023 11:08
Retrieve Plugin Data.md

Retrieve Plugin Data #kirby #php

Eg. get a blueprint or a template path in a controller:

// index.php
Kirby::plugin('my/plugin', [
	'blueprints' => [
 'profile_form' => __DIR__ . '/blueprints/form.yml',
@marcus-at-localhost
marcus-at-localhost / _index.md
Last active January 31, 2023 17:07
This is a Lepton Title Some description #tag1 #tag2

Bla

  • Mark
  • Down
@marcus-at-localhost
marcus-at-localhost / mysql-change-sqlmode.md
Created January 31, 2023 14:22 — forked from yidas/mysql-change-sqlmode.md
[MySQL] Permanently change SQL Mode in MySQL (disable_strict_mode)

[MySQL] Permanently change SQL Mode in MySQL (disable_strict_mode)

Set into [mysqld] of MySQL config, for Ubuntu your could create a file /etc/mysql/conf.d/disable_strict_mode.cnf:

[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION

SQL mode example: STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

<?php
$blueprint = new Kirby\Cms\PageBlueprint(array_merge(['model' => $page], Kirby\Cms\Blueprint::load('pages/album')));
dump($blueprint->section('images'));
@marcus-at-localhost
marcus-at-localhost / csv.php
Created October 8, 2022 13:05
[CSV Tab as String] #csv #tab #slashes #string
<?php
$csv = fopen('php://memory', 'r+');
fputcsv($csv, ['a','b','c'], "\t");
fputcsv($csv, ['a','b','c'], "\t");
rewind($csv);
$output = stream_get_contents($csv);
// tab as string
@marcus-at-localhost
marcus-at-localhost / index.md
Created September 9, 2022 16:35
[HTMX Select Field Goto URL] Inspired by https://stackoverflow.com/a/68058914/814031 #htmx
let handle = function (event) {
  if(event.detail.elt.id !== 'formFilter'){
    return;
  }
  event.detail.path = event.detail.parameters['categories'];
  delete event.detail.parameters['categories'];
};

document.body.addEventListener("htmx:configRequest", handle);
@marcus-at-localhost
marcus-at-localhost / KirbyCacheStorage.php
Last active January 3, 2023 14:36
[Guzzle Cache Middleware - Kirby CMS Cache Driver] #kirby #cache
<?php
namespace Kevinrob\GuzzleCache\Storage;
use Kevinrob\GuzzleCache\CacheEntry;
class KirbyCacheStorage implements CacheStorageInterface
{
/**
@marcus-at-localhost
marcus-at-localhost / README.md
Last active July 23, 2022 12:20 — forked from joyrexus/README.md
[Vanilla JS equivalents of jQuery methods] #jquery2js

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@marcus-at-localhost
marcus-at-localhost / index.html
Created June 20, 2022 14:31
[Change Button Text Depending on Another Field] #js
<form>
<input class="kb-field-2">
<button class="kb-forms-submit">A</button>
</form>
<script>
const field = document.getElementsByClassName('kb-field-2')[0];
field.addEventListener("keyup", () => {
let btn = document.getElementsByClassName('kb-forms-submit')[0];
if( field.value === "" ) {