Skip to content

Instantly share code, notes, and snippets.

View stelf's full-sized avatar
🦌
focusing 🦊

Gheorghi stelf

🦌
focusing 🦊
View GitHub Profile
@stelf
stelf / find.files.fast.ps1
Created March 24, 2022 15:09
Use System.IO.Directory to find files in .NET (faster than gci)
function Find-Files {
[CmdletBinding()]
param(
[Parameter()] [string] $Glob,
[Parameter()] [string] $Path = (Get-Location))
if (-not ( $Path -match '^\w:' ) ) {
$Path = (Get-Location).Path + '\' + $Path
}
@stelf
stelf / findelems.in.html.ps1
Created December 13, 2021 15:17
workaround the querySelectorAll bug that shows when calling it from COM+
$comDoc = New-Object -Com 'HTMLFile'
# load the wiki content
$res = Invoke-WebRequest $webLocation
# create a webview
$comDoc.Write( [System.Text.Encoding]::Unicode.GetBytes($res.Content) )
# query DOM
$elems = $comDoc.querySelector('table.prettytable')
# unfortunately querySelectorAll fails for various reasons
# so we have to enumerate the items manually
$codes = $elems.childNodes().item(0).childNodes() `
@stelf
stelf / check.interesect.consistency.sql
Created December 4, 2021 00:03
check spatial intersection consistency by making sure no duplicate rows are returned
-- listing only records that appear more than twice
-- in result which finds points within areas
--
-- the partitioning allows us to figure the results
-- alongside corresponding dulplicate areas
--
-- the n.type may be skipped, is included as aexample
select * from (
select
@stelf
stelf / school.data.prep.sh
Last active December 3, 2021 12:15
a short excursion into jq black magic
jq -sc '.[] | .result."attendance-areas"[] | {
type: "Feature",
properties: {
id: .id,
grade: .grade | tostring,
openEnrollment: .openEnrollment,
name: .name, },
geometry: .geometry, }' input/school-page-*.json > prepared/school.geojson
const saxpath = require('./lib/saxpath');
const fs = require('fs');
const zlib = require('zlib');
const sax = require('sax');
const saxParser = sax.createStream(true);
const deflate = zlib.createGunzip();
const fileStream = fs.createReadStream('../discogs_20211101_releases.xml.gz');
const streamer = new saxpath.SaXPath(saxParser, '/releases/release');
#!/usr/local/bin/perl
use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
use XML::XPath;
my $ifile = '/Users/user/Downloads/discogs_20211101_releases.xml.gz';
my $ioref = IO::Uncompress::Gunzip->new( $ifile )
or die "gunzip failed: $GunzipError\n";
my $xp = XML::XPath->new(ioref => $ioref );
@stelf
stelf / dynamic.regex.switch.pl
Last active September 30, 2021 16:44
dynamic regex switch (Perl5)
#!/usr/bin/perl
use feature say;
my @a = (
" asd",
" asd ",
" bsd",
" XXX",
"10000"
);
@stelf
stelf / dynamic.regex.switch.ps1
Last active September 30, 2021 16:49
dynamic regex switch (PowerShell)
[string[]] $a = (
" asd",
" asd ",
" bsd",
" XXX",
"10000"
)
[string] $spacer = ""
@stelf
stelf / install.oracle.managed.dependencies.ps1
Created July 21, 2021 13:58
manual (&local) installation of Oracle.ManagedDataAccess.Core dependencies from nuget v2.0 API
function Install-CollectDependencies {
Set-PackageSource -SourceName nuget.org -NewLocation https://www.nuget.org/api/v2
Install-Package System.Numerics.Vectors,System.ValueTuple -SkipDependencies -Destination packages
Install-Package System.Runtime.CompilerServices.Unsafe -SkipDependencies -Destination packages
Install-Package System.Memory,System.ValueTuple -SkipDependencies -Destination packages
Install-Package System.Threading,System.Threading.Tasks -SkipDependencies -Destination packages
Install-Package Runtime.Native.System,System.Runtime.Handles,System.Runtime.InteropServices -SkipDependencies -Destination packages
Install-Package System.Reflection.Extensions -SkipDependencies -Destination packages
Install-Package System.Console,System.AppContext,System.Collections -SkipDependencies -Destination packages
Install-Package Microsoft.Win32.Primitives,System.Globalization.Calendars -SkipDependencies -Destination packages
@stelf
stelf / substitute.js
Created July 19, 2021 13:34
several attepts to some informatics assignemnt
// -- this GIST is available under the conditions of
// -- https://creativecommons.org/licenses/by/4.0/
//
// this are four approaches to solution to one trivial task from
// Bulgaria's softuni's curriculum that i was asked to help with
//
//
// the input is basically 4 integers K, L, M, N
//
// then we have a integer ranges for the digits A, B, C, D