Skip to content

Instantly share code, notes, and snippets.

View danieltomasz's full-sized avatar

Daniel Borek danieltomasz

View GitHub Profile
@danieltomasz
danieltomasz / My template content.md
Last active March 31, 2024 10:13
Zotero Integration Obsidian new note template

I have several version of template I use with zotero.

One version of title is

literature/{{creators[0].lastName}}{{date | format ("YYYY")}} - {{title | replace("/" ,  "_") }}.md

Another, maybe easier to use in text when referring

@danieltomasz
danieltomasz / preferencje.R
Last active March 26, 2024 23:14
Plot - sondaże nt preferencji wyborczych na prezydenta Warszawy
library(ggplot2)
library(dplyr)
library(gridExtra)
library(grid)
# Create data frame
data <- data.frame(
Candidate = c(
"Rafał Trzaskowski", "Magdalena Biejat", "Tobiasz Bocheński", "Przemysław Wipler",
"Janusz Korwin-Mikke", "Romuald Starosielec", "Nie wiem", "Nie wziąłbym/wzięłabym \nudziału w wyborach"
@danieltomasz
danieltomasz / obsidian-callouts.lua
Last active May 13, 2024 09:40
Lua filter that allows passing obsidian/github callouts as quarto native in quarto >1.3
local stringify = (require "pandoc.utils").stringify
-- idea aken from https://forum.obsidian.md/t/rendering-callouts-similarly-in-pandoc/40020/6 and modified to work with Quarto 1.3
function BlockQuote(el)
local start = el.content[1]
if (start.t == "Para" and start.content[1].t == "Str" and
start.content[1].text:match("^%[!%w+%][-+]?$")) then
local firstline = stringify(start.content[1])
@danieltomasz
danieltomasz / Makefile
Last active August 11, 2023 11:20
Quick makefile to install project from gitgub
.ONESHELL:
.PHONY: install
PROJECT?=python-design
VERSION?=3.11.4
VENV=${PROJECT}-${VERSION}
VENV_DIR=$(shell pyenv root)/versions/${VENV}
PYTHON=${VENV_DIR}/bin/python
@danieltomasz
danieltomasz / dynamic-highlights.json
Created August 3, 2023 07:38
Dynamic highlights - date and words
{
"basic-datetime": {
"class": "basic-datetime",
"color": "#00000000",
"regex": true,
"query": "((\\d{4}-\\d{2}-\\d{2})T(\\d{1,2}:\\d{2})( am| pm| AM| PM)?)|((\\d{4}-\\d{2}-\\d{1,2}))|((\\d{1,2}:\\d{2}( am| pm| AM| PM)?))",
"mark": [
"match",
"group"
],
window.addEventListener("DOMContentLoaded", () => {
const highlightResults = (text, color) => {
document.designMode = "on"; // https://stackoverflow.com/a/5887719
var selection = window.getSelection();
selection.collapse(document.body, 0);
while (window.find(text)) {
document.execCommand("HiliteColor", false, color);
selection.collapseToEnd();
}
document.designMode = "off";
@danieltomasz
danieltomasz / wikilinks-filter.lua
Last active August 19, 2023 14:00
Lua filter for removing wikilinks brackets

Quarto callouts

About callouts

Callouts are a great way to add more attention ot certain details of the text (in the form of a box). Quarto provides 5 different types of callouts:

  • note
  • warning
  • important
@danieltomasz
danieltomasz / Example.r
Created January 29, 2023 23:07
Iterating over variables in glm
create_models <- function(datame_name, cog_vars, eeg_components) {
list_models <- list()
for (cogvar in cog_vars) { # ,eeg_components
for (eegvar in eeg_components) { # ,eeg_components
models <- glue("model1.{cogvar}.{eegvar} <- glm({cogvar} ~ GM_Normalised + {eegvar}, {datame_name}, family = gaussian)
list_models[['model.{cogvar}.{eegvar}']] <- model5.{cogvar}.{eegvar}") # nolint
eval(str2expression(models))
}
}
return(list_models)
@danieltomasz
danieltomasz / clearwiki.md
Last active September 14, 2022 22:26
A naive proof of the concept Lua filter removing wikilinks

A naive proof of the concept Lua filter for removing [[ wikilinks from markdown file.

function Str (str)
    return (str.text:gsub('%[%[', '')
                    :gsub('%]%]', ''))
end

When the filter is saved under name cleanwiki.lua it might be used with the flag --lua-filter=cleanwiki.lua