Skip to content

Instantly share code, notes, and snippets.

Ivan Krukov ivan-krukov

  • Canada
Block or report user

Report or block ivan-krukov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
import numpy as np
from collections import Counter, defaultdict
def __f(x, i, j):
'''Consume a state to generate a sequence of haplotypes picked'''
pairs = []
y = x.copy()
while True:
ivan-krukov /
Last active Mar 30, 2019
Show opencv image in ipython notebook
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 /
Created Jun 6, 2013
Complete download file over FTP example. Complete with write-report closure in python3 style, writing stdout to same line and nice verbosity handling
#!/usr/bin/env python3
from ftplib import FTP
def ftp_download(server,remote_path,local_path,username="anonymous",password="",verbose=True):
#new ft object
ftp = FTP(server)
if verbose: print("Connected to %s"%server)
#notice that default login is "anonymous" with no password. works on most public servers
ivan-krukov /
Created Mar 20, 2018
Rename a bunch of files by zero padding
# create
for ((i = 1; i <= N; i++)); do
touch e-$i.csv
# rename
# note %04d - pad to 4 zeros
for ((i = 1; i <= N; i++)); do
ivan-krukov /
Created Nov 5, 2013
Using Perl Inline::CPP and perlapi to pass around array data
use warnings;
#not sure how to use strict here - does not allow bareword in "Inline CPP"
use Inline CPP;
my @data = (0..10);
my $result_ref = do_stuff(\@data);
my @result = @$result_ref;
print "@result\n";
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>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Elementary observables</title>
<script src=""></script>
<button id='error'>Will throw</button>
View bootstrap.R
# bootstrap.R
cat("Loading packages\n")
cat("Loading data\n")
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 /
Created Sep 5, 2016
Metropolis Beamer theme framesubtitle

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.

You can’t perform that action at this time.