Skip to content

Instantly share code, notes, and snippets.

View joshbtn's full-sized avatar

Josh Bennett joshbtn

View GitHub Profile
@joshbtn
joshbtn / FindBrokenLinks.ps1
Last active August 13, 2021 20:31
FindBrokenLinks.ps1
@joshbtn
joshbtn / formats_parse.js
Last active November 5, 2019 04:26
quick check of yt compatible formats
//type and url dictionary
ytplayer.config.args.adaptive_fmts
.split(',')
.map((format) => format.split('&'))
.reduce((a, cv) => {
a[decodeURIComponent(cv[0].split("=")[1])] = decodeURIComponent(cv[1].split("=")[1]);
return a;
}, {})
// All props as arrays
@joshbtn
joshbtn / Vagrantfile
Created November 12, 2015 18:10 — forked from tvjames/Vagrantfile
Prepare a Windows Server 2008 R2 instance for use with vagrant-windows.
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
@joshbtn
joshbtn / gist:d6bffe7d94a9785aabda
Created November 11, 2015 17:47
Search active directory from powershell
([adsisearcher]"samaccountname=prefix-*").FindAll().Properties.cn
([adsisearcher]"(&(objectcategory=computer)(samaccountname=prefix-*))").FindAll().Properties.cn
@joshbtn
joshbtn / Get All Results
Last active September 4, 2015 17:04
PowerShell helpers for Rest
#Get all results when rest endpoints paginate.
function Get-All-RestMethod ($CurrentObj, [int] $Skip, [string] $Uri, [hashtable] $Headers){
$results = Invoke-RestMethod -Uri "$Uri`?skip=$skip" -Headers $Headers
$ItemsPerPage = [int]$results.ItemsPerPage
$TotalResults = [int]$results.TotalResults
$NextSkip = $skip + $ItemsPerPage
if( ($TotalResults - $NextSkip) -gt 0 ){
$results = Get-All-RestMethod $results $NextSkip "$Uri" $Headers
@joshbtn
joshbtn / gist:a947e2828c7fac242104
Created August 19, 2015 17:28
Stupid simple mustash template expander
# Stupid simple mustash template expander
function Expand-Template(){
param(
[string] $template,
[hashtable] $scope
)
return iex $($template -replace '{{([^}]+)}}', "`$(`$scope.Get_Item('`$1'))")
}
@joshbtn
joshbtn / gist:fc004e647b64463140e6
Created August 3, 2015 15:11
Delete bogus build tags
git push origin $(git tag | egrep -ie "build-[0-9]+$" | awk '{print ":" $0}')
@joshbtn
joshbtn / Remove remote branches except for master
Last active August 29, 2015 14:12
Match and remove remote branches
git push origin $(git for-each-ref --format "%(refname)" refs/remotes | cut -d"/" -f4- | grep -Eiv '(^HEAD|^master)' | awk '{print ":"$1}')
@joshbtn
joshbtn / findAndReplace.ps1
Created December 4, 2014 17:04
Find and replace
#Find and replace
$fileNameMatch = "\.html|\.txt"
$find = ""
$replace = ""
$webFiles = get-childitem . -Recurse | Where-Object {$_.Name -match $fileNameMatch}
foreach ($file in $webFiles)
{
Write-Host $file
@joshbtn
joshbtn / copyFilesFromDiff.sh
Last active August 29, 2015 14:09
Git - grab files from diff
#!/bin/bash
branch=$1
output=$2
(IFS=$'\n'; git archive -o $output $branch $(git diff @{0} $branch --name-only --diff-filter=ACM))