Skip to content

Instantly share code, notes, and snippets.

@meoso
meoso / all-git-status.sh
Last active April 26, 2017 15:17
show git status for all local repos found under given path
#!/bin/bash
######################################################################
# purpose : show git status for all local repos found under given path
# author : njd
# created : 2017-Apr-21
# usage : ./all-git-status.sh [path] [| less -r]
######################################################################
ESC="\033"
NORMAL="$ESC[m"
@meoso
meoso / pull-all-gits.sh
Last active April 24, 2017 12:49
"git pull" all sub .gits for a given path
#!/bin/bash
#######################################################
# purpose : "git pull" all sub .gits for a given path
# author : njd
# created : 2015-03-05
# modified : 2017-04-21
# usage : ./pull-all-gits.sh [path]
#######################################################
ESC="\033"
@meoso
meoso / start_minecraft_server.sh
Created April 26, 2017 15:11
minecraft (spigotmc) server start script (run inside gnu screen)
#!/bin/bash
# edit username
username='username' #because i autostart in init.d, i dont want to execute as root
cd ~/minecraft/server || exit 1
case $1 in
"1.10")
server="spigot-1.10.jar";;
@meoso
meoso / gitstatus.sh
Last active June 15, 2017 20:32
ghetto bash-prompt git-status
# append your ~/.bashrc to include
# PROMPT_COMMAND=~/path/to/gitstatus.sh
# skip a line irregardless
echo
echo $'\e[7m' $(date +"%b %d; %H:%M:%S")' '$'\e[m' #date in reverse color
# only run if in a git repo root
if [[ -e .git ]] ; then
#if you dont want to see modified files, uncomment pipe to head
@meoso
meoso / shift_state.c
Last active February 3, 2020 04:28
linux keyboard return shift-key pressed state
#include <sys/ioctl.h>
#include <asm/ioctls.h>
#include <stdio.h>
#include <fcntl.h>
// code by "dma" via https://forums.gentoo.org/viewtopic-p-2455159.html#2455159
int main(int argc, char *argv[]) {
int fd;
char shift_state;
@meoso
meoso / awesomeview.sh
Created June 15, 2017 20:35
AwesomeView.sh - Largest Folders and Files - Found this script online somewhere and modified it slightly
#!/bin/sh
if [ "$1" = "" ] ; then
folder=$(pwd)
else
folder=$1
fi
echo ""
date
@meoso
meoso / RequiresReboot.ps1
Created June 28, 2017 13:04
Powershell function to determine if machine requires reboot.
<#
Powershell function to determine if machine requires reboot.
by Michael Simmons : http://ilovepowershell.com/2015/09/10/how-to-check-if-a-server-needs-a-reboot/
Adapted from https://gist.github.com/altrive/5329377
Based on <http://gallery.technet.microsoft.com/scriptcenter/Get-PendingReboot-Query-bdb79542>
#>
function Test-PendingReboot
{
if (Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" -EA Ignore) { return $true }
if (Get-Item "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" -EA Ignore) { return $true }
@meoso
meoso / remmina.sh
Last active July 19, 2017 18:42
remmina wrapper - script to launch remmina from xfce panel launcher; also re-focuses; also kills
#!/bin/bash
shift_state=$(sudo ~/scripts/shift_state) #https://gist.github.com/meoso/b46b441b31344804c6837829e059c2b8
if (( $shift_state )) ; then
killall remmina
rm -f ~/.freerdp/known_hosts
else
RWindow=""
RWindow=$(wmctrl -l | grep "Remmina Remote Desktop Client")
if [ -z "$RWindow" ]
$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}
@meoso
meoso / rdpcli.csv
Last active March 24, 2022 16:18
xfreerdp bash commandline wrapper - Simple bash script to launch xfreerdp against csv file of clients
Title Host Username Domain Resolution AdditionalParams
user@example host01 username domain.com 1920x1200 +clipboard /cert-tofu
anothermachine machine74 username domain.com 1920x1200 +clipboard /cert-tofu
admin@thatothermachineiforget examplehostname administrator domain.com 1920x1200 +clipboard /cert-tofu