Skip to content

Instantly share code, notes, and snippets.

View sevaa's full-sized avatar

Seva Alekseyev (he/him) sevaa

View GitHub Profile
@sevaa
sevaa / tasks.schema.amended.json
Created May 28, 2024 19:50
tasks.schema.amended.json
{
"$schema": "http://json-schema.org/draft-04/schema",
"id": "https://raw.githubusercontent.com/Microsoft/azure-pipelines-task-lib/master/tasks.schema.json",
"title": "Azure DevOps Tasks schema",
"type": "object",
"additionalProperties": false,
"properties": {
"serverOwned":{"type":"boolean"},
"contentsUploaded":{"type":"boolean"},
"iconUrl":{
@sevaa
sevaa / json_validate.sql
Last active June 5, 2024 18:14
JSON_VALIDATE.sql
create or alter function dbo.JSON_VALIDATE(
@doc nvarchar(max), -- JSON document to validate
@schema nvarchar(max), -- JSON schema to validate against
-- Pass nulls, those parameters are for recursive invokations
@res1 bit = null,
@res2 bit = null,
@schema_path nvarchar(max) = null,
@type tinyint = null,
@root nvarchar(max) = null)
returns @t table(
@sevaa
sevaa / ll.py
Last active November 15, 2023 16:50
Test gist for debugging location list parsing
from sys import argv
from elftools.common.exceptions import ELFParseError
from elftools.dwarf.locationlists import LocationLists, LocationListsPair, LocationParser
from elftools.elf.elffile import ELFFile
from inspect import getframeinfo
from elftools.dwarf.dwarfinfo import DWARFInfo
def location_lists(self):
""" Get a LocationLists object representing the .debug_loc/debug_loclists section of
the DWARF data, or None if this section doesn't exist.
@sevaa
sevaa / a.cpp
Created March 2, 2023 14:38
COM double hop test
#include <windows.h>
static const GUID CLSID_B =
{ 0x51addb47, 0xd26a, 0x4f69, { 0xb9, 0x7b, 0x7e, 0x30, 0x62, 0x8d, 0xcf, 0x5b } };
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
@sevaa
sevaa / MSISetProp.ps1
Created December 20, 2022 16:58
A Powershell script to change a property value in an MSI file
param($Path, $Property, $Value)
$i = New-Object -COM "WindowsInstaller.Installer"
$db = $i.OpenDatabase($Path, 2)
$r = $i.CreateRecord(2)
$r.StringData(1) = $Value
$r.StringData(2) = $Property
$vw = $db.OpenView("update Property set Value=? where Property=?")
$vw.Execute($r)
$r = $null
#define INITGUID
#include <SDKDDKVer.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mfidl.h>
#include <mfapi.h>
#include <evr.h>
#include <cguid.h>
#include <propvarutil.h>
#include <comdef.h>
using Microsoft.Win32.SafeHandles;
using System.Diagnostics;
using System.Text;
using System;
using System.Threading;
namespace COMNET
{
public class Program
{
@sevaa
sevaa / RequestTLSCert.ps1
Last active January 4, 2024 00:42
RequestTLSCert.ps1
# Requires .NET 4.7.2+ or Core 2.0+
# Basic parameters. For TLS certs for IIS, this is sufficient
$Hostname = "foo.example.com" # Goes into Subject as the CN
$AltHostnames = @("foo.example.com", "bar.example.com", "baz.example.com") # These go into Subject Alternative Name
$DNPostfix = "OU=IT;O=Acme;L=Chicago;S=Illinois;C=US" # What follows the CN in the Subject field. Optional!
$FriendlyName = "foo" # Optional but highly recommended
$TermDays = 3650 # Expiration date for the temporary self-signed cert. The CA will probably override the exp date anyway.
$CSRPath = "c:\\MyCert.csr" # Your path WILL vary.
$SaveUnderLocalMachine = $false # False for current user, true for local machine.
@sevaa
sevaa / MurMur.sql
Last active July 7, 2020 17:28
MurMurHash64B in MySQL dialect of SQL
drop function if exists MurmurHash64B;
delimiter $$
create function MurmurHash64B(s longblob, seed int unsigned)
returns bigint unsigned
deterministic no sql
begin
declare m int unsigned default 0x5bd1e995;
declare r int default 24;
declare len int default length(s);
@sevaa
sevaa / MurMur.pas
Last active February 14, 2020 22:45
MurMurHash64B in Pascal
unit MurMur;
interface
function MurmurHash64B(s: PAnsiChar; Len: Integer; Seed: UInt32) : UInt64;
implementation
function MurmurHash64B(s: PAnsiChar; Len: Integer; Seed: UInt32) : UInt64;
const
m = $5bd1e995;