Skip to content

Instantly share code, notes, and snippets.

<?php
const PATTERN_LINK = '/^(?<index>\d+):\s+(?<device>[\w\-]+).+state (?<state>UNKNOWN|UP|DOWN).+link\/(loopback|ether) (?<address>[a-z0-9\:]+)/';
const PATTERN_IPv4 = '/^(?<index>\d+):\s*(?<device>[\w\-]+)\s+inet (?<ipv4>[0-9\.\/]+)/';
const PATTERN_IPv6 = '/^(?<index>\d+):\s*(?<device>[\w\-]+)\s+inet6 (?<ipv6>[a-z0-9\:\/]+)/';
$interfaces = [];
$result = shell_exec('ip -o link show');
$rows = explode(PHP_EOL, $result);
@kesselb
kesselb / nextcloud.sh
Last active October 8, 2020 10:05
Homestead site-type for Nextcloud
#!/usr/bin/env bash
if [ "$7" = "true" ]
then configureXhgui="
location /xhgui {
try_files \$uri \$uri/ /xhgui/index.php?\$args;
}
"
else configureXhgui=""
fi
<?php
namespace OCA\ServerInfo\Resources;
class Memory {
public $memTotal = -1;
public $memFree = -1;
public $memAvailable = -1;
public $swapTotal = -1;
public $swapFree = -1;
@kesselb
kesselb / kicker_guzzle.php
Created March 9, 2020 18:49
Minimal working example to reproduce a guzzle issue with rss.kicker.de/news/2bundesliga
<?php
require_once __DIR__ . '/vendor/autoload.php';
$stream =
$client = new GuzzleHttp\Client([
//'handler' => new \GuzzleHttp\Handler\CurlHandler(), // body size: 0
'handler' => new \GuzzleHttp\Handler\StreamHandler(), // body size: 25965
]);
@kesselb
kesselb / TemplateLayout.patch
Created November 23, 2019 21:32
Add \OC::$APPSROOTS to mappings for findWebRoot
Index: lib/private/TemplateLayout.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- lib/private/TemplateLayout.php (revision 4f2837017c95f063d99a05b6cd6a5e73ac388d75)
+++ lib/private/TemplateLayout.php (date 1574544614260)
@@ -48,6 +48,8 @@
class TemplateLayout extends \OC_Template {