This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct _FloatMatrix { | |
uint32_t N; | |
uint32_t M; | |
float *data; | |
} FloatMatrix; | |
/* read matrix from tsv file */ | |
/* matrix is allocated, will need to be freed */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def nesterov_optimizer(g, w0, alpha, mu): | |
dim = w0.shape[0] | |
w = w0 | |
v = np.zeros(dim) | |
while True: | |
yield w | |
v = mu * v - alpha * g(w + mu * v) | |
w = w + v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# groups of `size` from an iterable `seq` | |
def group(seq, size): | |
it = iter(seq) | |
while True: | |
values = [] | |
try: | |
for n in xrange(size): | |
values.append(it.next()) | |
yield values | |
except: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sklearn.cross_validation import train_test_split | |
from sklearn.linear_model import SGDClassifier | |
from sklearn.metrics import precision_recall_curve | |
dfp = PATH_TO_FILE_HERE # format is csv with itemid,label,features | |
def readff(fpath): | |
trids, labs, feats = [], [], [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; route destructuring | |
(POST "/login" {post-params :params session :session} (page-login-post post-params session)) | |
;; session update | |
(assoc (response (html "whatever...") :session (assoc session :userid uid))) | |
;; show request map: | |
(GET "/profile" reqmap (str reqmap)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; zip sequences: | |
(map vector v1 v2 v3 ...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -name "*.dat" -exec cat {} \; > filename |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; ;; config using mac-port of emacs, | |
;; ;; see https://github.com/railwaycat/emacs-mac-port | |
;; ;; mac switch meta key | |
(setq mac-option-modifier 'meta) | |
(setq mac-command-modifier 'hyper) | |
(setq package-archives '(;;("gnu" . "http://elpa.gnu.org/packages/") | |
;;("marmalade" . "http://marmalade-repo.org/packages/") | |
("melpa" . "http://melpa.milkbox.net/packages/"))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Python.h> | |
static PyObject* say_hello(PyObject* self, PyObject* args) | |
{ | |
const char* name; | |
if (!PyArg_ParseTuple(args, "s", &name)) | |
return NULL; | |
printf("Hello %s!\n", name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.nicolamontecchio.chroma; | |
import java.io.*; | |
import javax.sound.sampled.*; | |
/** | |
* Read an audio file. Provided that the appropriate packages are in the classpath, mp3 and ogg should be readable too. The safest route is to read from a MONO, WAV file. | |
*/ | |
public class AudioReader { |
NewerOlder