Skip to content

Instantly share code, notes, and snippets.

View wqweto's full-sized avatar

Vladimir Vissoultchev wqweto

View GitHub Profile
@wqweto
wqweto / cVbzlib.cls
Created March 29, 2017 15:43
VB6 Deflate/Inflate with thunks
Option Explicit
'=========================================================================
' Thunk data
'=========================================================================
' Auto-generated on 29.3.2017 17:59:42, CodeSize=6048, DataSize=987, ALIGN_SIZE=16
Private Const STR_THUNK1 As String = _
"Vot0JAho/I8DAIsG/1AYi9CF0nUCXsOJVgSNSgK+AIAAAIPI/2aJQQJmiQFmiUH+g8EGTnXvV426BIADALn7AwAA86tmq1/HggCAAwAAAAAAx4L4jwMAAAAAALgBAAAAXsOQkJCQkJCQkJCQkJCQkItEJASLiACAAwCNDEmNFEhmi0xIAmaD+f90Dg+/yY0USWbHBFD//+sXZotSBGaD+v90DQ+/ymbHhEgEgAMA//+LiACAAwBXjRRJi0wkEGaJTFAEi5AAgAMAjRRSZsdEUAL//4uQAIADAGaLvEgEgAMAjRRSZok8UIuQAIADAGaLuACAAwCNFFIPvxRQZom8SASAAwCD+v9fdA+NDFJmi5AAgAMAZolUSAKLiACAAwCKVCQIiJQIAAADAIuIAIADAEGB4f9/AACJiACAAwDDkJCB7CgBAACLhCQsAQAAU1VWV4t4BIsAM/aLj/iPAwCJRCQ0hckPjv8AAACNh/KPAwCJRCQQi5wkRAEAAIvRK9YD" & _
"04P6Aw+MtgAAAIvejUQkKDPSK9iJXCQUjUQUKAPDO8F9C4tsJBAzwIoEKusWi6wkQAEAAIvaK9kD3jPAigQri1wkFIhEFChCg/oDfMuLTCQpi1wkKIHh/wAAAIvBweAFA8HB4AMrwYtMJCqB4f8AAACNFEmNFJKNFNLR4ivRi8uB4f8AAAADwovRweIIA9G59
@wqweto
wqweto / program.cs
Last active August 1, 2023 08:31
Minimal .Net Web Server with Regex Routing in 177 LOC of C#
//
// Poor Man's Web Server with Regex Routing in 177 LOC of C#
//
// This is a simple standalone http server that handles routing with regular expressions
// matching. For each request the router passes capture groups to handlers as a data dictionary.
//
// Router implementation constructs a single composite regex to match request path, based on
// https://nikic.github.io/2014/02/18/Fast-request-routing-using-regular-expressions.html
//
// One can use `WebServer` and `Router` classes alone, just has to register all custom
@wqweto
wqweto / Program.cs
Last active October 3, 2016 09:34
Playing with the StackOverflow datasets : All the wrong ways
// https://ayende.com/blog/175618/playing-with-the-stackoverflow-datasets-all-the-wrong-ways?Key=57ee98e3-2865-47ba-bc68-367d694b2a6e
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Serialization;
@wqweto
wqweto / mdMain.bas
Created March 22, 2016 15:55
VB6 surrogate linker
Attribute VB_Name = "mdMain"
Option Explicit
'=========================================================================
' API
'=========================================================================
Private Const INVALID_FILE_ATTRIBUTES As Long = -1
Private Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long
<log4net>
<appender name="Services.Debug" type="log4net.Appender.RollingFileAppender">
<file value="Logs/Services.Debug.log" />
<appendToFile value="true" />
<encoding value="utf-8" />
<maximumFileSize value="20MB" />
<maxSizeRollBackups value="4" />
<datePattern value="yyyyMMdd" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
@wqweto
wqweto / NumberToWords (Bulgarian)
Last active March 13, 2016 18:06
Конвертиране на число в словом с думи за VB.NET. По подразбиране работи за левове в мъжки род, но може да се използва и за мярка в женски род (например метро единици) или среден род (например евро)
Module ToWordsModule
Public Function ToWords(ByVal dblValue As Double, Optional Measure As Object = Nothing, Optional Gender As String = Nothing) As String
Dim vDigits As Object
Dim vGenderDigits As Object
Dim vValue As Object
Dim lIdx As Long
Dim lDigit As Long
Dim sResult As String = ""
Dim sString As New String("0", 18)
@wqweto
wqweto / mdExcel.bas
Last active November 5, 2020 18:26
Write to Excel using ADO
Option Explicit
Public Function ReadFromExcel( _
ByVal sFileName As String, _
Optional Workbook As String, _
Optional ByVal CsvHeader As Boolean) As Recordset
Dim cn As ADODB.Connection
Dim rsDest As Recordset
Dim sTable As String
Dim sCharset As String
@wqweto
wqweto / countdown.lua
Last active February 16, 2016 18:15
Countdown problem solution in Lua
--local strict = require"strict"
local function permutations(t)
local fn = coroutine.yield
local function permgen(t, n)
for i = 1, n do
t[n], t[i] = t[i], t[n]
if n == 1 then
fn(t)
else
@wqweto
wqweto / bf2.lua
Last active February 16, 2016 16:56
Brainfuck optimizing compiler in Lua
-- This transpiler generates Lua source code from input brainf**k program, then compiles and
-- executes this Lua source code. Can be used with LuaJIT for jitted brainf**k experience.
--
-- Based on https://github.com/prapin/LuaBrainFuck/blob/master/brainfuck.lua
-- Inspired by https://github.com/luapower/bf and its dynasm implementation (~5-10x faster)
-- Optimizations from https://www.nayuki.io/page/optimizing-brainfuck-compiler
--
-- Optimizations due to lpeg grammar:
-- instead of generating repeating `i = i + 1` just output `i = i + N`
-- instead of generating repeating `t[i] = t[i] + 1` just output `t[i] = t[i] + N`
@wqweto
wqweto / re.lua
Last active January 4, 2016 16:19
LPeg.re w/ optional built-in and external trace support (can be used w/ pegdebug.lua)
-- $Id: re.lua,v 1.44 2013/03/26 20:11:40 roberto Exp $
-- imported functions and modules
local tonumber, type, print, error = tonumber, type, print, error
local setmetatable = setmetatable
local m = require"lpeg"
-- 'm' will be used to parse expressions, and 'mm' will be used to
-- create expressions; that is, 're' runs on 'm', creating patterns
-- on 'mm'