Skip to content

Instantly share code, notes, and snippets.

View ivan-krukov's full-sized avatar
🗃️
Getting there

Ivan Krukov ivan-krukov

🗃️
Getting there
View GitHub Profile
@ivan-krukov
ivan-krukov / Imports.pm
Created October 19, 2014 08:44
Imports - default modules I want to use everywhere in perl
package Imports;
strict->import();
warnings->import(qw(FATAL));
5.010_000->import();
utf8->import();
1;
@ivan-krukov
ivan-krukov / pointer_madness.xs
Created November 3, 2014 02:55
Get a structure pointer from perl's SV containing T_PTRREF
typedef struct datum {
int number;
} datum;
typedef datum * table;
TYPEMAP: <<END
table T_PTRREF
END
@ivan-krukov
ivan-krukov / median.c
Last active August 29, 2015 14:10
Memory-efficient median calculation
#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 / data.csv
Last active August 29, 2015 14:16
A simple kNN implementation
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 / README.md
Last active August 29, 2015 14:17
Chords

#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 / README.md
Last active March 6, 2021 03:49
My favourite keymap

#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.

@ivan-krukov
ivan-krukov / README.md
Last active August 29, 2015 14:18
Shuffle and relabel observations in a csv file

#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 / hello.fa
Created August 24, 2015 21:50
Multiple file suffixes in makefile rules
>sequence 1
ACTG
@ivan-krukov
ivan-krukov / clone_all.sh
Last active March 17, 2016 03:34
Clone all repos for a given user
#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 / R_ify.R
Created March 30, 2016 16:18
Use dots instead of dollar signs in R
# Use dots (.) instead of ($)
R_ify <- function(expr) eval(parse(text=
gsub("\\.","$",substitute(expr))))
R_ify(mtcars.mpg)