Skip to content

Instantly share code, notes, and snippets.

View dbroeglin's full-sized avatar

Dominique Broeglin dbroeglin

View GitHub Profile
module ApplicationHelper
class BulmaFormBuilder < ActionView::Helpers::FormBuilder
delegate :tag, :safe_join, to: :@template
def input(method, options = {})
@form_options = options
object_type = object_type_for_method(method)
input_type = input_type_for_object_type(object_type, options)
send("#{input_type}_input", method, options)
@dbroeglin
dbroeglin / New-NSVirtualBoxInstance.ps1
Last active January 15, 2020 08:11
Generates a new VirtualBox Netscaler instance from a Netscaler VPX ESX package.
<#
.SYNOPSIS
Generates a new VirtualBox Netscaler instance from a Netscaler VPX ESX package.
.PARAMETER Package
Location of the VPX package to use.
.PARAMETER VMName
@dbroeglin
dbroeglin / ShuttingDown.ps1
Last active October 3, 2016 18:45
An excerpt from Vagrant that illustrates use of C# inside PowerShell
function ShuttingDown {
[string]$sourceCode = @"
using System;
using System.Runtime.InteropServices;
namespace Vagrant {
public static class RemoteManager {
private const int SM_SHUTTINGDOWN = 0x2000;
[DllImport("User32.dll", CharSet = CharSet.Unicode)]
@dbroeglin
dbroeglin / Trace-SPNs.ps1
Created April 17, 2016 17:10
Extract domain, principal and SPN from Kerberos TGS-REP messages
[CmdletBinding()]
Param (
[Parameter(ValueFromPipeline = $True, Mandatory = $True)]
[String]$PcapFile,
[String]$WireSharkPath = "C:\Program Files\Wireshark"
)
$TempFile = [System.IO.Path]::GetTempFileName()
@dbroeglin
dbroeglin / Compare-Hashtable.Tests.ps1
Last active December 16, 2024 09:37
A simple Compare-Hashtable function for powershell
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
. "$here\$sut"
Describe "Compare-Hashtable" {
Context "When both are empty" {
$Left, $Right = @{}, @{}
It "should return nothing" {
Compare-Hashtable $Left $Right | Should BeNullOrEmpty
@dbroeglin
dbroeglin / ShutdownableProxy.java
Created June 12, 2015 18:20
Java Proxy that exposes a management interface
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
public class ShutdownableProxy {
public static interface Service {
public void doit();
}
@dbroeglin
dbroeglin / 0-ssh.pp
Last active August 29, 2015 14:07
Soft-Shake 2014 / Automating your infrastructure with Puppet
class ssh {
package { openssh: ensure => installed }
}