Skip to content

Instantly share code, notes, and snippets.

View danieltomasz's full-sized avatar

Daniel Borek danieltomasz

View GitHub Profile
@danieltomasz
danieltomasz / git_time_word_count.sh
Last active September 5, 2024 19:03
A simple script to count net changes in the git repository for the defined file extensions (useful for daily goals when writing thesis/articles)
#!/bin/bash
# Git Word Count Analyzer
# Copyright (c) 2024 Daniel Borek
# MIT License
# Inspired by https://www.gijsvandam.nl/post/measuring-your-writing-progress-with-a-git-word-count/
# Configuration
# FILE_EXTENSIONS: Array of file extensions to analyze (e.g., "typ" "md")
# Separate multiple extensions with spaces
FILE_EXTENSIONS=("typ" "md" )
@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 September 3, 2024 06:20
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)