Skip to content

Instantly share code, notes, and snippets.

View slowkow's full-sized avatar
🐄
moooooo

Kamil Slowikowski slowkow

🐄
moooooo
View GitHub Profile
@slowkow
slowkow / perlin-noise-classical.js
Created May 31, 2017 13:45 — forked from banksean/perlin-noise-classical.js
two Perlin noise generators in javascript. The simplex version is about 10% faster (in Chrome at least, haven't tried other browsers)
// Ported from Stefan Gustavson's java implementation
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
// Read Stefan's excellent paper for details on how this code works.
//
// Sean McCullough banksean@gmail.com
/**
* You can pass in a random number generator object if you like.
* It is assumed to have a random() method.
*/
@slowkow
slowkow / proxy.sh
Last active February 5, 2021 14:30 — forked from sheerun/proxy
Automatic SOCKS proxy setup through SSH connection on Mac OS X
#!/usr/bin/env bash
# Script for automatic setup of SOCKS proxy through SSH connection.
# It automatically teardowns SOCKS configuration before stopping.
# It's supposed to work on Mac OS X 10.6+
#
# Author: Adam Stankiewicz (@sheerun)
#
[[ -n "$1" ]] || { echo "Usage: proxy [email protected]"; exit 1; }
@slowkow
slowkow / colorgorical.md
Last active July 23, 2018 17:38
Call Colorgorical from R http://vrl.cs.brown.edu/color
# install.packages(c("httr", "jsonlite"))

colorgorical <- function(n = 10) {
  post_body <- jsonlite::toJSON(
    auto_unbox = TRUE,
    list(
      'paletteSize' = n,
      'weights' = list(
 'ciede2000' = 0,
@slowkow
slowkow / optimize_html.py
Last active November 21, 2022 23:04
Optimize base64 encoded PNG images in an HTML file.
#!/usr/bin/env python
"""
optimize_html.py
Kamil Slowikowski
November 14, 2016
Optimize base64 encoded PNG images in an HTML file.
USAGE
@slowkow
slowkow / hook_pngquant.R
Created November 15, 2016 17:14
Use pngquant to optimize PNG files generated by knitr.
#' ---
#' title: "pngquant demo"
#' author: "Kamil Slowikowski"
#' date: "`r Sys.Date()`"
#' output:
#' html_document:
#' self_contained: true
#' ---
#+ setup, include=FALSE
@slowkow
slowkow / pdfoptim.sh
Last active August 18, 2023 22:13
Optimize PDF files with Ghostscript.
#!/usr/bin/env bash
# pdfoptim.sh
#
# Optimize a PDF with Ghostscript
#
# Usage: bash pdfoptim.sh FILE.pdf
#
# This will copy the input file to FILE-original.pdf
# And write an optimized file to FILE.pdf
#
@slowkow
slowkow / granger.md
Last active October 19, 2016 14:39
Granger Test

The lmtest package provides a Granger Test function:

set.seed(42)
x <- rnorm(10)
y <- rnorm(10)

lmtest::grangertest(x, y, order = 1)
@slowkow
slowkow / gallery.py
Last active October 14, 2016 15:19
Create an image gallery.html in the current folder.
@slowkow
slowkow / do_hyper.R
Last active August 29, 2022 18:33
Compute a hypergeometric p-value for a gene set of interest.
# Try this with:
# - https://github.com/jefworks/genesets
# - https://github.com/slowkow/tftargets
#' Compute a hypergeometric p-value for your gene set of interest relative to
#' a universe of genes that you have defined.
#'
#' @param ids A vector with genes of interest.
#' @param universe A vector with all genes, including the genes of interest.
@slowkow
slowkow / usage_brief.py
Created August 11, 2016 14:57
Read usage_report.txt and list sizes of folders in a specified parent folder.
#!/usr/bin/env python
"""
usage_brief.py
Kamil Slowikowski
August 11, 2016
(Works with Python 2 and 3)
# USAGE