Skip to content

Instantly share code, notes, and snippets.

View Proxy.rb
=begin
=================================
PROXY VERSION 3
=================================
DEFINITION:
I want a simple wrapper which will wrap the Application class and down.
Criterium:
@sancarn
sancarn / How to use a function pointer in VBA.md
Created Dec 30, 2020
How to use a function pointer in VBA by Akihito Yamashiro
View How to use a function pointer in VBA.md

VB6 and VBA come with no support for function pointers.

Also, when you wish to execute a function in a dll using the Declare function, you can only call functions created by the Steadcall calling conversation.

These constraints can be avoided by using the DispCallFunc API. The DispCallFunc is widely used in VB6 when erasing the history of IE. Although the DispCallFunc is known as API for calling the IUnknown interface, in fact, you can also perform other functions other than COM by passing the NULL to the first argument.

As explained in the http://msdn.microsoft.com/en-us/library/ms221473(v=vs.85).aspx , the DispCallFunc argument is as follows.

View stdEnumerator.cls
Public Function Sort(cb as callback, ctor as object) as stdArray 'stdArray? Or can i use stdEnum again? and have a `stdArray.Create(stdEnum)`?
Dim arr() as SortStruct
Redim arr(1 to me.count)
Dim iIndex as Long: iIndex = 0
Dim iFirstItem as long: iFirstItem = 1
Dim val as variant
For each val in pEnumObject
'Increment index
iIndex = iIndex + 1
View .README.MD

Formula tracer

Have you ever been told to audit or understand a large formula application? Have you ever took on the challenge, and after a few hours of searching you still have no idea how the outputs relate to the inputs?

Recently I had this same issue while trying to debug issues in a spreadsheet owned by a non-profit organisation. This spreadsheet had huge tables, each table column containing formulas with one of the 7k+ relationships used in the spreadsheet. To be honest, I'm astonished Excel is capable of dealing with this number of relationships in memory with little drop in performance...

This tool can be used to create a list of every relationship in a spreadsheet, which can ultimately be boiled down into a graph showing how each sheet interacts with eachother.

![relationshis

View .VBA Perf.md

Performance Tests in VBA

Variant Copy vs Local implementation

Tests:

Private Declare PtrSafe Sub VariantCopyDLL Lib "oleaut32.dll" Alias "VariantCopy" (ByRef pvargDest As Variant, ByRef pvargSrc As Variant)
Const MaxCount As Long = 10 ^ 6
View .README.MD

The following functions are hidden functions executable from vba on Mac.

Functions Present in Microsoft Office

/Applications/Microsoft Excel.app/Contents/Frameworks/MicrosoftOffice.framework/MicrosoftOffice

These are callable from VBA, e.g.

Declare Function GetTickCount Lib "/Applications/Microsoft Excel.app/Contents/Frameworks/MicrosoftOffice.framework/MicrosoftOffice" () As Long
View MathEvaluator.bas
Private Type TokenDefinition
Name As String
Regex As String
RegexObj As Object
End Type
Private Type token
Type As TokenDefinition
Value As Variant
BracketDepth As Long
End Type
View lexerParserEvaluator.js
//Made by http://github.com/TarVK
/*******************
* All helper code *
*******************/
/**
* Tokenizes the input text using the given rules
* @param {string} text The text to tokenize
* @param {{[key: string]: RegExp}} rules The rules
View .Ruby - InfoNet and InfoWorks REST Servers.md

InfoNet and InfoWorks REST Servers.md

Motivation for a REST Server

Data accessibility

InfoNet and InfoWorks is renound for innaccessibility of data. Business critical asset data is often captured in models, and then never shared with the outside world. Typically the only way to share data with the outside world is via manual exports to a GIS format, and interpreting the data through other system.

This needs to change and a REST API for InfoNet and InfoWorks is an ideal candidate for connectivity of this data.

Moving to the cloud

View .VBA ObjectPointers.md

Note at the time this was written, Serialize returned purely the ObjPtr and no extra data.

'Direct call convention of VBA.CallByName
#If VBA7 Then
  Private Declare PtrSafe Function rtcCallByName Lib "msvbvm60" (ByRef vRet As Variant, ByVal cObj As Object, ByVal sMethod As LongPtr, ByVal eCallType As VbCallType, ByRef pArgs() As Variant, ByVal lcid As Long) As Long
  Private Declare PtrSafe Sub VariantCopy Lib "oleaut32.dll" (ByRef pvargDest As Variant, ByRef pvargSrc As Variant)
  Private Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Any, ByVal Source As LongPtr, ByVal length As Long)
#Else
  Private Declare Function rtcCallByName Lib "msvbvm60" (ByRef vRet As Variant, ByVal cObj As Object, ByVal sMethod As LongPtr, ByVal eCallType As VbCallType, ByRef pArgs() As Variant, ByVal lcid As Long) As Long