Skip to content

Instantly share code, notes, and snippets.

@yadimon
yadimon / benchmark_time_with_promise_nodejs_example.js
Last active April 26, 2016 11:36
measure execution time of function (mini benchmark) in promises in node.js
//perf start
var lastCallName = '';
function timePromise(name) {
var lastNameToEnd = lastCallName ? lastCallName : '';
lastCallName = name;
return function (data) {
if (lastNameToEnd) console.timeEnd(lastNameToEnd);
console.time(name);
return data;
@yadimon
yadimon / mdlCleanSheet.bas
Last active December 18, 2015 16:04
clear worksheet except header row
'---------------------------------------------------------------------------------------
' Function: ClearDataWorksheet
'---------------------------------------------------------------------------------------
' Purpose: clear worksheet content after header
' Param : Worksheet wksSheet reference to worksheet
' Remarks: e.g. usage: Call ClearDataWorksheet(ThisWorkbook.Worksheets(1))
'---------------------------------------------------------------------------------------
Public Function ClearDataWorksheet(ByRef wksSheet As Worksheet)
Dim lLastRow As Long
Dim lLastColumn As Long
@yadimon
yadimon / VBA Unescape UTF-8
Last active February 11, 2023 08:05
Function to unescape UTF-8 escaped content for VBA
'modified from http://needtec.sakura.ne.jp/codeviewer/index.php?id=2
Public Function UnescapeUTF8(ByVal StringToDecode As String) As String
Dim i As Long
Dim acode As Integer, sTmp As String
On Error Resume Next
If InStr(1, StringToDecode, "\") = 0 And InStr(1, StringToDecode, "%") = 0 Then
UnescapeUTF8 = StringToDecode
Function GetDBNameFromConnString(ByVal connString As String) As String
Dim lcConnString As String
Dim endIndex As Integer
lcConnString = LCase(connString)
' if this is a Jet database, find the index of the "data source" setting
Dim startIndex As Integer
If InStr(1, lcConnString, "jet.oledb", vbTextCompare) > -1 Then
startIndex = InStr(1, lcConnString, "data source=", vbTextCompare)