Skip to content

Instantly share code, notes, and snippets.

@countingpine
countingpine / check_microsoft_windows_software_raid.ps1
Last active October 2, 2024 08:38 — forked from schakko/check_microsoft_windows_software_raid.ps1
A simple PowerShell script for retrieving the RAID status of volumes with help of diskpart.The nicer solution would be using WMI (which does not contain the RAID status in the Status field of Win32_DiskDrive, Win32_LogicalDisk or Win32_Volume for unknown reason) or using the new PowerShell API introduced with Windows 8 (wrong target system as ou…
# A simple PowerShell script for retrieving the RAID status of volumes with help of diskpart.
# The nicer solution would be using WMI (which does not contain the RAID status in the Status field of Win32_DiskDrive, Win32_LogicalDisk or Win32_Volume for unknown reason)
# or using the new PowerShell API introduced with Windows 8 (wrong target system as our customer uses a Windows 7 architecture).
#
# diskpart requires administrative privileges so this script must be executed under an administrative account if it is executed standalone.
# check_mk has this privileges and therefore this script must only be copied to your check_mk/plugins directory and you are done.
#
# Christopher Klein <ckl[at]neos-it[dot]de>
# This script is distributed under the GPL v2 license.
@countingpine
countingpine / mongo_prune_js.js
Created August 24, 2023 13:02 — forked from arevindh/mongo_prune_js.js
mongo_prune_js.js
// keep N-day worth of data
var days=7;
// change to false to have the script to really exclude old records
// from the database. While true, no change at all will be made to the DB
var dryrun=true;
var now = new Date().getTime(),
time_criteria = now ;
time_criteria_in_seconds = time_criteria / 1000;
@countingpine
countingpine / nc.php
Created June 22, 2023 16:46 — forked from miguelmota/nc.php
PHP send message to socket server (netcat)
<?php
$payload = 'hello world';
$stream = stream_socket_client("tcp://127.0.0.1:5555", $errno, $errstr);
if (!$stream) {
echo "{$errno}: {$errstr}\n";
die();
}
fwrite($stream, $payload);
stream_socket_shutdown($stream, STREAM_SHUT_WR);
@countingpine
countingpine / mp3.txt
Created March 16, 2023 10:35
MPEG format dump utility by Ralph Giles - https://svn.xiph.org/experimental/giles/mp3dump.c
MP3 header is 32 bits
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| sync word |V| L |E| rate |frq|P|R| mode |C|O|EM |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
sync word = 1111 1111 111x (x is zero for MPEG 2.5 VBR extension)
V (version) 1 = MPEG
@countingpine
countingpine / example.sh
Last active November 15, 2023 13:42
SimpleHTTPUploadServer (from https://stackoverflow.com/a/58255859/446106 by smidgey)
# https://stackoverflow.com/a/58255859/446106
HOST=1.2.3.4
FILE1=foo.txt
FILE2=bar.txt
# Running the server on your host:
python3 ./httpupload.py
# Download a file from your host:
@countingpine
countingpine / h4slAAA.md
Last active March 2, 2024 19:17
h4slAAA

H4sIAAA... is the start of a base64-encoded gzipped string.

H4sI
H4sIA
H4sIAA
H4sIAAA
H4sIAAAA
H4sIAAAAA
H4sIAAAAAA
#!/bin/sh
# https://redmine.pfsense.org/attachments/1440
# curl -s https://gist.githubusercontent.com/countingpine/3556e5ee09d56465ca9da081e202f46b/raw/_update_oui.sh | sh
#
# Run me to update the file in the package repo.
#
OUI_URL=http://standards-oui.ieee.org/oui/oui.txt
OUI_FILE=/usr/local/share/nmap/nmap-mac-prefixes
#OUI_FILE=nmap-mac-prefixes
TEMP_FILE=/tmp/oui-prefixes.txt
@countingpine
countingpine / duwatch.sh
Created January 16, 2021 10:56
duwatch.sh
#!/bin/bash
# watch du output every 10s, return size in KB/MB/GB, difference in KB/MB
# (Assumes du output is in KB)
set -u
path="${1:-.}"
while du -s "$path"; do sleep 10; done |
awk '{printf "%dK\t%dM\t%dG\t+%dK\t+%dM\n", $1, $1/1024, $1/1048576, ($1-old), ($1-old)/1024 ; old = $1}'
KBD English "United Kingdom - Apple"
COPYRIGHT "(c) 2010 Stephane Moreau"
COMPANY "Stephane Moreau"
LOCALENAME "en-GB"
LOCALEID "00000809"
@countingpine
countingpine / dnsmadeeasy.ps1
Last active October 20, 2020 13:17
DNS Made Easy - Dynamic DNS Updater in PowerShell
$ID = 123456789
$PASSWORD = "%68%75%6e%74%65%72%32"
$DIR = $env:USERPROFILE
$WHATSMYIP_URL = "https://ifconfig.me/ip"
$oldip = (Get-Content "$DIR\ddns-publicip.txt")
$ip = (Invoke-RestMethod $WHATSMYIP_URL)
if ($ip -ne $oldip) {