Skip to content

Instantly share code, notes, and snippets.

Avatar

Quentin Roy QuentinRoy

View GitHub Profile
@QuentinRoy
QuentinRoy / rxjs-from-stream.js
Created Oct 20, 2017
Transform a node stream into an rxjs Observer
View rxjs-from-stream.js
import { Observable } from 'rxjs';
// Adapted from https://github.com/Reactive-Extensions/rx-node/blob/87589c07be626c32c842bdafa782fca5924e749c/index.js#L52
export default function fromStream(stream, finishEventName = 'end', dataEventName = 'data') {
stream.pause();
return new Observable((observer) => {
function dataHandler(data) {
observer.next(data);
}
@QuentinRoy
QuentinRoy / flat-summarize.R
Last active Sep 16, 2017
A rewrite of ddply's summarize that 'flattens' named columns
View flat-summarize.R
# Fork of ddply's summarize that 'flattens' named columns
flat.summarize <- function (data, ...) {
stopifnot(is.data.frame(data) || is.list(data) || is.environment(data))
cols <- as.list(substitute(list(...))[-1])
if (is.null(names(cols))) {
missing_names <- rep(TRUE, length(cols))
}
else {
missing_names <- names(cols) == ""
}
You can’t perform that action at this time.