Skip to content

Instantly share code, notes, and snippets.

Avatar
🐄
moo

Kamil Slowikowski slowkow

🐄
moo
View GitHub Profile
@slowkow
slowkow / pay-water-bill.py
Created May 3, 2021
Pay your water bill in Baltimore City
View pay-water-bill.py
#!/usr/bin/env python3
# pay-water-bill.py
# 2021-05-02
"""
Pay your water bill in Baltimore City
=====================================
Steps:
@slowkow
slowkow / montage.py
Created Dec 23, 2020
Make a montage from a list of PDF files
View montage.py
#!/usr/bin/env python
"""
montage.py
2020-12-23
Kamil Slowikowski
Usage
-----
Write montage.png from a list of PDF files, each panel 500px wide:
@slowkow
slowkow / rsa-example.R
Created Oct 21, 2020
A toy example of RSA encryption and decryption
View rsa-example.R
#!/usr/bin/env Rscript
# rsa-example.R
#
# Inspired by Alex Van de Sande
# https://twitter.com/avsa/status/1318672796415819776
last_digit <- function(x) {
x_char <- as.character(x)
as.numeric(substr(x_char, nchar(x_char), nchar(x_char)))
}
@slowkow
slowkow / income.svg
Last active Oct 15, 2020
Trends in Income From 1975 to 2018 by Carter C. Price, Kathryn A. Edwards
View income.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@slowkow
slowkow / writeMMgz.R
Created Mar 16, 2020
Write a gzip compressed Matrix Market file in R.
View writeMMgz.R
#' @param x A sparse matrix from the Matrix package.
#' @param file A filename that ends in ".gz".
writeMMgz <- function(x, file) {
mtype <- "real"
if (is(x, "ngCMatrix")) {
mtype <- "integer"
}
writeLines(
c(
sprintf("%%%%MatrixMarket matrix coordinate %s general", mtype),
@slowkow
slowkow / needleman-wunsch.py
Created Feb 5, 2020
A simple version of the Needleman-Wunsch algorithm in Python.
View needleman-wunsch.py
#!/usr/bin/env python
"""
The Needleman-Wunsch Algorithm
==============================
This is a dynamic programming algorithm for finding the optimal alignment of
two strings.
Example
-------
@slowkow
slowkow / read_cellranger.R
Last active Aug 4, 2020
Read Cell Ranger HDF5 .h5 files in R
View read_cellranger.R
# install.packages(c("Matrix", "rhdf5", "tidyverse"))
library(Matrix)
library(rhdf5)
library(tidyverse)
library(glue)
my_h5_files <- Sys.glob(
"path/to/cellranger-per-channel/output/*/filtered_feature_bc_matrix.h5"
)
@slowkow
slowkow / install-units.md
Last active Oct 1, 2019
Install the 'units' R package on Partners
View install-units.md

Summary

I had a difficult time installing the units R package on the Partners ERIS servers.

I hope this post helps you to figure out how to work around the errors.

Instructions

@slowkow
slowkow / pubmed-publications.html
Created May 3, 2019
Get an HTML list of PubMed publications
View pubmed-publications.html
<!DOCTYPE html>
<body>
<!-- Copied directly from http://www.ephys.org/ by Damian J Williams -->
<input placeholder="Kamil Slowikowski" name="name"/>
<p id="demo"></p>
<script>
@slowkow
slowkow / README.md
Last active May 10, 2021
Generate a DESCRIPTION file with all of your installed packages
View README.md

Problem

We need to install a lot of R packages each time we upgrade to a new version of R.

Solution

  1. Before installing the new R, run Rscript make_description.R to write a list of all installed packages.
  2. Install the new version of R.
  3. Use devtools to reinstall the packages.