Skip to content

Instantly share code, notes, and snippets.

View kiler129's full-sized avatar

Gregory House kiler129

  • noFlash
  • Chicago, IL (USA)
View GitHub Profile
@kiler129
kiler129 / replace-cert.sh
Last active August 10, 2023 09:25
Replace certificate for an isolated service running on TrueNAS SCALE and restart the service if needed
#!/bin/bash
#set -e
set -o errexit -o pipefail -o noclobber -o nounset
if [ "$#" -ne 4 ]; then
echo "Usage: ${0} CertTargetDir CertName OutputFormat<pem|p12> AssociatedService"
exit 1
fi
certTargetDir="${1}"
@kiler129
kiler129 / watchdog.c
Created October 31, 2020 02:13
Simple process watchdog & restarter
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
int main(int argc, char* argv[]) {
char *args[]={argv[0], "UDP4-LISTEN:123,fork", "UDP:example.com:123", NULL};
setuid(0);
pid_t pid;
@kiler129
kiler129 / prevent-host-driver-in-pci-pass.md
Last active April 25, 2025 14:32
Definitely prevent stubborn devices from being bound by the host driver in PCI passthrough scenario

Scenario

You're running a KVM-based virtualization. You want to do PCI/PCIe passthrough of some device. You don't want it to attach to the host OS at all.

Your device looks like that:

00:1f.2 SATA controller [0106]: Intel Corporation 6 Series/C200 Series Chipset Family SATA AHCI Controller [8086:1c02] (rev 05)
	Subsystem: Hewlett-Packard Company 6 Series/C200 Series Chipset Family 6 port Desktop SATA AHCI Controller [103c:330d]
	Kernel driver in use: ahci
	Kernel modules: ahci
@kiler129
kiler129 / README.md
Last active June 4, 2025 23:27 — forked from seeker2921/ilo-console.sh
Run iLO remote console from shell

iLO Remote Console

This small script lets you start iLO Java-based console from shell.

But why not HTML5?

  • iLO 2/3 doesn't have HTML5 console
  • Mounting local (from the client computer) ISOs is PAINFULLY slow via HTML5 client

TL;DR

If you just start it, it will ask you for everything:

@kiler129
kiler129 / composer.json
Created July 19, 2020 21:03
PHP Code Quality
{
"type": "project",
"license": "MIT",
"minimum-stability": "dev",
"prefer-stable" : true,
"require": {
"php-64bit": "^7.4.0"
},
"require-dev": {
"object-calisthenics/phpcs-calisthenics-rules": "^3.7",
@kiler129
kiler129 / RATZEROTHE.B
Created October 21, 2018 05:24
Rational Zero Theorem implementation in TI-Basic
Define rzt(l,c)=
Prgm
: If l=0 Then
: Disp "ERR:l=0"
: Stop
: EndIf
: If c=0 Then
: Disp "ERR:c=0"
: Stop
: EndIf
diff -Naur libevent-master/http.c libevent-master-mod2/http.c
--- libevent-master/http.c 2016-11-18 11:58:08.000000000 -0600
+++ libevent-master-mod2/http.c 2016-11-27 01:30:06.726038913 -0600
@@ -192,13 +192,14 @@
static void evhttp_write_buffer(struct evhttp_connection *,
void (*)(struct evhttp_connection *, void *), void *);
static void evhttp_make_header(struct evhttp_connection *, struct evhttp_request *);
+static int evhttp_method_may_have_body_(struct evhttp_connection *, enum evhttp_cmd_type);
/* callbacks for bufferevent */
PHP Compilation x64
——————————
+++++++++++++++++++++++++
+ 7.3.7 @ Debian/Ubuntu +
+++++++++++++++++++++++++
./configure \
--prefix=/usr/local/lsws/lsphp73 \
--enable-cli \
--disable-cgi \
#!/usr/bin/php
<?php
if(!isset($argv[1])) die("No prefix!\n");
define('DRY_RUN', (!isset($argv[2]) || $argv[2] !== '-r'));
define('F_PREFIX', (empty($argv[1])) ? '' : ($argv[1] . '.'));
if(DRY_RUN) echo "-- DRY RUN --\n\n";
$fi = new FilesystemIterator('./');
$ri = new RegexIterator($fi, '/(?:(?:(\d?\d)x(\d\d))|(?:s(\d\d)e(\d\d))).*?\.([a-z]{3,4})$/i', RegexIterator::GET_MATCH);
@kiler129
kiler129 / CheckSwotDomains.php
Last active June 24, 2020 03:31
This tool can be used to verify domains in Swot project (https://github.com/leereilly/swot) by checking A/AAAA and MX records for them. It's horribly written in 10 minutes, but works ;)
<?php
define('DOMAINS_DIRECTORY', 'lib/domains/');
function path2Domain($path, $prefix = DOMAINS_DIRECTORY)
{
$prefixPos = strpos($path, $prefix);
if ($prefixPos !== 0) {
throw new InvalidArgumentException('Path does not begin with given prefix');
}