Skip to content

Instantly share code, notes, and snippets.

View sebsel's full-sized avatar

Sebastiaan Andeweg sebsel

View GitHub Profile
<?php
namespace App;
use App\Services\KirbyDataReader;
use Illuminate\Database\Eloquent\Model;
use League\Flysystem\FileNotFoundException;
abstract class HybridModel extends Model
{
@sebsel
sebsel / _ide_helper_generator.php
Last active November 5, 2020 09:32
Kirby IDE Helper
<?php define('DS', DIRECTORY_SEPARATOR);
// Set this one to your own blueprint root if you changed it.
$blueprint_root = __DIR__ . DS . 'site' . DS . 'blueprints';
// For Kirby 3, see the comment below.
/**
* === Let's build an IDE-helper for Kirby for PHPStorm!
*
@sebsel
sebsel / framework.php
Last active October 4, 2017 10:38
Bot Framework
<?php
header('Content-Type: application/json');
class Bot {
const xrayUrl = ''; // host your own XRay!
const logfile = 'log.txt';
const names = [
// add names for your bot here, so it can ignore itself
// IMPORTANT! because it will loop and flood if you're not careful
@sebsel
sebsel / fibohaha.php
Last active September 14, 2017 11:25
Fibohaha
<?php
function fibo($n) {
if($n <= 1) return $n;
return fibo($n-1) + fibo($n-2);
}
function haha($n) {
return str_repeat('ha', fibo($n));
}
@sebsel
sebsel / indexer.php
Created June 28, 2017 18:00
Indexer for Kirby
<?php
class Indexer {
static $fields;
static $methods;
static $site;
static function get($where = null, $num = 20, $hideDeleted = true) {
if (!static::$site) static::$site = site();
@sebsel
sebsel / name.php
Created June 25, 2017 18:57
CLI for naming things
<?php
echo 'What pattern of consonants and vowels? ';
echo '(use "C" and "V" like CVC or CVCV)'.PHP_EOL;
$pattern = trim(fgets(STDIN), PHP_EOL);
$a = [
'a','e','i','o','u',
];
@sebsel
sebsel / endpoint.php
Created January 27, 2017 19:53
discover endpoint route for seblog-kirby-webmentions
<?php
// add after line 22
[
'pattern' => 'discover',
'action' => function() {
echo mentions::discoverEndpoint(get('url'));
}
],
@sebsel
sebsel / default.php
Last active January 17, 2017 10:27
Kirby minimal blueprint dev template
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title><?php echo $site->title()->html() ?> | <?php echo $page->title()->html() ?></title>
<style>
.field {