Skip to content

Instantly share code, notes, and snippets.

View wqweto's full-sized avatar

Vladimir Vissoultchev wqweto

View GitHub Profile
@wqweto
wqweto / Form1
Created October 14, 2020 12:11
Execution order
Option Explicit
Private Function A() As Long
A = 1
MsgBox "A"
End Function
Private Function B() As Long
B = 2
@wqweto
wqweto / rant.sql
Created April 20, 2020 16:58
Writing clever cursor loops in T-SQL (not using the hot-mess from BOL)
IF OBJECT_ID('dbo.zero_ten') IS NOT NULL DROP TABLE dbo.zero_ten
GO
SET NOCOUNT ON
CREATE TABLE dbo.zero_ten (id INT PRIMARY KEY)
INSERT dbo.zero_ten(id)
SELECT 0
@wqweto
wqweto / Form1.frm
Last active November 18, 2022 08:59
CRC32 calculation benchmark
Option Explicit
Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long
Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long
Private Declare Function RtlComputeCrc32 Lib "ntdll" (ByVal dwInitial As Long, pData As Any, ByVal iLen As Long) As Long
Private Sub Form_Click()
Const ITERS As Long = 100000
Dim baBuffer() As Byte
Dim lIdx As Long

Keybase proof

I hereby claim:

  • I am wqweto on github.
  • I am wqweto (https://keybase.io/wqweto) on keybase.
  • I have a public key ASDomFHdT9_NTPnvRMzbrIWaHI2D_Art4OYOKkzpcLN76wo

To claim this, I am signing this object:

@wqweto
wqweto / mdPostFile.bas
Created May 5, 2019 10:23
Send JSON and binary file as multipart request
Option Explicit
Private Function pvPostFile(sUrl As String, sJSON As String, sFileName As String, Optional ByVal bAsync As Boolean) As String
Const STR_BOUNDARY As String = "864d391d-4097-44e0-92e1-71aff17094c1"
Dim nFile As Integer
Dim baBuffer() As Byte
Dim sPostData As String
'--- read file
nFile = FreeFile
@wqweto
wqweto / mdMedianBlur.bas
Last active October 18, 2019 06:58
Fast O(N) median filter for GDI+ bitmaps impl w/ SSE2 thunks based on http://nomis80.org/ctmf.c
Option Explicit
DefObj A-Z
'--- for VirtualProtect
Private Const PAGE_EXECUTE_READWRITE As Long = &H40
Private Const MEM_COMMIT As Long = &H1000
'--- for CryptStringToBinary
Private Const CRYPT_STRING_BASE64 As Long = 1
'--- for GdipBitmapLockBits
Private Const ImageLockModeRead As Long = &H1
@wqweto
wqweto / Form1.frm
Last active March 25, 2019 14:35
PNG filter on save
Option Explicit
Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Private Declare Function GdiplusStartup Lib "gdiplus" (hToken As Long, pInputBuf As Any, Optional ByVal pOutputBuf As Long = 0) As Long
Private Declare Function GdipLoadImageFromFile Lib "gdiplus" (ByVal lFilenamePtr As Long, hImage As Long) As Long
Private Declare Function GdipDisposeImage Lib "gdiplus" (ByVal hImage As Long) As Long
Private Sub Form_Load()
Dim aInput(0 To 3) As Long
@wqweto
wqweto / LabelVert.ctl
Created March 7, 2019 18:44
Windowless Vertical Label control
VERSION 5.00
Begin VB.UserControl LabelVert
Appearance = 0 'Flat
BackColor = &H80000005&
BackStyle = 0 'Transparent
CanGetFocus = 0 'False
ClientHeight = 3372
ClientLeft = 0
ClientTop = 0
ClientWidth = 4980
@wqweto
wqweto / mdJson.bas
Last active May 11, 2025 16:43
JSON parsing/dumping functions with JSON path support for VB6 and VBA
'=========================================================================
'
' https://github.com/Unicontsoft/UcsFiscalPrinters/blob/master/src/UcsFP20/Shared/mdJson.bas
' JSON parsing and dumping functions with JSON path support
'
'=========================================================================
Option Explicit
DefObj A-Z
Private Const MODULE_NAME As String = "mdJson"
@wqweto
wqweto / mdCollection.bas
Last active December 16, 2020 17:33
[VB6/VBA] Collection keys
Option Explicit
#Const HasPtrSafe = (VBA7 <> 0)
#Const LargeAddressAware = (Win64 = 0 And VBA7 = 0 And VBA6 = 0 And VBA5 = 0)
'--- for CopyMemory
#If HasPtrSafe Then
Private Const NULL_PTR As LongPtr = 0
#Else
Private Const NULL_PTR As Long = 0