Skip to content

Instantly share code, notes, and snippets.

View cwg999's full-sized avatar

Cody W. Geisler cwg999

View GitHub Profile
return n.name==t.name&&n.message==t.message;
case"[object RegExp]":
case"[object String]":
return n==t+"";
case"[object Map]":
var f=L;
case"[object Set]":
if(f||(f=D),n.size!=t.size&&!(1&e))break;
@cwg999
cwg999 / WordDocToPdf.vba
Created February 2, 2017 12:56
Word Document to PDF
Sub WordDoc_To_Pdf()
ActiveDocument.ExportAsFixedFormat OutputFileName:=ActiveDocument.FullName + ".pdf", _
ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, to:=99, _
Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=True
End Sub
@cwg999
cwg999 / IDWtoDWG.vba
Last active February 2, 2017 13:01
Inventor Export DWG
' For Inventor R9 (REALLY OLD)
Public Sub PublishDWG()
Dim myArray(1 To 1) As String
myArray(1) = "C:\temp\some.idw"
' Attempt to connect to a running instance of Inventor.
Dim oApp As Inventor.Application
On Error Resume Next
Set oApp = GetObject(, "Inventor.Application")
If Err Then
libreoffice --headless --convert-to pdf myFile.docx
@cwg999
cwg999 / createcheckbox.vb
Created June 28, 2017 17:44
Create a Checkbox VBA
Sub Macro1()
Set cb = ActiveSheet.CheckBoxes.Add(99.75, 78, 24, 17.25)
With cb
.Name = "test"
.Value = xlOff
.LinkedCell = "$A$1"
.Display3DShading = False
End With
End Sub
@cwg999
cwg999 / awaitdelay.js
Last active August 2, 2017 17:45
await delay
// Function
const delay = time => new Promise(res=>setTimeout(()=>res(),time));
// Usage
await delay(2000);
let results = await foo();
@cwg999
cwg999 / check_for_multi_page_pdf.ps1
Created August 2, 2017 17:18
A Powershell Script that reads a path and recursively lists pdfs with more than one page.
$ArrayList = [System.Collections.ArrayList]@()
# $i = $ArrayList.add('echo "Hello"')
Get-ChildItem -Path .\ -Recurse | Where-Object {
$_ -is [System.IO.FileInfo] `
-and ($_.Directory.Name -eq 'Single')
} | ForEach-Object {
$ArrayList.add($_.FullName)
# $output = iex "& $command"
@cwg999
cwg999 / check_size_given_parent_folder.ps1
Created August 2, 2017 17:22
Given a parent folder name, output file names greater than a certain size.
Get-ChildItem -Path .\ -Recurse | Where-Object {
$_ -is [System.IO.FileInfo] `
-and (($_.Directory.Name -eq 'Single' `
-and $_.Length -gt (1*1024*1204)) `
-or ($_.Directory.Name -eq 'Multiple' `
-and $_.Length -gt (7*1024*1204)))
} | ForEach-Object {$_.FullName}
Write-Host "Press any key to continue ..."
Option Explicit
Sub WorkWithArrayExample()
Dim DataRange As Variant
Dim Irow As Long
Dim Icol As Integer
DataRange = ActiveSheet.Range("A1:A10").Value ' read all the values at once from the Excel grid, put into an array
For Irow = LBound(DataRange,1) To UBound(DataRange, 1) ' Get the number of rows.
For Icol = LBound(DataRange,2) To UBound(DataRange, 2) ' Get the number of columns.
@cwg999
cwg999 / compress_pdfs.ps1
Created August 3, 2017 13:55
Compresses PDFs using a ghostscript batch file, (required since ghostscript doesn't like powershell)
$ArrayList = [System.Collections.ArrayList]@()
Get-ChildItem -Path .\ -Recurse | Where-Object {
$_ -is [System.IO.FileInfo] `
-and ($_.Extension.ToLower().CompareTo('.pdf') -eq 0) `
-and ($_.name.CompareTo('out.pdf') -ne 0)
} | ForEach-Object {
$ArrayList.add($_.FullName)
}
workflow Test-Workflow{