Skip to content

Instantly share code, notes, and snippets.

VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "SAPECC"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'{F9} - Jump to first form value
@sancarn
sancarn / 01. Infinite acceleration loop.js
Last active September 9, 2021 22:52
Open AI Codex fun
/* Make screen a canvas */
var canvas = document.createElement('canvas');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
document.body.appendChild(canvas);
/* remove scroll bars */
document.body.style.overflow = 'hidden';
/* add a circle to the canvas */
@sancarn
sancarn / Proxy.rb
Last active February 17, 2021 11:08
=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 December 30, 2020 12:14
How to use a function pointer in VBA by Akihito Yamashiro

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.

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

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

@sancarn
sancarn / .VBA Perf.md
Last active September 13, 2021 06:59

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

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

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
//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