Skip to content

Instantly share code, notes, and snippets.

View adamkiss's full-sized avatar
🐱
Cats are awesome.

Adam Kiss adamkiss

🐱
Cats are awesome.
View GitHub Profile
@adamkiss
adamkiss / index.php
Last active January 2, 2023 15:19
Kirby: easy Simple Snippets plugin
<?php
use Kirby\Cms\App;
App::plugin('adamkiss/simple-snippets', []);
if (! function_exists('s')) {
/**
* Short, auto-return snippet call with support for auto-merging certain parameters
*
* @param string $snippetName
@adamkiss
adamkiss / nr.fish
Created July 23, 2020 11:32
NPM RUN Shortcut
#!/usr/bin/env fish
function nr -a script --description 'npm run shortcut with default script set to "start"'
if not string length -q $script
set script start
end
npm run $script
end
@adamkiss
adamkiss / Retour Query Optimization.md
Last active March 18, 2020 14:59
Retour Overview Query Optimization

SQL Optimization — Retour database, events overview

@distantnative asked me (well, anyone) to optimize a SQL query which generates an overview of Retour events.

#Programming/SQL

Original Query

with recursive dates as (
    select "2019-10-01" as date
 union all
@adamkiss
adamkiss / _index.php
Last active March 5, 2020 20:12
Dynamic Blueprints in Kirby
<?php
use Kirby\Cms\App as Kirby;
use Kirby\Data\Data;
Kirby::plugin('adamkiss/dynamic-blueprint', [
'hooks' => [
'system.loadPlugins:after' => function() {
// load base (this could be dynamic as well. Should even)
$fakeBlueprint = Data::read(__DIR__ . '/fake-kirby-request.yml');
module.exports = class Transform {
constructor (opts) {
this.opts = opts
this.apply = this.apply.bind(this)
}
apply (compiler) {
const transforms = (Array.isArray(this.opts)) ? this.opts : [this.opts]
compiler.plugin('emit', function(compilation, done) {
extends(src='layout.sgr')
block(name='styles' type='append')
// normal link
link(rel='stylesheet' href='/css/home-hero.css')
// function for reshape-content
style(inline) /css/home-hero.css
// reshape custom element plugin
@adamkiss
adamkiss / stuff.scss
Created May 2, 2017 11:25
Testing ruleset generation Sass
$breakpoints-list: (
ns: '>=44em'
);
$ruleset: (
bg-r: ('background red'),
bg-g: ('background green', top 10px)
);
$breakpoints: ns;
@adamkiss
adamkiss / lib.js
Created March 31, 2017 20:57
Require fresh module each time (as a function in lib.js)
'use strict'
module.exports = {
require_fresh: function (file) {
delete require.cache[require.resolve(file)]
return require(file)
}
}
@adamkiss
adamkiss / TextformatterTempTags.php
Created December 7, 2012 14:35
PW TextFormatter – {{ something }} parsing module
<?php
/**
* Temporary Tags for Text fields
*
* I need to push my site out ASAP, fast. I need this.
*
* @author Adam Kiss
* @version 1.0
* @since 2012-09-20
@adamkiss
adamkiss / gist:4215822
Created December 5, 2012 14:20
EE's 'switch' – template function in pure PHP
<?php
$ee_switch_global = array();
function switch(){
global $ee_switch_global;
$args = func_get_args();
$key = array_shift($args);
if (array_key_exists($key,$ee_switch_global)){
$index = $ee_switch_global[$key]++;