Skip to content

Instantly share code, notes, and snippets.

@jrich523
jrich523 / gist:dede9f8a3901d44c4c6c
Last active August 29, 2015 14:07
NBU error gathering
currentTime=$(date)
timeStampFile="lastrun.txt"
#check to see if there is a timestamp file
if [ -f "$timeStampFile" ]; then
#read in last run date
lastRun=$(date -f "$timeStampFile")
#excute command and exit if it fails (dont store time)
/usr/openv/netbackup/bin/admincmd/bperror -d "$(date -d "$lastRun" '+%D %T')" -e "$(date -d "$currentTime -1 second" '+%D %T')"
#write current to last run
@jrich523
jrich523 / Example Script
Last active August 29, 2015 14:10
Odd Regex Escape
#this is all powershell, but its using the .net Escape()
#i've also made it use the .net match() with similar results.
#based on the MSDN docs it looks like it doesnt need to escape a ], which makes sense if there is no open
$chars = "abcd[]."
"a","b" | %{ $_ -match "[$([regex]::Escape($chars))]"}
[regex]::Match("a","[$([regex]::Escape($chars))]").Success
#output is all false
@{
NAME=@{
template=@{
type="abc"
generator="xyz"
}
block="block"
material=""
clusterSize=123
numClusters=123
@jrich523
jrich523 / 0_reuse_code.js
Last active August 29, 2015 14:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
$rawVirtual = $rawLTM | ? h1 -eq "virtual"
$virtualData = $rawVirtual | %{
#$body = $_.body -split "\n"
$body = $_.body |?{$_ -match '(?ms)^(\S+.+?)\{(.+)\}' }|%{$Matches[2]}
$persist,$profiles,$rules,$address,$port = $null
#persist
$persist = $body |?{$_ -match "(?s)\s+persist\s+\{(.+?)\}.\s+\b"} | %{$matches[1]}
#profiles
$profiles = $body |?{$_ -match "(?s)\s+profiles\s+\{(.+?)\}.\s+\b"} | %{$matches[1]}
RenderDevice.TripleBufferingEnable 0
Thread.MaxProcessorCount 8
WorldRender.TransparencyShadowmapsEnable 0
WorldRender.MotionBlurEnable 0
WorldRender.MotionBlurForceOn 0
WorldRender.MotionBlurFixedShutterTime 0
WorldRender.MotionBlurMax 0
WorldRender.MotionBlurQuality 0
WorldRender.MotionBlurMaxSampleCount 0
WorldRender.SpotLightShadowmapEnable 0
function Show-Object{
param(
## The object to examine
[Parameter(ValueFromPipeline = $true)]
$InputObject
)
#custom controls for treeview... found it on MSDN a while ago, lost link :-/
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
root 5562 1 0 10:42 ? 00:00:01 /usr/bin/dockerd
root 5567 5562 0 10:42 ? 00:00:00 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --runtime docker-runc
root 5695 5567 0 10:42 ? 00:00:00 docker-containerd-shim e45554e5265ac406110260e161f5570e6d8e9ec8ea285427d4b6a2ccc6024150 /var/run/docker/libcontainerd/e45554e5265ac406110260e161f5570e6d8e9ec8ea285427d4b6a2ccc6024150 docker-runc
root 5712 5567 0 10:42 ? 00:00:00 docker-containerd-shim b7416353a8bb091a435f02e186816807b777cc7370cefb6bc3422d249866f50f /var/run/docker/libcontainerd/b7416353a8bb091a435f02e186816807b777cc7370cefb6bc3422d249866f50f docker-runc
root 5742 5567 0 10:42 ? 00:00:00 docker-containerd-shim ea45e8aa9b5c7e0bb179d64c49e9d935dfdd3997f4d4ae3800e111907f7e6f71 /var/run/docker/libcontainerd/ea45e8aa9b5c7e0bb179d64
Function Import-CurrentFileAsModule
{
[cmdletbinding()]
param()
#get paths
$filePath = $psise.CurrentFile.FullPath
$folder = split-path $filePath
#save if not already saved
if($psise.CurrentFile.IsUntitled){Write-Error "Must save file first! Sorry didn't feel like implementing the dialog box!" -ErrorAction Stop}
if(-not $psise.CurrentFile.IsSaved){$psise.CurrentFile.Save()}
if ((int) rt == 3)
{
Report3 report3 = new Report3();
int num = 66560 / inputReportBuffer.Length;
do
{
Thread.Sleep(3);
if (this._deviceDetected)
{
inputReportBuffer[0] = rt;