Skip to content

Instantly share code, notes, and snippets.

Avatar
🐄
moooooo

Kamil Slowikowski slowkow

🐄
moooooo
View GitHub Profile
@slowkow
slowkow / word-reorder-figures.md
Last active May 2, 2023 18:01
How to update figure references after reordering them in Microsoft Word
View word-reorder-figures.md

How to update figure references in Word

Add a new caption in the Figure Legends section of your manuscript:

  • In the menu bar, click Insert > Caption...
  • Type a name like "My great data" — you can always change it later.
  • Click OK
@slowkow
slowkow / circle-montage.md
Created March 21, 2023 22:52
Make a montage of circle-cropped photos
View circle-montage.md

Make a montage of circle-cropped photos

Here are the source files, the masked output folder, and the montage.png output file:

Here are the images in the masked output folder:

@slowkow
slowkow / rotating-3d-mp4.R
Last active August 22, 2022 18:37
Make an animation to visualize millions of points in 3 dimensions.
View rotating-3d-mp4.R
library(data.table)
library(glue)
library(rgl)
# https://github.com/google/palette.js/blob/master/palette.js
mpn65 <- c(
'#ff0029', '#377eb8', '#66a61e', '#984ea3', '#00d2d5', '#ff7f00', '#af8d00',
'#7f80cd', '#b3e900', '#c42e60', '#a65628', '#f781bf', '#8dd3c7', '#bebada',
'#fb8072', '#80b1d3', '#fdb462', '#fccde5', '#bc80bd', '#ffed6f', '#c4eaff',
'#cf8c00', '#1b9e77', '#d95f02', '#e7298a', '#e6ab02', '#a6761d', '#0097ff',
@slowkow
slowkow / copy-to-google.sh
Created March 23, 2022 15:13
Copy files from Broad to Google
View copy-to-google.sh
#!/usr/bin/bash
#$ -N MY_JOB_NAME
#$ -o /path/on/broad/server/
#$ -e /path/on/broad/server/
#$ -cwd
#$ -j y
#$ -l h_rt=12:00:00
#$ -pe smp 8 -R y -binding linear:8
#$ -l h_vmem=2G
#
@slowkow
slowkow / plot-umap-experiment.R
Last active June 27, 2022 20:09
UMAP on 30k cells with different values for min_dist and spread
View plot-umap-experiment.R
library(uwot)
library(scattermore)
library(foreach)
library(doParallel)
library(data.table)
library(ggplot2)
library(scales)
library(glue)
# This code snippet assumes we have these objects:
@slowkow
slowkow / pay-water-bill.py
Created May 3, 2021 01:32
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 December 23, 2020 19:40
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 October 21, 2020 18:48
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 October 15, 2020 13:46
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 March 16, 2020 21:08
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),