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
@ivan-krukov
ivan-krukov / print_vector.cpp
Created Apr 19, 2016
Print vectors in C++, easy as `cout << vector << endl`
View print_vector.cpp
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << "[";
typename vector<T>::const_iterator it;
for (it = v.begin(); it != v.end() - 1; ++it) {
os << *it << ", ";
}
os << *(it) << "]";
return os;
}
@ivan-krukov
ivan-krukov / R_ify.R
Created Mar 30, 2016
Use dots instead of dollar signs in R
View R_ify.R
# Use dots (.) instead of ($)
R_ify <- function(expr) eval(parse(text=
gsub("\\.","$",substitute(expr))))
R_ify(mtcars.mpg)
@ivan-krukov
ivan-krukov / clone_all.sh
Last active Mar 17, 2016
Clone all repos for a given user
View clone_all.sh
#Get repo list, filter git urls
GITHUB_NAME=octocat
curl https://api.github.com/users/$GITHUB_NAME/repos > github_response
for repo in `cat github_response | jq -r '.[] | .git_url'`; do;
git clone $repo;
done
@ivan-krukov
ivan-krukov / hello.fa
Created Aug 24, 2015
Multiple file suffixes in makefile rules
View hello.fa
>sequence 1
ACTG
@ivan-krukov
ivan-krukov / README.md
Last active Aug 29, 2015
Shuffle and relabel observations in a csv file
View README.md

#Randomization script

The idea is to do bootstrap resampling on the control dataset to make sure it is appropriate as a control dataset.

#Usage

python randomize.py <input.csv> <resample_times>
@ivan-krukov
ivan-krukov / README.md
Last active Aug 29, 2015
My favourite keymap
View README.md

#Custom Keymap (Lenovo T430)

This will apply settings for both system console and Xorg server.

  • CapsLock will become an extra Esc
  • Home will be switched with PageUp
  • End will be switched with PageDown

This makes sense for the Lenovo T430, where PageUp and PageDown are right next to the arrow keys.

View README.md

#20 chords A simple chord diagram for amino-acid relationships ##Usage

The input data should be a 20x20 table with tabs as separators.

To run the thing, do this (uses firefox)

git clone https://gist.github.com/ivan-kryukov/c265c9df6bfeda28abc8
@ivan-krukov
ivan-krukov / data.csv
Last active Aug 29, 2015
A simple kNN implementation
View data.csv
1 1 0
1 2 0
1 3 0
2 1 0
2 2 0
2 3 0
4 1 1
4 2 1
4 3 1
5 1 1
@ivan-krukov
ivan-krukov / median.c
Last active Aug 29, 2015
Memory-efficient median calculation
View median.c
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
/**
* Median calculation
* This program takes an input file with one number per line and calculates mean and median.
@ivan-krukov
ivan-krukov / pointer_madness.xs
Created Nov 3, 2014
Get a structure pointer from perl's SV containing T_PTRREF
View pointer_madness.xs
typedef struct datum {
int number;
} datum;
typedef datum * table;
TYPEMAP: <<END
table T_PTRREF
END
You can’t perform that action at this time.