Skip to content

Instantly share code, notes, and snippets.

View theTonyHo's full-sized avatar

Tony Ho theTonyHo

View GitHub Profile
@theTonyHo
theTonyHo / loggingExample.py
Last active August 29, 2015 14:03
Logging function to set up and create a logging object.
import logging
import os
def Logger(loggerName, fileName=None, console=False):
"""
Instantiate a logger object with default Formatter.
Default level is set to DEBUG (Show all messages)
Args:
loggerName: Name of the logger. Usually __file__ or something sensible.
' Experiment communication with Rhinoceros 3D application.
' This is useful for interopability from Excel and/or other windows programs using VBA/VBscript.
' Author: Tony Ho
' Date: 08/04/2016
' References: http://v5.rhino3d.com/forum/topics/rhino-automation-through-com
Option Explicit
Public rhApp As Object
Public rhSO As Object
@theTonyHo
theTonyHo / PlanarClosedCurveContainment.py
Last active August 29, 2015 14:05
PlanarClosedCurveContainment with Curve Geometries
def PlanarClosedCurveContainment(curve_a, curve_b, plane=None, tolerance=None):
"""Determines the relationship between the regions bounded by two coplanar
simple closed curves
Parameters:
curve_a, curve_b = identifiers of two planar, closed curves
plane[opt] = test plane. If omitted, the currently active construction
plane is used
tolerance[opt] = if omitted, the document absolute tolerance is used
Returns:
a number identifying the relationship if successful
invalid_chars = "#$+"
invalidResponse = True
while invalidResponse:
response = rs.GetString()
if not response:
break
rc = str.strip(response, invalid_chars)
invalidResponse = (rc != response)
if invalidResponse:
print "Invalid Characters found"
###Latest Revision lookup
> When you want to find out the latest transaction in a transaction table.
Look up a value in a table to return the highest letter or value.
`=IFERROR(LOOKUP(2,1/(IF(DWG_Transactions[DRAWING]=[DRAWING],DWG_Transactions[ISSUE])<>""),IF(DWG_Transactions[DRAWING]=[DRAWING],DWG_Transactions[ISSUE])), "N/A")`
Assuming you have a table called `DWG_Transactions` with column `DRAWING` and `ISSUE`
@theTonyHo
theTonyHo / datepicker.vba
Last active January 23, 2017 05:55
Generic Date Picker in Excel
' Insert Microsoft Date and Time Picker control in the document and paste the following code on the sheet.
' Reference: http://www.techrepublic.com/blog/microsoft-office/how-to-acquire-position-and-hide-a-calendar-control-in-an-excel-sheet/
Private Sub DTPicker1_Change()
' Set picked date to active Cell.
ActiveCell.Value = Me.DTPicker1.Value
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Anchor control to the active cell.
' Display control only when active cell contains a date.

VMWare CLI SSH Commands

Create Virtual Disk

This will create a thin 0.01GB vmdk file. vmkfstools --createvirtualdisk 0.01G --diskformat thin FS-18XX.vmdk

Convert VMDK to Thin

Function GetProperty(fileFolder As String, fileName As String, strName As String)
'All properties are saved in an array so that the actual name of the _
'property can be found in lieu of using the numbered index of the property.
'REFERENCE: https://social.msdn.microsoft.com/forums/en-US/873cfe9f-13fe-4d2f-ad52-af020eaa0f7f/find-the-title-of-a-pdf-document
'
'AVAILABLE PROPERTIES:
'SIZE
'ITEM TYPE
'DATE MODIFIED
'DATE CREATED
@echo off
REM SOURCE:
REM http://stackoverflow.com/questions/19467792/batch-command-line-to-eject-cd-tray/28422571#28422571
echo Set oWMP = CreateObject("WMPlayer.OCX.7") >> %temp%\temp.vbs
echo Set colCDROMs = oWMP.cdromCollection >> %temp%\temp.vbs
echo For i = 0 to colCDROMs.Count-1 >> %temp%\temp.vbs
echo colCDROMs.Item(i).Eject >> %temp%\temp.vbs
echo next >> %temp%\temp.vbs
echo oWMP.close >> %temp%\temp.vbs