Skip to content

Instantly share code, notes, and snippets.

Ivan Krukov ivan-krukov

  • Canada
View GitHub Profile
@ivan-krukov
ivan-krukov / pad-rename.sh
Created Mar 20, 2018
Rename a bunch of files by zero padding
View pad-rename.sh
N=100
# create
for ((i = 1; i <= N; i++)); do
touch e-$i.csv
done
# rename
# note %04d - pad to 4 zeros
for ((i = 1; i <= N; i++)); do
@ivan-krukov
ivan-krukov / .vimrc
Created Sep 20, 2017
vimrc for Vim 8
View .vimrc
" Plugins {{{
call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdcommenter'
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
Plug 'christoomey/vim-tmux-navigator'
Plug 'chriskempson/base16-vim'
Plug 'sheerun/vim-polyglot'
Plug 'fatih/vim-go'
Plug 'SirVer/ultisnips'
Plug 'scrooloose/nerdtree'
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Elementary observables</title>
</head>
<body>
<script src="https://unpkg.com/@reactivex/rxjs@5.0.3/dist/global/Rx.js"></script>
<button id='error'>Will throw</button>
View bootstrap.R
# bootstrap.R
cat("Loading packages\n")
library(tidyverse)
library(RefFreeEWAS)
library(qvalue)
cat("Loading data\n")
load("pdat.merge.rdata")
load("betas.rdata")
View Default.sublime-keymap
[
// Align
{ "keys": ["super+.", "super+a"], "command": "alignment" },
// Surround
{ "keys": ["super+.", "super+s", "super+s"], "command": "surround_selection"},
{ "keys": ["super+.", "super+s", "super+d"], "command": "surround_delete"},
{ "keys": ["super+.", "super+s", "super+c"], "command": "surround_change"},
// Expand selection
{ "keys": ["super+shift+'"], "command": "expand_selection_to_quotes"},
{ "keys": ["super+shift+;"], "command": "expand_selection", "args": {"to": "scope"}},
@ivan-krukov
ivan-krukov / README.md
Created Sep 5, 2016
Metropolis Beamer theme framesubtitle
View README.md

Metropolis framesubtitle

This is an attempt to have frame subtitle support for the Metropolis Beamer theme. Since there is no native support in the theme itself, this is somewhat of a hack.

This adds an extra beamercolorbox, equivalent to a frametitle box, but with a different name.

@ivan-krukov
ivan-krukov / grep_operator.Rmd
Last active Jun 7, 2016
Simpler logical subsetting by strings with `grep`
View grep_operator.Rmd
```{r, echo=FALSE}
library(magrittr)
```
# `%grep%` operator
Using `R`'s built-in `grep` function is really inconvenient for interactive work.
There already exists a convenient `%in%` operator for testing membership in a sequence.
However, real data analysis rarely presents with well-defined sequences.
Strings are much more common.
@ivan-krukov
ivan-krukov / README.md
Last active Apr 27, 2016
Get ENSEMBL IDs for a given KEGG pathway
View README.md

Problem

For a given KEGG pathway, we want to get a list of all the genes. Ensembl IDs are convenient here.

KEGG provides a REST API for some tasks, but is far from complete. For example, it is possible to map from KEGG to NCBI IDs, but not to Ensembl IDs.

The implementation peforms the following steps:

@ivan-krukov
ivan-krukov / jupyter-imshow.py
Last active Mar 30, 2019
Show opencv image in ipython notebook
View jupyter-imshow.py
import cv2
import urllib.request
# Will use matplotlib for showing the image
from matplotlib import pyplot as plt
# Plot inline
%matplotlib inline
# For local images, read as usual
@ivan-krukov
ivan-krukov / multinomial.cpp
Created Apr 21, 2016
Generating multinomial random variates via the binomial conditional method
View multinomial.cpp
#include <vector>
#include <numeric>
#include <random>
using namespace std;
template <typename T>
T sum(vector<T> v) {
return accumulate(v.begin(), v.end(), 0.0);
}
You can’t perform that action at this time.