Skip to content

Instantly share code, notes, and snippets.

@IISResetMe
IISResetMe / ConvertTo-Object.ps1
Last active July 25, 2023 23:12
Quick and dirty regex-based text-to-object parsing using named expressions groups and $Matches
function ConvertTo-Object {
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[AllowEmptyString()]
[string[]]$InputString,
[Parameter(Mandatory=$true,ValueFromRemainingArguments=$true)]
[string[]]$Pattern
)
@Vartkat
Vartkat / buildresticexcludes.sh
Last active December 23, 2023 05:29
Bash script to build a restic exclude list that mimics Apple TimeMachine exclude list
#!/bin/bash
# This script intend to mimic TimeMachine exclude list.
# As the exclude list can evolve between backups it has to be rebuilt before every backup
# Apple uses 5 types of excludes, four from the /System/Library/CoreServices/backupd.bundle/Contents/Resources/StdExclusions.plist file
# and files from applications where metadata says to not backup, these can be found usinf
# sudo mdfind "com_apple_backup_excludeItem = 'com.apple.backupd'"
SYSLOG=/usr/bin/syslog;
TEMPFILE=$1;
@BlaM
BlaM / cookiebanner-go-away.user.js
Last active April 24, 2024 18:01
Get rid of EU Cookie Banners (Tampermonkey)
// ==UserScript==
// @name Get rid of EU Cookie Banners
// @namespace http://blog.deobald.org/
// @description Get rid of EU Cookie Banners
// @license http://creativecommons.org/licenses/by-nc-sa/3.0/
// @downloadURL https://gist.githubusercontent.com/BlaM/6d826d6e9d77d2d77bf9a92fdad55788/raw/cookiebanner-go-away.user.js
// @homepage https://gist.github.com/BlaM/6d826d6e9d77d2d77bf9a92fdad55788
// @version 0.3.4
// @author Dominik Deobald
// @match http*://*/*
@Jaykul
Jaykul / Start-Demo.ps1
Last active December 2, 2022 08:55
Doing demos with just PSReadLine
function Start-Demo {
[CmdletBinding()]
param(
# A history file with a command on each line (or using ` as a line-continuation character)
[Parameter(Mandatory)]
[Alias("PSPath")]
[string]$Path
)
[Microsoft.PowerShell.PSConsoleReadLine]::ClearHistory()
@ruanbekker
ruanbekker / cheatsheet-elasticsearch.md
Last active April 24, 2024 00:11
Elasticsearch Cheatsheet : Example API usage of using Elasticsearch with curl
@gboudreau
gboudreau / AuthyToOtherAuthenticator.md
Last active May 12, 2024 00:29 — forked from Ingramz/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy
@twolfson
twolfson / README.md
Last active January 22, 2024 07:32
Setting up SOPS

I'm learning about SOPS and setting it up as my preferred mechanism for storing secrets. Here are my notes.

PGP

It’s security mechanism is that we (i.e. client) use a PUBLIC key from the receiver (i.e. server) and encode it with a random key (I’m saying nonce but it could be reused)

This varies from RSA and SSH because the server uses a PUBLIC key to identify the client.

Web of trust

Web of trust operates by still using PGP (i.e. encoding with recipient’s public key) but additionally, we can encrypt/sign the data as our own by signing it with the client’s private key.

This means the recipient will initially decrypt via our (i.e. client’s) public key (verifying the source) and then decrypting via their (i.e. server’s) private key to get the data.

@JustinGrote
JustinGrote / Get-WinEventXPathFilter.ps1
Last active October 4, 2023 14:55
Get-WinEventXPathFilter
Function Get-WinEventXPathFilter
{
<#
.SYNOPSIS
This function generates an xpath filter that can be used with the -FilterXPath
parameter of Get-WinEvent. It may also be used inside the <Select></Select tags
of a Custom View in Event Viewer.
.DESCRIPTION
This function generates an xpath filter that can be used with the -FilterXPath
parameter of Get-WinEvent. It may also be used inside the <Select></Select tags
@jpoehls
jpoehls / example.ps1
Created April 28, 2015 14:45
Symlink support in PowerShell V5 *-Item cmdlets
### SYMBOLIC LINK FILES
# Create a new symbolic link file named MySymLinkFile.txt in C:\Temp which links to $pshome\profile.ps1
cd C:\Temp
New-Item -ItemType SymbolicLink -Name MySymLinkFile.txt -Target $pshome\profile.ps1 # File
# Target is an alias to the Value parameter
# Equivalent to above
New-Item -ItemType SymbolicLink -Path C:\Temp -Name MySymLinkFile.txt -Value $pshome\profile.ps1
# Equivalent to above
@holman
holman / emoji_test.rb
Last active June 18, 2020 01:27
A snapshot of the tests we use internally at GitHub to help edit our blog posts before they go out to everybody. For more information, take a peek at http://zachholman.com/posts/how-github-writes-blog-posts
require_relative "test_helper"
require "open-uri"
require "net/http"
class EmojiTest < Blog::Test
def test_no_emoji
posts.each do |post|
content = File.read(post)
refute_match /:[a-zA-Z0-9_]+:/, content,