Skip to content

Instantly share code, notes, and snippets.

View Wimpje's full-sized avatar
🦕

Wim Wimpje

🦕
  • The Netherlands
View GitHub Profile
@Wimpje
Wimpje / SplitXml.ps1
Last active February 8, 2023 12:46
Powershell, split large XML files on node name, with offset support
param( [string]$file = $(throw "file is required"), $matchesPerSplit = 50, $maxFiles = [Int32]::MaxValue, $splitOnNode = $(throw "splitOnNode is required"), $offset = 0 )
# with a little help of https://gist.github.com/awayken/5861923
$ErrorActionPreference = "Stop";
trap {
$ErrorActionPreference = "Continue"
write-error "Script failed: $_ \r\n $($_.ScriptStackTrace)"
exit (1);
}
@Wimpje
Wimpje / SplitFile.ps1
Created December 8, 2014 10:06
Split files with Powershell
param( [string]$file = $(throw "file is required"),$maxFiles = [Int32]::MaxValue, $upperBound = 500MB )
# with a little help of https://gist.github.com/awayken/5861923
$ErrorActionPreference = "Stop";
trap {
$ErrorActionPreference = "Continue"
write-error "Script failed: $_ \r\n $($_.ScriptStackTrace)"
exit (1);
}
@Wimpje
Wimpje / iis.py
Created August 23, 2016 09:16 — forked from adamwitko/iis.py
Example Datadog IIS log line parser
import time
from datetime import datetime
def parse_iis(logger, line):
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) cs-host sc-status sc-substatus sc-win32-status time-taken
line_date, line_time, server_ip, cs_method, cs_uri_stem, cs_uri_query, server_port, cs_username, client_ip, cs_user_agent, cs_referer, cs_host, status_code, sub_status, win32_status, time_taken = line.split()
dt = datetime.strptime(line_date+"T"+line_time, "%Y-%m-%dT%H:%M:%S")
dt = time.mktime(dt.timetuple())
@Wimpje
Wimpje / Remove-NonAliasedIndices.ps1
Created July 13, 2017 10:39
Removes Elastic search indices that don't have an alias (probably old or test indices) WARNING REMOVES WITHOUT CONFIRMATION
$i = (invoke-webrequest http://localhost:9200/_alias | ConvertFrom-Json); $i.psobject.properties.name | where { $i.$_.aliases.psobject.properties.name -eq $null } | % {Write-Host (invoke-webrequest -method DELETE -uri "http://localhost:9200/$_") }
@Wimpje
Wimpje / ssl_puma.sh
Created October 20, 2017 11:18 — forked from tadast/ssl_puma.sh
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@Wimpje
Wimpje / karabiner-pc-style-mods.json
Last active November 8, 2019 10:34
Karabiner PC modifications, based on https://pqrs.org/osx/karabiner/complex_modifications/#pc_shortcuts but added some more & exclusion for IntelliJ (shortcuts interfered with visual studio keybinding mode)
{
"title": "PC-Style Shortcuts - Edited & extended by wimpje",
"rules": [
{
"description": "ctrl + shift + home key to the select everything until beginning of the sentence (Shift + Command + Left). Doesnt work in terminal",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "home",