Skip to content

Instantly share code, notes, and snippets.

@alexlovelltroy
alexlovelltroy / reassign.sh
Created December 18, 2014 20:33
reallocate unassigned shards in elasticsearch
NODE="a hostname"
IFS=$'\n'
for line in $(curl -s 'localhost:9200/_cat/shards' | fgrep UNASSIGNED); do
INDEX=$(echo $line | (awk '{print $1}'))
SHARD=$(echo $line | (awk '{print $2}'))
curl -XPOST 'localhost:9200/_cluster/reroute?pretty' -d '{
"commands": [
{
"allocate": {
@vScripter
vScripter / Start-PowerCLI.ps1
Last active March 22, 2017 15:09
PowerCLI 'loader' function
function Start-PowerCLI {
<#
.NOTES
Loads PowerCLI, depending on what version you have installed. Set the default -Version parameter, depending in your environment.
#>
[cmdletbinding()]
param (
[parameter(Mandatory = $false, Position = 0)]
@mrmx
mrmx / wallet-balance.sh
Created September 11, 2016 11:25
Get balance of rusty bitcoin wallet.dat for all addrs in bash
#!/bin/bash
#
# Depends on:
# pywallet.py from https://github.com/pagobit/pywallet
# jq from https://stedolan.github.io/jq
for addr in $(./pywallet.py --dumpwallet | jq --raw-output ".keys[].addr"); do
echo "$addr balance:";
curl https://insight.bitpay.com/api/addr/$addr/balance;
echo "";
@Chris-ZA
Chris-ZA / Delete Obsolete WSUS Updates.sql
Last active February 6, 2018 20:53
Script to Delete Obsolete WSUS Updates
-- This script deletes all obsolete WSUS updates from a WSUS database.
-- For more information, visit http://thebashfuladmin.com/2016/05/13/workaround-for-wsus-sql-timeout-errors/
USE SUSDB
DECLARE @UpdateID INT
DECLARE @message varchar(1000)
CREATE TABLE #ObsoleteUpdatesToCleanup (UpdateID INT)
@onesail
onesail / load-xml-src.js
Created June 3, 2016 23:01
add support for src attribute in strapdown.js
<!-- usage -->
<!-- <xmp src="homepage.md" theme="cerulean" style="display:none;"></xmp> -->
<!-- <script src="load-xmp-src.js"></script> -->
var elements = document.body.getElementsByTagName("*");
for(var i=0; i<elements.length; i++) {
var element = elements[i];
if(element.nodeName == "XMP") {
var xhr = new XMLHttpRequest();
xhr.open('GET', element.getAttribute("src"), false);
@Mark-Booth
Mark-Booth / git-branch-status
Last active August 19, 2019 16:00 — forked from lth2h/git-branch-status
Version of git-branch-status which only shows the current branch and only generates output if a branch is ahead or behind.Added options to:* Show all branches (revert to the old behaviour)* Show output even if the branch isn't ahead or behind (revert to the old behaviour)* Show branch(es) with respect to origin/master (inspired by git-branches-v…
#!/bin/bash
# hosted at https://gist.github.com/Mark-Booth/5058384
# forked from https://gist.github.com/lth2h/4177524 @ ae184f1 by mark.booth
# forked from https://gist.github.com/jehiah/1288596 @ e357c1e by lth2h
# ideas from https://github.com/kortina/bakpak/blob/master/bin/git-branches-vs-origin-master
# this prints out some branch status
# (similar to the '... ahead' info you get from git status)
# example:
@D4rKP01s0n
D4rKP01s0n / wifiscanner.py
Created November 11, 2016 23:06
A simple python script which records and logs wifi probe requests.
#########################################################################
# Wifiscanner.py - A simple python script which records and logs wifi probe requests.
# Author - D4rKP01s0n
# Requirements - Scapy and Datetime
# Inspiration - Tim Tomes (LaNMaSteR53)'s WUDS https://bitbucket.org/LaNMaSteR53/wuds/
# Reminder - Change mon0 (around line 65) to your monitor-mode enabled wifi interface
#########################################################################
from datetime import datetime
@dav3860
dav3860 / gist:5345656
Last active April 27, 2020 11:38
Cisco ASA/PIX config for logstash.
/etc/logstash/logstash.conf :
# We handle the syslog part of the Cisco PIX/ASA messages
grok {
tags => "cisco-fw"
patterns_dir => "/etc/logstash/patterns"
pattern => "^<%{POSINT:syslog_pri}>(?:(%{TIMESTAMP_ISO8601:timestamp8601} |%{CISCOTIMESTAMP:timestamp} ))?%{SYSLOGHOST:logsource}?[ :]+%{GREEDYDATA:syslog_message}"
}
syslog_pri {
tags => "cisco-fw"
@meoso
meoso / shotcut.sh
Last active December 3, 2020 17:45
Shotcut launcher bash script
#!/bin/bash
#assumes new downloads of shotcut is always in ~/Downloads
currpath=$(pwd)
cd ~/Downloads
chmod +x ./[Ss]hotcut-*.AppImage
#always choose the latest Shotcut-*.AppImage download
shotcut=$(ls -Art [Ss]hotcut-*.AppImage | tail -n 1 | cut -d' ' -f 9-)
cd "${currpath}"
$OU="OU=TheOUName,DC=yourdomain,DC=com"
$ShadowGroup="CN=ShadowGroupName,OU=TheOUName,DC=yourdomain,DC=com"
Import-Module ActiveDirectory
(Get-ADGroup -Identity $ShadowGroup -properties members).Members | Get-ADUser | Where-Object {$_.distinguishedName –NotMatch $OU} | ForEach-Object {Remove-ADPrincipalGroupMembership –Identity $_ –MemberOf $ShadowGroup –Confirm:$false}
Get-ADUser –SearchBase $OU –SearchScope OneLevel –LDAPFilter "(!memberOf=$ShadowGroup)" | ForEach-Object {Add-ADPrincipalGroupMembership –Identity $_ –MemberOf $ShadowGroup}