Skip to content

Instantly share code, notes, and snippets.

@Aszarsha
Aszarsha / extractFasta.nim
Last active August 29, 2015 14:17
Extract peptide counts from count matrix in new fasta files
#Add those lines to lib/system.nim:
iterator pairs*[T](it: iterator(): T {.inline.}): tuple[key: int, val: T] {.inline.} =
## iterates over each item of it. Yields ``(index, item)`` pairs.
var i = 0
for v in it:
yield (i, v)
inc(i)
iterator mpairs*[T](it: iterator(): T {.inline.}): tuple[key: int, val: var T] {.inline.} =
@Aszarsha
Aszarsha / splay.c
Last active April 16, 2020 16:05
Splay tree (corr for Algo3 students)
#include "splay.h"
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <limits.h>
//===== Splay Node =====//
typedef struct splay_node_t {
struct splay_node_t * left;
@Aszarsha
Aszarsha / avl.c
Last active April 16, 2020 16:05
AVL tree (corr for Algo3 students)
#include "avl.h"
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
static inline int max( int a, int b ) {
return a < b ? b : a;
}
@Aszarsha
Aszarsha / sorts.c
Last active April 16, 2020 16:05
Basic sorts
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <assert.h>
#include <string.h>
#include <math.h>
typedef void (*sort_func)( double *, size_t );
static double * init_array( size_t size ) {
@Aszarsha
Aszarsha / listShuffle.lua
Created March 5, 2014 18:31
listShuffle.lua
function initListAndMatrix (numElements)
local l, pos = {}, {}
for i = 1, numElements do
l[i] = i
pos[i] = {}
for j = 1, numElements do pos[i][j] = 0 end
end
return l, pos
end
@Aszarsha
Aszarsha / typesafe_varargs.cpp
Last active June 15, 2017 21:00
Some adjustments to typesafe_varargs from deplinenoise (https://gist.github.com/deplinenoise/6297411) for better error messaging and to remove macro.
// Type-safe varargs with C++11 variadic templates.
//
// Andreas Fredriksson <deplinenoise at gmail dott com>
// minor changes from:
// Thomas Hume <thomas dot hume at labri dot fr>
//
// This code is in the public domain.
#include <stdio.h>
#include <stdarg.h>