Skip to content

Instantly share code, notes, and snippets.

View theTonyHo's full-sized avatar

Tony Ho theTonyHo

View GitHub Profile
@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.
###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`
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"
@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
' 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 / 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.