Skip to content

Instantly share code, notes, and snippets.

{% set items = [] %}
{% for child in page.collection() %}
{% set items = items|merge([{ frontmatter: child.header, content: child.content} ]) %}
{% endfor %}
{% set payload = {
name: page.header.title,
route: page.route,
type: page.template,
items: items,
@w00fz
w00fz / sphp.sh
Last active February 7, 2022 00:12
PHP switcher
#!/bin/bash
# Check if command was ran as root.
if [[ $(id -u) -eq 0 ]]; then
echo "The command \"sphp\" should not be executed as root or via sudo directly."
echo "When a service requires root access, you will be prompted for a password as needed."
exit 1
fi
# Usage
// current
((window.gitter = {}).chat = {}).options = {
room: 'getgrav/grav'
};
document.addEventListener('gitter-sidecar-instance-started', function(e) {
$('.gitter-open-chat-button').html('<i class="fa fa-comments-o fa-fw"></i> Open Chat');
});
});
// ideal
<?php
$file = file_get_contents('file.json');
$count = -1;
preg_match_all("/(?:color:\s'([^']+)')/i", $file, $colors);
preg_match_all("/(?:windows:\s'([^']+)')/i", $file, $windows);
$file = preg_replace_callback("/(?:url:\s'([^']+)')/i", function($matches) use (&$count, $colors, $windows) {
$count++;
return "url: '". $matches[1] . $colors[1][$count] . '-' . $windows[1][$count] . ".jpg'";
}, $file);
@w00fz
w00fz / opamp.ino
Created December 9, 2012 23:42
Arduino simple program for op-amp feedback.
#define MIC A1
#define LED 3
void setup(){
//for debug
//Serial.begin(9600);
pinMode(MIC, INPUT);
pinMode(LED, OUTPUT);
}