Skip to content

Instantly share code, notes, and snippets.

View berdosi's full-sized avatar

Bálint Erdősi berdosi

View GitHub Profile
@berdosi
berdosi / tagImages.sh
Last active July 24, 2019 19:19
set image comment to labels detected via AWS
#!/bin/sh
MAXLABELCOUNT=4
MINCONFIDENCE=90
mkdir smallpics
# create smaller versions, that are both small and big enough for image recognition
parallel convert {} -resize 2048x2048 -quality 90 smallpics/{} ::: *.jpg
@berdosi
berdosi / arrow.svg
Created September 17, 2019 22:11
basic commented picture of an arrow
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@berdosi
berdosi / RenameFilesMatchingPattern.ps1
Last active January 28, 2020 10:10
Powershell snippet to do something with items with matching names in a directory
Get-ChildItem |
Where-Object -Property "Name" -Like "*remove this part from the filename*" | # filtering
ForEach-Object {
# action to do. Case in point: rename the file. Note the parentheeses around the two parameters.
Move-Item ($_.Name) ([System.Text.RegularExpressions.Regex]::Replace($_.Name, "remove this part from the filename", ""))
}
@berdosi
berdosi / GPX_to_GIS.sql
Last active February 11, 2020 23:11
PostgreSQL: Get the trackpoints from a table containing GPX data into PostGIS geometry.
-- i_am_spatial.raw_gpx_data's gpx_xml column contains GPX data stored as XML.
-- below query lists the trackpoints from this table, along with the file_id they belong to.
--
-- PostGIS is necessary to have the geometry data type available. Otherwise, the outermost SELECT can be removed.
SELECT
file_id,SELECT
file_id,
point_time,
lat,
@berdosi
berdosi / pseudorandom.sql
Last active May 31, 2020 12:20
PostgreSQL functions to get the n-th pseudorandom number generated by random() based on a given seed.
CREATE FUNCTION pseudorandom(seed DOUBLE PRECISION, n int)
RETURNS DOUBLE PRECISION AS $$
-- Set the seed (optional). When recursing, this is obviously not done.
SELECT CASE WHEN seed IS NOT NULL THEN setseed(seed) END;
-- recurse until counter reaches 0
SELECT CASE WHEN n>0 THEN pseudorandom(NULL, n-1) END;
-- run random() once. When counter reached 0, this will be the returned.