Skip to content

Instantly share code, notes, and snippets.

View vehrka's full-sized avatar

Pedro-Juan Ferrer vehrka

View GitHub Profile

Main steps

  1. Use obsidian-export to filter the obsidian Vault «source folder» that we want to publish into a «destination folder» also in the same Vault.
  2. Re-create Listings and Index page using the Templater plugin
  3. Export the «destination folder» in the Vault using the Webpage HTML Export plugin to a «to publish directory» (outside the Vault) that is going to be published in GitHub.
  4. Upload the content to GitHub in a repo with GitHub pages enabled.

obsidian-export

@vehrka
vehrka / tor2e_pc_character_sheet_obsidian.md
Created January 28, 2023 11:38
Obsisian.md template for a Playing Character sheet for the The One Ring RPG 2e
Campaign type summary
CAMPAIGN
PJ
SUMMARY

Culture: =this.culture Calling: =this.calling Cultural Blessing: =this.CulturalBlessing Shadow Path: =this.ShadowPath

@vehrka
vehrka / postgis_to_geopackage.py
Created March 25, 2020 07:53
GDAL Python From Postgis to Geopackage
import os
from osgeo import ogr, gdal
PG_CONN = {
'user': os.getenv('DATA_USER'),
'password': os.getenv('DATA_PWD'),
'port': os.getenv('DATA_PORT'),
'host': os.getenv('DATA_HOST'),
}
CREATE OR REPLACE FUNCTION slugify("value" TEXT)
RETURNS TEXT AS $$
WITH lowercased AS (
SELECT lower(value) AS value
),
translated AS (
SELECT translate( value,
'áàâãäåāăąèééêëēĕėęěìíîïìĩīĭḩóôõöōŏőùúûüũūŭůäàáâãåæçćĉčöòóôõøüùúûßéèêëýñîìíïş',
'aaaaaaaaaeeeeeeeeeeiiiiiiiihooooooouuuuuuuuaaaaaaeccccoooooouuuuseeeeyniiiis'
) AS value
def __poly_decode_trans(value, index):
"""Transforms a GMaps Encoded polyline chunk back into numbers
Args:
value: chunk of the GMaps polyline
index: position in the chunk
Returns:
chunk as a number
"""
@vehrka
vehrka / minimal.vimrc
Created July 31, 2019 07:12
Minimal vimrc
set number
set numberwidth=5
set nocompatible " be iMproved, required
set backspace=indent,eol,start " Backspace for dummies
set linespace=0 " No extra spaces between rows
set showmatch " Show matching brackets/parenthesis
set incsearch " Find as you type search
set hlsearch " Highlight search terms
set winminheight=0 " Windows can be 0 line high
set ignorecase " Case insensitive search
@vehrka
vehrka / assign_isocodes.zsh
Created December 7, 2018 08:36
Assign isocode to shapes programatically
find . -name "*.shp" | sort > shps.txt
# In this case: the name of the country is the first word of the shape name and after there is a number
sed -ie 's/^\.\/\([a-z_-]*\)_\([0-9]\)/\1,.\/\1_\2/' shps.txt
cat shps.txt | header -a cname,shape > shapes.txt
csvcut -c 1 shapes.txt | uniq | sort > countries.txt
# This works only in Mac
pbcopy < countries.txt
# Match the countries with the isocodes
csvjoin -c cname countries.txt shapes.txt | csvcut -c 1,3 > isoshapes.csv
# ZSH to read a file
# coding: utf-8
import requests
import json
import os
base_url = 'https://www.humblebundle.com/api/v1/order/{download_key}'
# Get this one from the bundle page url
download_key = ''
@vehrka
vehrka / wait_for_page_load
Created July 5, 2018 13:52
Selenium wait for a page to load completely
## Stolen from http://www.obeythetestinggoat.com/how-to-get-selenium-to-wait-for-page-load-after-a-click.html
class wait_for_page_load(object):
def __init__(self, browser):
self.browser = browser
def __enter__(self):
self.old_page = self.browser.find_element_by_tag_name('html')
@vehrka
vehrka / csv_validation.py
Created June 21, 2018 12:20
Validation of CSV file using yaml field definition
# coding: utf-8
import pandas as pd
import numpy as np
import yaml
# ## Input data file
venues_filename = 'venues.csv'