Skip to content

Instantly share code, notes, and snippets.

View royashbrook's full-sized avatar

Roy Ashbrook royashbrook

View GitHub Profile
/
--/assets
----/page1
------20180101-Some Document Title-t0.pdf
------20180102-Some Document Title-t0.pdf
------20180104-Some Document Title-t1.pdf
page1.md
# note that this is not a shell script that is meant to be run, just a list of shell commands mostly with comments.
# I am setting this up on my mac so all commands will be relative to that
# 1. Setup the piholes as usual, download stretch lite, image sdcard with etcher
# start with the following link if you forgot:
# https://www.raspberrypi.org/downloads/raspbian/
# 2. enable ssh
touch /Volumes/boot/ssh
$a = "server"
$b = "\Processor(_Total)\% Processor Time"
Get-Counter -com $a -cou $b -s 1 -con | %{
$cv = [math]::round($_[0].CounterSamples.CookedValue)
Write-Progress -Activity $a `
-PercentComplete $cv `
-CurrentOperation "$b - $cv%" `
-Status "Measuring..."
}
$sb = {
(New-Object -ComObject Microsoft.Update.Session).CreateUpdateSearcher() | %{
$_.QueryHistory(0, $_.GetTotalHistoryCount()) |
? resultcode -in 2,3 |
? operation -eq 1 |
select title,date -unique |
%{ [pscustomobject]$_ }
}
}
$s = "s1,s2,s3,s4".split(',')
@royashbrook
royashbrook / config.xml
Created March 24, 2018 03:15
Send-MailMessage Bug
<?xml version="1.0"?>
<settings>
<mail>
<from>from@gmail.com</from>
<to>to@gmail.com</to>
<subject>Test</subject>
<smtp>smtp.gmail.com</smtp>
<port>587</port>
<user>from@gmail.com</user>
<pass>frompassword</pass>
# all files
$a = Get-Item *.txt
# prefix of latest file
$b = $a |
sort -Property LastWriteTime -Descending |
select -First 1 @{n='dts';e={$_.name.split('_')[0]}}).dts
# files with that prefix
Get-Item "$b*.txt"
# Long way with some explanation
$FilePath = "path_to_ file"
$FileContents = gc $FilePath
$Commas = $FileContents[0].Split(',').Count
$Columns = $Commas + 1
$Header = (1..$Columns|%{"f{0,2:00}" -f $_})
$Data = $FileContents | ConvertFrom-Csv -Header $Header
$Data | Format-Table *
# What I usually do is something more like
select
[job] = j.name
, s.step_id
, [step] = s.step_name
, [cmd] = s.command
, [db] = s.database_name
from
sysjobs j
join sysjobsteps s on
s.job_id = j.job_id
void Main()
{
//function to measure an actions execution time
Func<Action,int,TimeSpan> ma = (m,c) =>{
Stopwatch s = new Stopwatch();
s.Start();
for (int i = 0; i < c; i++)
m();
s.Stop();
Sub FWAP()
Dim OriginalPage As Visio.Page
Set OriginalPage = ActivePage
Dim PagObj As Visio.Page
For Each PagObj In ActiveDocument.Pages
ActiveWindow.Page = PagObj.Name
ActiveWindow.ViewFit = visFitPage
Next PagObj