Skip to content

Instantly share code, notes, and snippets.

View dkohlsdorf's full-sized avatar
🏠
Working from home

Daniel Kohlsdorf dkohlsdorf

🏠
Working from home
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dkohlsdorf
dkohlsdorf / nips.py
Last active October 29, 2020 09:38
Download all nips papers ever
from lxml import html
import requests
import urllib.request
BASE_URL = 'https://papers.nips.cc/'
page = requests.get(BASE_URL)
tree = html.fromstring(page.content)
books = [ href.attrib['href'] for href in tree.xpath('//a') if 'book' in href.attrib['href']]
@dkohlsdorf
dkohlsdorf / Alignment.scala
Last active May 26, 2017 10:10
General Sequence Alignment
class Alignment[A](
init: (Int, Int) => Double,
rank: (Double, Double, Double, A, A) => Double
) {
def score(x: Array[A], y: Array[A]): Double = {
val n = x.size
val m = y.size
val dp = Array.ofDim[Double](n + 1, m + 1)
,~~+++===~:,,,,
,,:=+==~~~=~========::,
,:++?=~::~~~~~~~~~~=~====:,
,::=?+=~~~~~~~~::::::::~~~~~~~~==~:
,,:=?+?=~~~~~:~~~~~~::::::::::::::~====~:,
:++???=~~~::::~:~~~::,,,,,,,,,:::,::::~~=++~,
,~+++===~~:::::::::::,,,,,,,,,,,,,,,,:::~~==?=,
, ,+?+==~~::::::::::,,,,,,,..........,,,,,,~~~==?=,
=~?+???=~::::::,,,,,,,,,,,,..............,,~~=+??+=:
+++=+====~:::::,,,,,,,,,,,,,...............,,,,~++===+:
@dkohlsdorf
dkohlsdorf / SparseVector
Last active March 18, 2019 23:17
Interview Question Sparse Vector
//Given two sparse vectors. Write a function to find a dot product of these vectors.
// [0,4,0,0,1,0,0,10,0]
// [2,0,0,0,3,0,0,0,0]
// 3
x = (4, 1), (1, 4), (10, 7)
y = (2, 0), (3, 4)
@dkohlsdorf
dkohlsdorf / Audio Interest Point
Created April 1, 2015 21:50
Extract Local Interest Points from a spectrogram
package processing.signals;
import java.util.ArrayList;
/**
* Extract all local features from current spectrogram
*
* @author Daniel Kohlsdorf
*/
public class LocalFeatureExtractor {
@dkohlsdorf
dkohlsdorf / Regexp.java
Last active March 18, 2019 23:17
Parse A Regular Expression
package parser;
public class ExpressionNode {
public static final char or = '|';
public static final char and = '.';
public static final char repeat = '*';
public char symbol;
public ExpressionNode left, right;
@dkohlsdorf
dkohlsdorf / BitSet.java
Last active March 13, 2019 20:58
Implements a set on an integer
public class BitSet {
private int set = 0;
public void add(int position) {
int mask = 1 << position;
set = set | mask;
}
@dkohlsdorf
dkohlsdorf / Heap.java
Last active March 13, 2019 20:59
Heap
import java.util.Arrays;
/**
* Implements a size limited heap
*
* @author Daniel Kohlsdorf
*/
public class Heap {
private double heap[];
@dkohlsdorf
dkohlsdorf / Merge.java
Last active March 13, 2019 20:59
Merge As In Mergesort
import java.util.Arrays;
/**
* Merge as in MergeSort
*
* @author Daniel Kohlsdorf
*/
public class Merge {
public static int[] merge(int x[], int y[]) {