Skip to content

Instantly share code, notes, and snippets.

View maietta's full-sized avatar

Nick Maietta maietta

View GitHub Profile
@maietta
maietta / gist:d089d35805584bcf65ceed8abca803d4
Created May 8, 2021 22:38
Bigfoot Bite: Altering page titles sitewide.
// Place this in your /index.php, modified to your satisfaction.
// Hook into the end of dom to extend the F3 template engine to inject `{{ @page_title }}` for landing or `{{ @page_title }} | RETSQL` everywhere
// else and set to "Untitled Document" when not present.
Bigfoot::instance()->on("end_of_dom", function($dom){
$format = ( Base::instance()->get("PATH") != "/" ) ? '{{@page_title}} | RETSQL' : '{{@page_title}}';
$dom->getElementsByTagName('title')->item(0)->nodeValue = $format;
return $dom;
});
@maietta
maietta / gist:975af256a412d65f84d75b01cfdb9eda
Created February 5, 2021 23:24
Creds (Yes, this is public)
Username: 9m3nHcEQ47TO9a19
Password: L4nLj5hNkiWL31JQ
@maietta
maietta / gist:0f13dfb1ea071532e036fe937f81a4f7
Created July 30, 2020 21:39
Quick sFTP jail for sftp-only group
echo -n "User to create: " && read user && \
useradd -m $user && chsh -s /bin/bash $user && \
chr=/websites/$user && mkdir -pv $chr && chown -v root:root $chr && \
mkdir -pv $chr/home/$user && chown -Rv $user:$user $chr/home/$user && chmod -Rv 700 $chr/home/$user && \
usermod -aG sftp-only $user && \
mv $chr/.ssh/ /home/$user
@maietta
maietta / entry.sh
Last active July 24, 2020 00:12
Companion to nickmaietta/alpine-sshd image. DO NOTE DELETE!
#!/usr/bin/env bash
set -e
[ "$DEBUG" == 'true' ] && set -x
DAEMON=sshd
echo "> Starting SSHD"
@maietta
maietta / docker_events.sh
Created May 6, 2020 23:59 — forked from pragmasoft-ua/docker_events.sh
bash script to monitor and do something with docker events
#!/bin/sh
docker events --filter 'event=start' --filter 'event=stop' | while read event
do
container_id=`echo $event | sed 's/.*Z\ \(.*\):\ .*/\1/'`
echo $container_id
{
"require": {
"troydavisson/phrets": "2.*"
}
}
@maietta
maietta / gist:70b746c9497364a63b9bfbe36ec74f37
Last active January 28, 2019 07:10
PHP DOM. Find element, get parent, then find sibblings. Build JSON
<?php
$raw_content = file_get_contents("NBA_example.txt");
$dom = new DOMDocument;
$dom->loadHTML("$raw_content");
$block = $dom->getElementById("oddsGridContainer");
$results = [];
$assets = $block->getElementsByTagName('script');
@maietta
maietta / gist:6ba0cfd322f40c67536950a499ea9e84
Created January 25, 2019 16:44
PHRETS 2.x: Easy way to identify methods available for any object.
$objects = $rets->Search('Property', 'RE_1', '(L_ListingID=1800394)');
$test = get_class_methods($objects);
print_r($test);
// GIVES:
/*
Array
@maietta
maietta / command.txt
Last active April 22, 2019 14:49
PowerDNS on Ubuntu 18.04+
sudo systemctl disable systemd-resolved
sudo systemctl stop systemd-resolved
sudo ls -lh /etc/resolv.conf
sudo rm /etc/resolv.conf
sudo echo "nameserver 1.1.1.1" > /etc/resolv.conf
sudo apt-get update
sudo apt-get install pdns-server pdns-backend-mysql
@maietta
maietta / example.php
Created November 22, 2018 19:08
PHP: Return array of starting positions of all needles in a haystack
<?php
error_reporting(E_ALL);
$haystack = "An apple a day";
$needles = array("An", "da", "pp");
$array_of_starting_positions = findAnyNeedles($haystack, $needles, false); // This returns string by default.
header("Content-type: text/plain");