This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import boto3 | |
| from boto3 import ec2 | |
| import datetime | |
| import re | |
| from datetime import date | |
| def is_attached(image, snapshot): | |
| for mapping in image['BlockDeviceMappings']: | |
| # Is it a machine ephemeral device? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :: simple version | |
| $env:path.Split(';') | gci -Filter application.exe | |
| :: expanded version | |
| $env:path.Split(';') | select -Unique | ? {$_ -and (test-path $_)} | gci -Filter application.exe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $OldBase="C:\src\main\java" | |
| $NewBase="C:\src\main\resources" | |
| $HibernateFiles=Get-ChildItem $OldBase -Include *.xml -Recurse | |
| foreach ($file in $HibernateFiles) { | |
| Write-Host $file.FullName | |
| $Directory=$file.Directory.ToString() | |
| $Directory=$Directory.replace($OldBase, $NewBase) | |
| $OldFile=$file.FullName | |
| $NewFile=$OldFile.replace($OldBase, $NewBase) | |
| New-Item $Directory -ItemType Directory -ea 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| stats=”” | |
| echo "% user" | |
| echo "============" | |
| # collect the data | |
| for user in `ps aux | grep -v COMMAND | awk '{print $1}' | sort -u` | |
| do | |
| stats="$stats\n`ps aux | egrep ^$user | awk 'BEGIN{total=0}; \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Original: https://serverfault.com/questions/341919/how-to-find-error-messages-from-linux-init-d-rc-d-scripts | |
| # Reference: http://urbanautomaton.com/blog/2014/09/09/redirecting-bash-script-output-to-syslog/ | |
| exec 1> >(logger -s -t $(basename $0)) 2>&1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cat >/tmp/demo-space-separated.sh <<'EOF' | |
| #!/bin/bash | |
| POSITIONAL=() | |
| while [[ $# -gt 0 ]] | |
| do | |
| key="$1" | |
| case $key in | |
| -e|--extension) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Mandatory: apt install nvme-cli | |
| # Mount point (directory) | |
| TARGET_MOUNT=/data/tmp | |
| # Raid info | |
| TARGET_RAID_DEVICE=/dev/md0 | |
| TARGET_RAID_LABEL=RAID0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| killall Xcode | |
| xcrun -k | |
| xcodebuild -alltargets clean | |
| dirs = ("$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache" | |
| "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache" | |
| /Applications/Xcode.app | |
| ~/Library/Caches/com.apple.dt.Xcode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| #################################################################################### | |
| # Slack Bash console script for sending messages. | |
| #################################################################################### | |
| # Installation | |
| # $ curl -s https://gist.githubusercontent.com/andkirby/67a774513215d7ba06384186dd441d9e/raw --output /usr/bin/slack | |
| # $ chmod +x /usr/bin/slack | |
| #################################################################################### | |
| # USAGE | |
| # Send message to slack channel/user |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Add path permanently to environment machine | |
| [Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\bin", "Machine") | |
| # Add path permanently to environment user | |
| [Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\bin", "User") |