Skip to content

Instantly share code, notes, and snippets.

Avatar

Djamil Legato w00fz

View GitHub Profile
View home.json.twig
{% 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 Oct 31, 2020
PHP switcher
View sphp.sh
#!/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
View gitter.js
// 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
View json-replacer.php
<?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 Dec 9, 2012
Arduino simple program for op-amp feedback.
View opamp.ino
#define MIC A1
#define LED 3
void setup(){
//for debug
//Serial.begin(9600);
pinMode(MIC, INPUT);
pinMode(LED, OUTPUT);
}
You can’t perform that action at this time.