Skip to content

Instantly share code, notes, and snippets.

# run-parts: Runs all the scripts found in a directory.
# keep going when something fails
set +e
if [ $# -lt 1 ]; then
echo "Usage: run-parts <directory>"
exit 1
fi
#!/usr/bin/env python3
"""
Tests http mirrors of cygwin
"""
import random
import time
from urllib.request import urlopen
import sys
__author__ = 'Dmitry Sidorenko'
@jameswebb68
jameswebb68 / gist:8014473
Last active December 31, 2015 16:38
For CYGWIN, check if windows x86_64 64-bit and windows is 7 through 8.1. redundant accurate check
# is Windows NT 6+
check-os-ver() {
local WMIC="$(wmic os get version | grep -oE ^6\.[2-3]{1})" # 6.0 - 6.3
local CYGW="$(uname -s | grep -oE 6\.[2-3]{1})" # 6.0 - 6.3
[[ -n "$WMIC" && -n "$CYGW" && "$WMIC" == "$CYGW" ]]
}
# is 64-bit windows
check-windows-arch() {
local WMIC="$(wmic OS get OSArchitecture /value | grep -o '64-bit')"
local PATH="$(cd -P "$(cygpath -W)"; cd ../Program\ Files\ \(x86\) 2>/dev/null && echo "64-bit")"
@jameswebb68
jameswebb68 / finfo.bash
Created January 3, 2014 19:26
Returns the Windows file details for any file using Cygwin bash (actual r-click-properties-info) to the term. ex: finfo notepad.exe finfo "C:\windows\system32\notepad.exe" finfo /cygdrive/c/Windows/System32/notepad.exe finfo "/cygdrive/c/Program Files/notepad.exe" finfo ../notepad.exe
#get file details from windows via wmic wmi formatted call
finfo() {
[[ -e "$(cygpath -wa "$@")" ]] || { echo "bad-file"; return 1; }
echo "$(wmic datafile where name=\""$(echo "$(cygpath -wa "$@")" | sed 's/\\/\\\\/g')"\" get /value)" |\
sed 's/\r//g;s/^M$//;/^$/d' | awk -F"=" '{print $1"=""\033[1m"$2"\033[0m" }'
}
@jameswebb68
jameswebb68 / open-explorer.bash
Created January 3, 2014 19:31
function to open explorer window for current working directory, provided absolute path, provided relative path, from within a cygwin ex: open (opens current working directory in an explorer window), open /home (opens home directory), open ../home
# open explorer directory relative, absolute or empty for current path
open() {
local var="$1"
[[ -z "$var" ]] && cygstart -x "$(cygpath -wa "$PWD")"
if [[ "${var:0:1}" == "/" ]]; then
[[ -d "$var" ]] || { echo "bad path"; return 1; }
cygstart -x "$(cygpath -wa "$var")"
elif [[ "${var:0:3}" == "../" ]]; then
[[ -d "$(cd "$var" 2>/dev/null && pwd)" ]] || { echo "bad path"; return 1; }
cygstart -x "$(cygpath -wa "$(cd "$var"; pwd)")"
@jameswebb68
jameswebb68 / gist:34ed19ed2b06d99c484b
Last active April 27, 2021 20:16
Synology Active Directory ADS join domain fix (suddenly nas lost connection to domain)
# Your NAS Synology device suddenly lost connection to your Windows Domain Controller, and or intermittent AD connectivity issues.
# Symptoms include but not limited to:
# - Failing to rejoin after removing the account on the Domain.
# - Failing to rejoin without any changes
# - Join attempt results in = "Failed to join the Windows domain. Please check your domain and firewall settings and try again"
# - Synology is joined, but attempting to connect from domain clients results in "There are no logon servers available to service the logon request"
# - This problem happens intermittently, sometimes rebooting the Synology device allows you to rejoin (Not a solution).
# - Sometimes rebooting both Synology device and Domain Controller allows you to rejoin (Not a solution).
# 1st.) *OPTIONAL* Remove the AD Synology device from Avtice Directory Users/Computers.
@jameswebb68
jameswebb68 / hosts.fix.sh
Created October 26, 2014 18:47
bind-utils host on cygwin not piping stdout correctly fix
# temporary fix for Cygwin 1.7.32 - 1.7.33+ and bind-utils
# rolls windows builtin nslookup into bash function
# outputs exactly how bind-utils output so that host calls in other places don't break
# source this file, roll your own, or insert into existing shell scripts
# quick and dirty, but effective, untested on zsh and ash
# Jon Retting @ 10/26/2014
#TEMP host.exe fix for output
# check to make sure ip is valid
@jameswebb68
jameswebb68 / Get-ADtop.ps1
Last active April 7, 2017 16:29
Retrieves gets CPU usage, Memory usage, and OS Disk storage usage details from Active Directory domain joined Windows computers
# Get-ADtop
# @ JMR 2012 All right reserved, not for resale
#
# Retrieves Realtime CPU/MEM/DISK usage details from
# AD Computer Objects via provided BaseDN
# Or from provided ComputerName
# Probes computer names for connectivity before executing
#
# -SampleTime is the amount of time to sample the CPU usage and provide avg