Skip to content

Instantly share code, notes, and snippets.

View webbedfeet's full-sized avatar

Abhijit Dasgupta webbedfeet

View GitHub Profile
@webbedfeet
webbedfeet / name_chunks.py
Created October 2, 2024 21:56
Convert RMarkdown chunk labels to Quarto chunk labels, adding labels if they're not present
import re, os
regex = "```\{r (.+)\}"
def name_chunks(f):
"""
This function takes a quarto (.qmd) file, checks for rmarkdown-style
labels, and converts to quarto-style labels. If a quarto-style label
exists, it preserves it (it checks the first line of the chunk metadata).
If no label exists, it creates one based on the file name, in sequential order
@webbedfeet
webbedfeet / tar_h5.py
Created October 11, 2023 20:16
Selectively adding files to a tar using Python glob
from pathlib import Path
import tarfile
with tarfile.open('data.tar','w') as tar:
for name in Path('.').glob('*/filtered_feature_bc_matrix.h5'):
tar.add(name)
syntax on
filetype plugin indent on
set number
set path+=**
set noswapfile
set undofile
set incsearch
set smartindent
set ic
set expandtab
@webbedfeet
webbedfeet / df_diff.py
Created August 29, 2022 04:33
Set difference of rows of two data frames
def df_diff(d1, d2):
"""
df_diff Create a DataFrame containing rows of d1 not in d2
Arguments:
d1 -- A data frame
d2 -- Another DataFrame which is a subset of d1
Returns:
A pandas DataFrame containing rows of d1 that are not in d2
@webbedfeet
webbedfeet / Makefile
Created July 10, 2022 17:40 — forked from gernotstarke/Makefile
Makefile for authoring markdown with a (BibTeX-based) citation manager like Zotero
# For a description of this file, please see:
# https://www.innoq.com/en/blog/markdown-with-zotero-workflow
#------------------------------------------------------------
# what's the name of the generated output file(s)
OUTPUT=out
# what's the name of the markdown source file
SOURCE=principles-content.md
@webbedfeet
webbedfeet / dailyNoteTemplate.txt
Created May 23, 2022 19:27 — forked from bennewton999/dailyNoteTemplate.txt
My current Daily Note Template in Obsidian utilizing Templater and DataView Plugins
---
creation date: <% tp.file.creation_date() %>
tags: DailyNote <% tp.file.title.split('-')[0] %>
---
modification date: <%+ tp.file.last_modified_date("dddd Do MMMM YYYY HH:mm:ss") %> // This doesn't currently work in front matter, hoping that gets fixed.
# <% tp.file.title %>
<< [[<% tp.date.now("YYYY-MM-DD", -1, tp.file.title, "YYYY-MM-DD") %>]] | [[<% tp.date.now("YYYY-MM-DD", 1, tp.file.title, "YYYY-MM-DD") %>]]>>
@webbedfeet
webbedfeet / testdash.Rmd
Last active December 11, 2020 06:10
Including python-based graphics in flexdashboard
---
title: "Example dashboard"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: scroll
html_document: default
---
```{r setup, include=FALSE}
@webbedfeet
webbedfeet / coronaDeaths.R
Created March 21, 2020 20:06
Code to create COVID-19 attributed death trajectories by country using JHU data
# remotes::install_github('ramikrispin/coronavirus')
library(coronavirus)
update_datasets()
pacman::p_load(char=c('tidyverse','janitor', 'ggrepel'))
deaths <- coronavirus %>%
clean_names() %>%
filter(type=='death') %>%
group_by(country_region, date) %>%
summarise(cases = sum(cases)) %>%
@webbedfeet
webbedfeet / lowpass.py
Created November 22, 2019 05:14 — forked from junzis/lowpass.py
Python Lowpass Filter
# https://stackoverflow.com/questions/25191620/
# creating-lowpass-filter-in-scipy-understanding-methods-and-units
import numpy as np
from scipy.signal import butter, lfilter, freqz
from matplotlib import pyplot as plt
def butter_lowpass(cutoff, fs, order=5):
nyq = 0.5 * fs
#' ---
#' title: An annotated R script for Homework 6 using lists and maps
#' output: html_document
#' ---
#'
#+, include=FALSE
knitr::opts_chunk$set(error=F, warning=F, message=F)
#' First, read the data in. We've stored just the data files in the folder `data/HW6`.
library(tidyverse)