Skip to content

Instantly share code, notes, and snippets.

Avatar

Ruben Berenguel rberenguel

View GitHub Profile
@rberenguel
rberenguel / obsidianTodayWidget.js
Last active Jan 1, 2022
Quick-and-dirty Scriptable (https://scriptable.app/) script to show a medium widget with today's tasks from Obsidian, for my set up (today is in journal/YYYYMMDD.md, tasks are under the `### Plan` heading). Optionally pass "tomorrow" as widget arg to render tomorrow (if it doesn't exist it will fail of course)
View obsidianTodayWidget.js
let when = args.widgetParameter || 'today'
let now = new Date()
if (when == 'tomorrow') {
now.setDate(now.getDate() + 1);
}
let formatter = new DateFormatter()
formatter.dateFormat = 'yyyyMMdd'
let today = formatter.string(now)
@rberenguel
rberenguel / plugins.md
Created Jun 25, 2021
Plugins I'm using in Obsidian as of 20210625
View plugins.md
  • Adjacency Matrix: a different way of looking at the graph. Installed for curiosity
  • Admonition: allows having "special" boxes very easily. Very recommended
  • Advanced tables: makes editing tables easier. Not very used, but worth having
  • Calendar: I keep a daily log, so this is very useful to navigate it
  • Dataview: in a way converts your notes into a database. Very helpful to organise projects by adding metadata to notes.
  • Editor syntax highlight: show code syntax in the editor too, not only in the rendered view
  • Excalidraw: awesome SVG plugin that even works on mobile
  • Hotkeys for templates: rarely used, pretty much what it says in the bottle
  • Juggl: alternative graphs
  • Kanban: A kanban based on plan markdown (there's a similar Haskell project). Works well, but not use it much
@rberenguel
rberenguel / pushToTalk.js
Last active Feb 27, 2020
Push to talk (space bar when Safari's Meet is under focus) bookmarklet for Google Meet, working under Mac OS in Safari. Code modified from https://gist.github.com/caseywatts/561bc498b6feec3d419b29a65d916663
View pushToTalk.js
javascript: (() => {const toggles = tip => ({ key }) => key === '' && document.querySelectorAll('[data-tooltip]').forEach(el => el.dataset.tooltip === tip && el.click());document.body.onkeyup = toggles('Turn off microphone (⌘ + D)');document.body.onkeydown = toggles('Turn on microphone (⌘ + D)');})();
@rberenguel
rberenguel / pushToTalk.js
Created Feb 27, 2020
Push to talk bookmarklet for Mac OS in Safari
View pushToTalk.js
javascript: (() => {const toggles = tip => ({ key }) => key === '' && document.querySelectorAll('[data-tooltip]').forEach(el => el.dataset.tooltip === tip && el.click());document.body.onkeyup = toggles('Turn off microphone (⌘ + D)');document.body.onkeydown = toggles('Turn on microphone (⌘ + D)');})();
@rberenguel
rberenguel / pyspark-workshop-requirements.md
Last active Nov 14, 2019
Quick writeup of the requirements for my PySpark workshop at PyDay 2019, Barcelona (https://pybcn.org/pyday-bcn-2019/)
View pyspark-workshop-requirements.md

To take full advantage of the workshop you'll need

  • PySpark installed (anything more recent than 2.3 should be fine)
  • Jupyter installed
  • Pandas and Arrow installed
  • All able to talk to each other
  • One or more datasets

You can clone this repository to have the notebook and slides (some things may still change until Saturday, like uploading and upgating the compiled slides, but the notebook is essentially finished).

@rberenguel
rberenguel / Lavaurs.lsp
Created Aug 24, 2019
Code I wrote around 2009 for rendering Lavaurs chords (an abstract Mandelbrot set). Blame my old self for my poor Lisp
View Lavaurs.lsp
;; Copyright 2009 Rubén Berenguel
;; ruben /at/ maia /dot/ ub /dot/ es
;; This program is free software: you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation, either version 3 of the
;; License, or (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
@rberenguel
rberenguel / Koch.ps
Created Aug 24, 2019
Koch snowflake in PostScript
View Koch.ps
%!PS-Adobe-2.0
%%% Start of L-system definition
/STARTK { FK +K +K FK +K +K FK} def
/FK {
dup 0 eq
{ DK } % if the recursion order ends, draw forward
{
1 sub % recurse
@rberenguel
rberenguel / postcard2008.ps
Created May 31, 2019
Christmas Postcard 2008 in PostScript
View postcard2008.ps
%!PS-Adobe-3.0
%%BeginFeature: *PageSize A4
<< /PageSize [595 842] >> setpagedevice
%%EndFeature
%/PageSize A4
/CoordX 595 def
/CoordY 842 def
/RadiMax 95 def
@rberenguel
rberenguel / mand.ps
Created May 31, 2019
Simple Mandelbrot set generator in PostScript
View mand.ps
%!PS-Adobe-2.0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Mandelbrot set via PostScript code. Not optimized %
% in any way. Centered in A4 paper. Escape time, B&W %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/fun {
@rberenguel
rberenguel / wat.scala
Created Mar 8, 2019
Weird companion object issue in Scala 2.11 vs 2.12
View wat.scala
case class Country(name: String) {
private val ThreeLetterValidCountries = List("FOO", "BAR")
def valid: Option[Country] =
if (ThreeLetterValidCountries.contains(name.toUpperCase)) Some(this) else None
}
object Country {
def apply(name: String): Country = new Country(name.toUpperCase)
}