Skip to content

Instantly share code, notes, and snippets.

View feliperohdee's full-sized avatar
🚀
Going High

Felipe Rohde feliperohdee

🚀
Going High
View GitHub Profile
@feliperohdee
feliperohdee / ObservableCache.ts
Created March 15, 2016 16:43
Observable cache
let cache = (source: Observable<any>) => {
let replay: ReplaySubject<any>;
return source
.multicast(() => {
if (!replay) {
replay = new ReplaySubject(2);
setTimeout(() => replay = null, 2500);
}
import * as _ from 'lodash';
var root = window;
export class MockWebSocket {
static sockets: Array<MockWebSocket> = [];
static get lastSocket(): MockWebSocket {
return _.last(MockWebSocket.sockets);
}
import * as _ from 'lodash';
let root: any = window;
enum xhrStates {
UNSENT,
OPENED,
HEADERS_RECEIVED,
LOADING,
DONE
import * as _ from 'lodash';
import * as ws from 'ws';
import {Observable, Subject} from 'rxjs';
import {Request} from 'restify';
import {Socket as NetSocket} from 'net';
import {Errors, Redis} from './index';
export class Socket {
public channels: Map<string, Set<ws>> = new Map<string, Set<ws>>();
public wss: ws.Server;
import {Observable, Subscriber} from 'rxjs';
class RX {
fromArray(array: Array<T>): Observable<Array<T>> {
return Observable.create((subscriber: Subscriber<Array<T>>) => {
try{
array.forEach((value: T, index: number) => subscriber.next(value));
}catch(e){
subscriber.error(e);
}
AWS.config.credentials = {
accessKeyId: '{accessKeyId}',
secretAccessKey: '{secretAccessKey}'
};
let bucket: any = new AWS.S3({
params: {
Bucket: 'smallorange-local'
}
});
import * as _ from 'lodash';
import {TestScheduler, Observable, Notification} from 'rxjs/Rx.KitchenSink';
import {HotObservable} from 'rxjs/src/testing/HotObservable';
import {ColdObservable} from 'rxjs/src/testing/ColdObservable';
import {SubscriptionLog} from 'rxjs/src/testing/SubscriptionLog';
export type observableToBeFn = (marbles: string, values?: any, errorValue?: any) => void;
export type subscriptionLogsToBeFn = (marbles: string | string[]) => void;
export class ObservableTestsHelper {
@feliperohdee
feliperohdee / smallorange-reactive-store-typedAttributes-sample.js
Last active March 31, 2017 20:28
Usage of smallorange-reactive-store with new typedAttributes
'use strict';
const {
Model,
Collection,
rxjs,
lodash
} = one;
class MessageMeta extends Model {

Hey man!

I just have created a small POC (proof of concept) of a simple API to create scheduled triggers and receive postbacks with their relative payloads. I'll explain how it works and afterwards, I want to heard your opinion, ok?

The API is pretty simple and straighforward,

	//resources
	POST https://apis.smallorange.co/cron/triggers
	PUT https://apis.smallorange.co/cron/triggers/:id
@feliperohdee
feliperohdee / u1.RANDOM-INCREMENTAL:THRESHOLD=2
Last active June 16, 2017 16:22
movielens recSys THRESHOLD=2
{"user":1,"assertiveSize":8,"assertiveRatio":"10.13%","recsSize":138,"testSize":79}
{"user":2,"assertiveSize":1,"assertiveRatio":"8.33%","recsSize":149,"testSize":12}
{"user":3,"assertiveSize":0,"assertiveRatio":"0.00%","recsSize":150,"testSize":5}
{"user":4,"assertiveSize":0,"assertiveRatio":"0.00%","recsSize":151,"testSize":8}
{"user":5,"assertiveSize":2,"assertiveRatio":"8.00%","recsSize":145,"testSize":25}
{"user":6,"assertiveSize":7,"assertiveRatio":"10.94%","recsSize":143,"testSize":64}
{"user":7,"assertiveSize":13,"assertiveRatio":"9.63%","recsSize":127,"testSize":135}
{"user":8,"assertiveSize":2,"assertiveRatio":"9.09%","recsSize":148,"testSize":22}
{"user":9,"assertiveSize":1,"assertiveRatio":"11.11%","recsSize":150,"testSize":9}
{"user":10,"assertiveSize":8,"assertiveRatio":"9.76%","recsSize":144,"testSize":82}