Skip to content

Instantly share code, notes, and snippets.

View DvdGiessen's full-sized avatar

Daniël van de Giessen DvdGiessen

View GitHub Profile
@DvdGiessen
DvdGiessen / 03-iscsi-target.sh
Last active March 9, 2024 12:10
iSCSI between SmartOS and Linux
#!/bin/bash
# Ensure disks are connected
[[ -e /dev/rdsk/c0t50014EE20CF94363d0 ]] || exit
[[ -e /dev/rdsk/c0t50014EE2B34C02BBd0 ]] || exit
[[ -e /dev/rdsk/c0t50014EE2B3AEA7EDd0 ]] || exit
# Enable SCSI target mode framework and iSCSI target
svcadm enable -r svc:/system/stmf:default
svcadm enable -r svc:/network/iscsi/target:default
@DvdGiessen
DvdGiessen / transip-dynamic-ip.sh
Last active March 19, 2022 22:42
Small dynamic DNS update script for a domain in TransIP
#!/bin/bash
# Script for automatically updating DNS records using the TransIP API.
# Supports IPv4 and IPv6 and can update both the primary domain as well as subdomains.
# Requires you to have curl, dig, and openssl installed.
#
# By Daniël van de Giessen, 2021-04-17
# https://www.dvdgiessen.nl
# Configuration
@DvdGiessen
DvdGiessen / launcher.asm
Created January 10, 2019 23:26
Simple process launcher for Windows written in x64 assembly
extrn GetStartupInfoW: PROC
extrn CreateProcessW: PROC
extrn ExitProcess: PROC
.data
target word 2eh, 2eh, 5ch, 42h, 61h, 73h, 65h, 5ch, 42h, 69h, 6eh, 61h, 72h
word 69h, 65h, 73h, 5ch, 57h, 69h, 6eh, 36h, 34h, 53h, 74h, 65h, 61h
word 6dh, 5ch, 43h, 69h, 76h, 69h, 6ch, 69h, 7ah, 61h, 74h, 69h, 6fh
word 6eh, 56h, 49h, 5fh, 44h, 58h, 31h, 32h, 2eh, 65h, 78h, 65h, 0
; ..\Base\Binaries\Win64Steam\CivilizationVI_DX12.exe as UTF-16
@DvdGiessen
DvdGiessen / keybase.md
Created December 19, 2018 22:17
Keybase proof

Keybase proof

I hereby claim:

  • I am dvdgiessen on github.
  • I am dvdgiessen (https://keybase.io/dvdgiessen) on keybase.
  • I have a public key ASC7oQ9D2rXNNiLdB5RRPfVI-x_yVGBrChvctVWNh8Lskgo

To claim this, I am signing this object:

@DvdGiessen
DvdGiessen / ByteReplacingInputStream.java
Last active September 24, 2018 12:11
Based on ideas from https://stackoverflow.com/questions/7743534/filter-search-and-replace-array-of-bytes-in-an-inputstream, but a bit more efficient by avoiding a lot of allocation for each processed byte. Still not great, but good enough for my usecase.
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
/** A bit more efficient byte replacing filter stream */
public class ByteReplacingInputStream extends FilterInputStream {
private final byte[] search, replacement;
private byte[] buffer;
private int bufferOffset, bufferEOL, replacementOffset;
@DvdGiessen
DvdGiessen / directadmin-dynamic-dns.sh
Created September 10, 2018 19:25
Simple dynamic DNS update script for a domain in DirectAdmin
#!/bin/bash
# Script for automatically updating the DNS records using the DirectAdmin API.
# Requires you to have curl, dig and json installed.
#
# By Daniël van de Giessen, 2018-09-10
# https://www.dvdgiessen.nl
# Configuration
DOMAINNAME="example.com"
@DvdGiessen
DvdGiessen / sortablefilterable.js
Last active July 7, 2023 10:04
JS function to make tables sortable and filterable
function sortableFilterable(tableElement) {
if (tableElement.tHead && tableElement.tHead.rows.length > 0) {
const headers = tableElement.tHead.rows.item(0).cells;
for (const header of headers) {
if (typeof header.dataset.sortType !== 'undefined' && ['auto', 'string', 'integer'].indexOf(header.dataset.sortType) >= 0) {
header.addEventListener('click', () => {
// Classes
const reverseSort = header.classList.contains('sorted') && !header.classList.contains('sorted-reverse');
for (const h of headers) {
h.classList.remove('sorted', 'sorted-reverse');
@DvdGiessen
DvdGiessen / index.php
Created July 22, 2018 13:53
Simple PHP file browser
<?php
// By Black / DvdGiessen
// http://www.dvdgiessen.nl/
// Layout based on Mozilla Firefox's file:// display
// Wheter to rewrite directory URL's to the form ?dir=PATH
// Disable if you have mod_rewrite/htaccess configured to rewrite directories to this script
$rewrite_directory_urls = FALSE;
// Skip hidden files?
<?php
/**
* Implementation for WP filter 'embed_oembed_html'.
* Modifies any iframes in the oEmbed's HTML to use a
* empty src-attribute, storing the original value in
* the data-src-attribute. A small piece of JavaScript
* can restore the src-attribute later.
* This is particularly useful for example to prevent
* external sites from setting cookies without the