Skip to content

Instantly share code, notes, and snippets.

View DavidMoraisFerreira's full-sized avatar
🐢

David Morais Ferreira DavidMoraisFerreira

🐢
View GitHub Profile
@DavidMoraisFerreira
DavidMoraisFerreira / luxembourgish_citizens_first_names_gender.sparql
Last active September 15, 2022 20:16
Retrieves a list of first names and gender for Luxembourgish citizens on Wikidata
#For a list of family names, change SELECT and GROUP BY
PREFIX schema: <http://schema.org/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT ?givenNameLabel ?genderLabel #?familyNameLabel
WHERE
{
?human wdt:P31 wd:Q5 ;
wdt:P27 wd:Q32 .
@DavidMoraisFerreira
DavidMoraisFerreira / setup.sh
Last active July 31, 2022 09:25
quick notes
sudo zypper install git php7 nano zsh php-composer2 php7-dom php7-xmlwriter php7-tokenizer
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
wget https://raw.githubusercontent.com/rupa/z/master/z.sh
chmod 755 z.sh
echo ". ~/z.sh" >> .zshrc
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install --lts
@DavidMoraisFerreira
DavidMoraisFerreira / osm-tools-setup.sh
Last active May 23, 2022 20:12
required packages for running osm-revert-scripts
git clone https://github.com/woodpeck/osm-revert-scripts.git
cd osm-revert-scripts
sudo zypper install perl perl-libwww-perl perl-File-HomeDir perl-LWP-Protocol-https
xargs -a nodes.txt -I{} -d'\n' perl redaction.pl apply XXX node {} "XXX"
@DavidMoraisFerreira
DavidMoraisFerreira / LuxembourgPaddedBoundary.geojson
Created January 28, 2022 11:28
Padded boundary of Luxembourg in GeoJSON
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@DavidMoraisFerreira
DavidMoraisFerreira / extract-otp-codes-from-freeotp-export.sh
Last active January 27, 2022 21:11
Extract OTP codes and visualise them as QR codes from an encrypted FreeOTP ADB export
#!/bin/zsh
adb start-server
adb backup -f android-org.fedorahosted.freeotp.adb org.fedorahosted.freeotp
git clone https://github.com/nelenkov/android-backup-extractor.git
cd android-backup-extractor
./gradlew
export $ABE_PASSWD=<yourPasswordHereWithoutBrackets>
java -jar build/libs/abe-all.jar unpack android-org.fedorahosted.freeotp.adb android-org.fedorahosted.freeotp.tar
cd ..
git clone https://github.com/viljoviitanen/freeotp-export.git
@DavidMoraisFerreira
DavidMoraisFerreira / luxembourgish_citizen_without_familyname.sparql
Last active September 15, 2022 21:13
Find Luxembourgish citizens on Wikidata without a family name
PREFIX schema: <http://schema.org/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT DISTINCT ?human ?humanLabel (group_concat(?givennameLabel;separator=', ') as ?givenNames)
WHERE
{
?human wdt:P31 wd:Q5 ;
wdt:P27 wd:Q32 .
?human wdt:P735 ?givenname .
dmlu@errol:~/luxaddr$ cat /home/dmlu/luxaddr/update-addr-findings.sh
psql -A -F"," -P "footer=off" -d luxaddr > '/home/dmlu/public_html/luxaddr/no-match.csv' << EOF
COPY (
WITH osm_potential_addresses AS (
SELECT osm_id, tags->'osm_user' as osm_user, tags->'osm_uid' as osm_uid, tags->'osm_version' as osm_version, tags->'osm_timestamp' as osm_timestamp, concat('https://osm.org/way/' , osm_id) as url, "addr:housenumber", "addr:place", "addr:street", "addr:postcode", "addr:city", "addr:country", "ref:caclr", "note", "note:caclr", "fixme", way
FROM planet_osm_polygon
WHERE
"addr:housenumber" IS NOT NULL
AND "addr:street" IS NOT NULL
-- AND "addr:postcode" IS NOT NULL
select ST_AsGeoJSON(t.*)
from (
select distinct st_transform(ST_LineMerge(ST_UNION(trp_vc.wkb_geometry)), 4326),
addresses.rue
from trp_vc,
addresses
where trp_vc.id_rue_cac = addresses.id_caclr_rue
and not exists (
select 1
from road_names_osm
@DavidMoraisFerreira
DavidMoraisFerreira / luxembourg.shp.geojson.poly
Last active September 7, 2020 10:02
Boundary for Luxembourg in POLY format. Extracted from the official dataset.
luxembourg.geojson
1
5.888332 50.093352
5.888453 50.093541
5.888692 50.094004
5.888784 50.094199
5.889087 50.095078
5.889186 50.095279
5.889286 50.095547
5.889339 50.095624
@DavidMoraisFerreira
DavidMoraisFerreira / no-match.csv
Last active January 27, 2022 21:06
🇱🇺 Addresses in Luxembourg without a match to the official dataset (CACLR) ⏲️ Runs nightly at 5am ⬆️ https://dmlu.dev.openstreetmap.org/luxaddr/
We can't make this file beautiful and searchable because it's too large.
osm_id,url,numero,rue,codepostal,localite,note
"379545515","https://osm.org/way/379545515","1","Route de Leudelange","3311","Abweiler",
"302382940","https://osm.org/way/302382940","2","Route de Leudelange","3311","Abweiler",
"302382941","https://osm.org/way/302382941","4","Route de Leudelange","3311","Abweiler",
"302382943","https://osm.org/way/302382943","6","Route de Leudelange","3311","Abweiler",
"217189849","https://osm.org/way/217189849","1","Rue du Village","3311","Abweiler",
"217189832","https://osm.org/way/217189832","17","Rue du Village","3311","Abweiler",
"217189836","https://osm.org/way/217189836","2","Rue du Village","3311","Abweiler",
"217189833","https://osm.org/way/217189833","28","Rue du Village","3311","Abweiler",
"217189837","https://osm.org/way/217189837","35","Rue du Village","3311","Abweiler",