How to include reactivex dependency in Cloud Code - parse-platform

I would like to use a 3rd party library in my cloude code. It is located here https://github.com/Reactive-Extensions/RxJS
I have downloaded the .js file and put it in my cloud/ directory and tried to import it using
var rxModule = require('cloud/rx.js');
I have had success with other libraries but for this one it just throws
Uncaught Error: This operation is not supported
when i call parse deploy
Is there another way I can include a 3rd party lib?

RX can be installed using NPM:
$ npm install rx
It can then be used as follows:
var rxModule = require('rx');
There are great instructions and samples at https://www.npmjs.com/package/rx

#Darussian, I do not know if this is still relevant but I wanted to the same thing.
From what I understand, Rx won't work in Parse Cloud Code because setTimeout() and setInterval() are not defined, and they are needed for Rx.Schedulers to work.
So, what I ended up doing was trying with other similar libraries. The one I got to work was Kefir.JS. It works similar to Rx and has some of the same methods. You may be disconcerted at first but should be able to transfer any Rx code you wanted to build to Kefir.
One thing that helped me a lot was using scan() combined with last() to emulate Rx reduce() method (which is not on Kefir by default).

Related

Passing code from CodePipeline to PythonFunction

I'm trying to create a CDK app that will deploy a pipeline-stack and a lambda-stack. Similar to the tutorial here. I'm trying to implement a basic CI/CD application that is triggered with every push to a Github Enterprise Repo.
I chose to use PythonFunction from (#aws-cdk/aws-lambda-python) instead of function from #aws-cdk/aws-lambda because PythonFunction builds the dependencies from requirements.txt. I have various lambdas that use different packages (like awswrangler, pandas, requests, etc.).
But, PythonFunction does not support CfnParametersCode (Where the code is passed through CDK instead of being read from an asset).
What other option do I have to pass my code from GithubEnterprise to
the PythonFunction?
If function from #aws-cdk/aws-lambda is the only option I have, how
can I include the packages from requirements.txt
This does seem like an option for #aws-cdl/aws-lambda, but how would I pass my code from Github? This example relates to building from asset code.
I apologize if I'm missing something obvious, I just started working with AWS CDK last week.
First of all I would recommend to take a look at pipelines.CdkPipeline which is able to deal with Assets. That means you can directly use lambda.Code.from_asset instead of overriding CfnParametersCode in the Pipeline.
Regarding your other question, you can deal with the requirements by installing them into your lambda folder during the build step with: pip install -r requirements.txt -t .
CfnParametersCode gives you the ability to upload your code from an S3 file.
You can do the same via lambda.Code.fromBucket.
Taking your link from the third point (https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/aws-lambda#bundling-asset-code) You just need to use lambda.Code.fromBucket instead of code: lambda.Code.fromAsset. Docs can be found here: https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/aws-lambda

UglifyJS2 call minify function programmatically

I would like to know if I can call the minify main function programmatically.
I am able to run the same code as defined in compress, however replacing UglifyJS.Compressor with UglifyJS.minify does not work.
This is because I would like to pass the same options defined in the README of UglifyJS2, instead of the ones in compress.
Please note that I am running the code in Nashorn, and not in Node.js so that would be similar to a browser environment.
This is a work in progress: see this issue and this PR.

Streaming json in nativescript

has anyone used the streaming json in nativescript? I found this http://oboejs.com/why but it seems not to work. I'm using nativescript 1.6, any suggestion would be appreciated really much. Thank you.
There is no library to my knowledge currently built for NativeScript that allows streaming JSON. Just for clarification sake you can easily pull JSON from a server and parse it using the built in fetch/http api's, right now -- but their is no way to have it start parsing the json as it downloads in chunks built in.
You can attempt to modify the npm node module to build for NativeScript.
Or thinking outside the box a bit; you can also use the web based version of that module inside the nativescript-webworkers and have it pull and process your JSON and communicate the json messages back to the NS environment. The WebWorkers module actually wraps the native platform's web browser module so it can run all browser based JS code.
Disclaimer: I'm the author of the open source NativeScript-WebWorkers.

Parse Image + Parse httpRequest replacements — migrating from Parse Cloud Code to Parse Server on Node (Heroku / AWS / DO)

I found that when using the parse-node package, you can no longer use Parse.Cloud.httpRequest. I also know that Parse's Image object won't be available.
So far, I've been able to replace some Parse promises with native ones and use axios to make network requests.
However, I'm relatively new to Node, so I'm curious as to what are the most direct replacements for these, and how do I use them?
You should still be able to use Parse.Cloud.httpRequest. But axios is a great library and it's a great idea to start using it if you want to learn nodejs. When it comes to the parse-image it has to be replaced. There is a library which claims 100% compatibilty, check it out here.

Making HTTP Requests in Qt

I'm new to Qt. I installed Qt for VS2008 and integrated with my VS2010. I just want to know how to make HTTP requests. I've read about QtNetwork but QtHttp is obselete.
I also know about libcurl and curlpp, but I have problems installing it, and making it work with Qt.
What do you recommend, QtNetwork or curlpp? If QtNetwork, can you please give me a sample function or piece of code (and what class to use). If curlpp(libcurl), can you please point me to somewhere where I can find the steps to install it for Qt (or kindly explain)?
Thank you very much.
libcurl and curlpp are great libraries, but using them adds a dependency to your project that probably you can avoid.
Recent versions of Qt recommend to use QNetworkAccessManager to make network requests (included http requests) and receive replies.
The simplest possible way to download a file is:
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
manager->get(QNetworkRequest(QUrl("http://stackoverflow.com")));
When the replyFinished slot is called, the QNetworkReply object that it takes as parameter will contain the downloaded data as well as meta-data (headers, etc.).
A more complete example can be found in the Qt examples, you can read here its source code.
Giuseppe is right, you don't need to use libcurl, curlpp and similar libraries.
There is no need for that, Qt has a simple and working class on it own.
Keep in mind that the standard way of sending request and retrieving reply is asynchronous.
You always have to connect the manager finished(QNetworkReply*) signal to a slot.
If you send multiple requests and don't want to add a slot for each reply, you can always run an event loop, and connect the managers signal to event loops quit() slot.
Something like this:
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
QEventLoop *eventLoop = new QEventLoop();
QObject::connect(manager, SIGNAL(finished(QNetworkReply*)), eventLoop, SLOT(quit());
manager->get(QNetworkRequest(QUrl("http://stackoverflow.com")));
eventLoop->exec(QEventLoop::ExcludeUserInputEvents);
QByteArray replyData = reply->readAll();
... //do what you want with the data your receive from reply
Btw. don't know what are you doing. But if its a mobile app, I would recommend you switch from VS to QtCreator IDE. It has a nice simulator and a complete toolchain for mobile device testing.

Resources