Skip to content

Instantly share code, notes, and snippets.

View RuizSerra's full-sized avatar

Jaime RuizSerra

  • University of Sydney, Swinburne University of Technology
  • Sydney, Australia
  • X @JRuizSerra
View GitHub Profile
@RuizSerra
RuizSerra / md_to_latex.py
Last active April 4, 2023 13:46
Obsidian.md 👉 LaTeX
#!/usr/bin/env python
#
# * Converts citations:
# "[[Lastname2019a]]" into "\cite{Lastname2019a}"
#
# * Interprets code blocks with four back-ticks (````) as comments,
# and those with three back-ticks (```) as "lstlisting" environments.
#
# * Images:
# "![[Image Name.png]]" into "\figure (blablablabla)"
@RuizSerra
RuizSerra / tidy_up.sh
Last active September 25, 2020 08:33
Tidy up Zettelkasten vault
#!/bin/bash
#
# Tidy up files in Zettelkasten vault
# Ensure we are running this in the right directory
[[ "$(basename $PWD)" -eq "zettelkasten" ]] || exit 1
# Delete empty files
find . -type f -size 0 -exec echo Removing empty file: {} \; -exec rm "{}" \;
"""
Based on @4rtemi5 's TF implementation, ported to PyTorch
https://www.rpisoni.dev/posts/cossim-convolution/
"""
import torch
from torch import nn
import torch.nn.functional as F
class CosSimConv2D(nn.Module):
@RuizSerra
RuizSerra / instapaper_import.py
Last active September 10, 2022 09:02
PaperSpan to Instapaper
"""
Given exports from PaperSpan, Diigo, Pocket, format for import to Instapaper.
Run the script, browse to https://www.instapaper.com/user and select "Import from Instapaper CSV"
"""
import datetime
import csv
import re
@RuizSerra
RuizSerra / minority_game_mesa.py
Last active December 30, 2022 03:35
A MESA Python implementation of the Minority Game
"""
A Python MESA implementation of the Minority Game (Challet and Zhang, 1997)
Author: Jaime Ruiz Serra
Date: Dec 2022
"""
import mesa
import numpy as np
from scipy.stats import bernoulli
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@RuizSerra
RuizSerra / redact-student-names.py
Created March 21, 2024 06:31
To redact student names from `.html` comparison files
from bs4 import BeautifulSoup
import re
import os
import zipfile
def redact_names(html_filename, OUTPUT_DIR='.'):
## Load html file
with open(html_filename, 'r') as f:
txt = f.read()
/*
Given an Obsidian markdown note named "YYYYwNN.md",
where YYYY is the year and NN is the week number,
e.g. "2024w07.md", this Dataview JS snippet will list all
the notes in the valut created between the Thursday of that week
and the Wednesday of the following week.
Include this code snippet in your weekly note template within a dataviewjs block:
```dataviewjs