Skip to content

Instantly share code, notes, and snippets.

View kpalin's full-sized avatar

Kimmo Palin kpalin

View GitHub Profile
@kpalin
kpalin / random_effect_bambi.py
Created November 4, 2022 15:12
Test/demo model for nested priors in bambi
# %%
import pandas as pd
import numpy as np
import bambi as bmb
import arviz as az
import matplotlib.pyplot as plt
#%% [markdown]
#
@kpalin
kpalin / chimera.py
Created October 28, 2022 09:57
Plot sequence read alignments with respect to read (instead to genome)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created at Mon Mar 14 15:05:11 2016 by Kimmo Palin <kpalin@merit.ltdk.helsinki.fi>
"""
def main():
import argparse
@kpalin
kpalin / python.json
Created May 23, 2020 09:38
vs code snippet pyscript for python boilerplate
{
// Place your snippets for python here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
@kpalin
kpalin / pdfpagebox.tex
Created October 23, 2019 11:37
LaTeX command to put a box in its own resized page in a pdf file
\documentclass[11pt,a4paper]{article}
\usepackage[driver=xetex]{geometry}
\usepackage[utf8x]{inputenc}
\newsavebox{\mypagebox}
\newlength{\mypageboxheight}
@kpalin
kpalin / laskeKuningatartenAsemat.py
Last active November 11, 2018 20:58
Lasketaan 8x8 shakkilaudalla mahdollisten ei-uhkaavien kuningatarten asemien lukumäärät.
def valkoinenUhkaa(sarake,rivi,koko):
"""Palauttaa 'koko' x 'koko' kokoisen kaksiulotteisen listan 'lauta', jonka alkio on
1 joss kohdassa ('sarake','rivi') oleva shakkikuningatar uhkaa tai valloittaa
kyseistä alkiota. Muuten alkio on 0.
"""
# Alustetaan 2 ulotteinen taulukko/lista
@kpalin
kpalin / pxmagic.py
Last active April 6, 2020 22:29
IPython extension for system calls with file like return value. Good for e.g. reading awk output to pandas.
def pipex(line):
"Execute command and return stdout as file like object"
import subprocess as sp
cmd = get_ipython().var_expand(line)
p = sp.Popen(cmd,shell=True,stdout=sp.PIPE)
return p.stdout
def load_ipython_extension(ipython):
"""This function is called when the extension is loaded.
It accepts an IPython InteractiveShell instance.
@kpalin
kpalin / matplotlibrc
Created November 22, 2013 14:08 — forked from huyng/matplotlibrc
### MATPLOTLIBRC FORMAT
# This is a sample matplotlib configuration file - you can find a copy
# of it on your system in
# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it
# there, please note that it will be overridden in your next install.
# If you want to keep a permanent local copy that will not be
# over-written, place it in HOME/.matplotlib/matplotlibrc (unix/linux
# like systems) and C:\Documents and Settings\yourname\.matplotlib
# (win32 systems).
@kpalin
kpalin / bargs
Created September 24, 2012 08:24
bargs: xargs for LSF compute farms.
#!/bin/bash
# Tue Feb 17 16:18:06 GMT 2009
# submit the command on the command line to a job array with parameters from stdin (a la xargs)
# For debugging
#set -o verbose
# Die on unset variables