Jim is my enemy - but it turns out that Jim is also his own worst enemy - and the enemy of my enemy is my friend - so Jim is actually my friend - but - because he is his own worst enemy - the enemy of my friend is my enemy - so Jim is actually my enemy - but...
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
def GetWin32comObject(object_name='Word.Application'): | |
from win32com import client | |
try: | |
object = client.gencache.EnsureDispatch(object_name) | |
except AttributeError: | |
# Corner case dependencies. | |
import os | |
import re | |
import sys | |
import shutil |
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
# Dump schema from table | |
""" | |
Credit to Wilfredo Sánchez Vega who posted this answer | |
on stackoverflow | |
https://stackoverflow.com/questions/11996394/is-there-a-way-to-get-a-schema-of-a-database-from-within-python | |
""" | |
import sqlite3 | |
import re | |
import os | |
from pathlib import Path |
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
def strHex(s): | |
return f"0x%0.2X" % s | |
strHex(3) |
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
# AFQ210311450994 | |
import re | |
import win32com.client as w32 | |
path = r'<path goes here>' | |
wdApp = w32.gencache.EnsureDispatch('Word.Application') | |
wdApp.Visible = True | |
doc = wdApp.Documents.Open(path) |
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
%w(pp win32ole).each { |dep| require dep } | |
db = 'C:\Users\rdapaz\Documents\Statement of Compliance.accdb' | |
cs = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=#{db};" | |
rs = WIN32OLE.new('ADODB.Recordset') | |
conn = WIN32OLE.new('ADODB.Connection') | |
conn.Open(cs) | |
rs.Open("[SoC]", conn, 1, 3) | |
conn.Execute("DELETE * FROM SoC") |
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
%w(pp win32ole).each {|dep| require dep} | |
begin | |
$app = WIN32OLE.connect('Word.Application') | |
rescue Exception => e | |
$app = WIN32OLE.new('Word.Application') | |
end | |
$app.Visible = true | |
class WordConst |
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
#1 import these classes from jinja2 module | |
from jinja2 import FileSystemLoader, Environment, Template | |
from pathlib import Path | |
from enum import Enum | |
import re, sys, os | |
port_data = """ | |
Gi2/0/23|Gi2/0/23: Desc1|130 | |
Gi2/0/21|Gi2/0/21: Desc2|120 |
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
.DS_Store |