Skip to content

Instantly share code, notes, and snippets.

View stelf's full-sized avatar
🦌
focusing 🦊

Gheorghi stelf

🦌
focusing 🦊
View GitHub Profile
@stelf
stelf / closest_bus_school_pairs.sql
Last active April 17, 2024 10:24
closest bus stop in respect to each school.
-- notes:
-- Use a CROSS JOIN when you need a simple Cartesian product without any dependency between the rows of the joined tables.
-- Use a CROSS JOIN LATERAL when the second table's rows depend on values from the first table's current row, allowing for
-- dynamic and row-specific computations during the join process. This is powerful for queries requiring a contextual
-- relationship between the data sets. Lateral means "to the side"
--
-- using CROSS JOIN and subquery
SELECT * FROM (
@stelf
stelf / strip.schema.xslt
Created January 11, 2024 23:16
strip VisionR schema
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Template to process objectdefs and descend into module_name/objectdef/objectprop and match metaprops -->
<xsl:template match="import | objectdefs | objectdefs/* | objectdefs/*/* | objectdefs/*/*/* ">
<xsl:copy>
<xsl:apply-templates select="*"/>
</xsl:copy>
</xsl:template>
@stelf
stelf / geocode_csv_to_postgis_gmaps.py
Created March 17, 2023 15:38
geocoding a source CVS with google maps and then feed into a table in PostGIS
# geocoding a source CVS with google maps
# and then feed into a table in PostGIS
#
# interestingly some parts of the code were created with ChatGPT4
# but the output, of course, had to be revised a little
#
# license CC-Attribution
3
import csv
@stelf
stelf / jira.identifiers.keycloud.sql
Created June 13, 2022 13:45
Oracle PLSQL: JIRA identifiers clowd matched against ticket keys (for analysis)
SELECT distinct
upper(CAST (keywords.str AS varchar2(32))) AS keyword,
JP.pkey || '-' || JI.issuenum AS issuekey
FROM
JIRAACTION jA
JOIN jiraissue JI ON
JA.issueid = JI.id
JOIN project JP ON
JI.project = JP.id
CROSS JOIN lateral
@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 );