Skip to content

Instantly share code, notes, and snippets.

View smart--petea's full-sized avatar

Badarau Petru smart--petea

View GitHub Profile
//from stackoverflow
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
int get_pos(int *y, int *x);
int main() {
int x = 0, y = 0;
get_pos(&y, &x);
@smart--petea
smart--petea / .ts
Created April 13, 2017 13:55
Optimized sequential if/else pattern for Rx observables. (see generateObservableOptimized)
/// <reference path="typings/globals/es6-shim/index.d.ts" />`
import * as Rx from 'rxjs';
function generateObservable(...args) {
return Rx.Observable.of({
count: arguments.length > 1 ? 0 : 1
});
}
@smart--petea
smart--petea / TimerBufferOperator.ts
Last active February 10, 2017 08:04
Buffer operator based on counting time and items
/// <reference path="typings/globals/es6-shim/index.d.ts" />`
import { Observable } from "rxjs/Observable";
import { Observer } from "rxjs/Observer";
import { Subscriber } from "rxjs/Subscriber";
function timerBufferOperator<T>(this: Observable<T>, bufferSize: number, timeFrame: number): Observable<T> {
return Observable.create((subscriber: Subscriber<Array<T>>) => {
this.subscribe(new TimerBufferOperator(subscriber, bufferSize, timeFrame));
});
}
{
"targets": [
{
"target_name": "Jzon",
"type": "static_library",
"sources": [ "Jzon.cpp"]
}
]
}