how to debug google cloud function easily? - google-cloud-functions

How do I debug GCF without deployment?
Is there a way to debug functions faster while having access to GC storage? Much appreciate!
Currently, Im working on trying to use GCF to access GC storage to retrieve ML model and process images. The function will retrieve the image from the same bucket, run the image through the Ml and paste ML model results to a text file with time and image name.
As a beginner coder on GCF, im constantly having to debug and therefore looking for a faster way to debug without waiting for deployment.

A function is simply a piece of code! Run it to test it.
If you want to do that easily and in a similar way as Cloud Functions run it, you can use the Function Framework, compliant in many languages.
Personally I prefer to wrap my code in a custom webserver, as I described in one of my first article here. And rapidly, I choose to abandon Cloud Functions to Cloud Run, again in a pretty recent article
You could have issues with authentication and stuff like that, let me know if it the case (and do not generate a service account key file ;) )

Related

Design Automation cache life cycle

Our customers would like to know what happens to their data, that is being processed by the Design Automation plug-in. As I understand, the input files are downloaded from the bucket and stored on the Design Automation VM instance while the plug-in runs. But what happens with input and output files when the job is finished? When and how are these resources erased? What happens to the VM itself? Also, could other service/program/user gain access to these files?
Secondly, is there a way to perform RVT->SVF conversion without using cloud services? Does Autodesk provide any desktop tool or API to do it locally?
Thanks in advance.
To the 1st question, in general, the Design Automation Cloud Sandbox will be destroyed as soon as the workitem is done, all the input and output files will be destroyed, that means there should be no other service/app could access these files after the DA workitem is done.
To the 2nd question, No, Rvt-Svf should be done by Model Derivative service, there is no local tool or API to do that from Autodesk at this moment.

IBM Maximo - Querying API for data with very slow response time

I have been looking everywhere for a solution to this problem.
At my work, we are trying to integrate Maximo with another system via the other systems REST API (which returns JSON responses). I am able to make this integration work on a small scale, however this API is taking upwards of 5 seconds to respond per request. Currently, I have defined this system as a JSON Resource, and I copy daily "snapshots" of the non-persistent data to a persistent attribute using an automation script. The requests all run in a sequence - which works slowly for 5 assets in testing, and will definitely not scale to 1000's of calls a day.
Assume that the API of the external system cannot be modified in any way... Is there a way to query this API in a non-blocking way? I'd imagine that if I could send a request, and send the next, etc. without needing to wait for a reply to proceed, this would solve the problem.
I looked into Invocation and Publishing Channels, and also Enterprise Services, and it seems like Enterprise Services along with JMS Queues might be what I need, however documentation says that these only support queuing incoming data... and I can't see how this solves my problem.
Any help? I am completely stuck on this.
Thank you!
I had to do something that sounds similar, once. I tried JSON Resources, but they didn't work for me. I ended up using the examples in Maximo 7.6 Scripting Features to do it. The first code sample in that document is a library script for making HTTP/S calls using out-of-the-Maximo-box libraries, and other examples in that document use IBM's JSONObject and JSONArray classes (also available out of the Maximo box) to parse responses.
To get things going concurrently / multithreaded, you could configure a cron task to call your automation script, and configure multiple instances on various schedules to call the same one and use the args or some other mechanism to prevent collisions.

Game Maker Studio HTML5 localStorage issue

I'm embedding GMStudio game in browser using . I need to send some data to the game from site's frontend in JSON and to receive some data from the game in frontend to make consequent actions.
So, my idea before was to save data in cookies/localStorage and to get it in the game somehow, using HTTP functionality or DLL's. Also, I'd like to emit messages from the game using window.parent.postMessage and receive them in frontend correctly.
Alas, I did not find a way to implement this. I hope there's some consistent approach to this problem about which I do not know.
The backup plan is to use Game Maker http_post_string and web sockets to get user's data before game's start and to make frontend do something after game's ending. It's clumsy and insecure, however.
The standard approach is to make a JavaScript extension.
That is done by creating a blank extension, adding a blank JS file to it, defining the functions via the context menu on it, and then adding the implementations into the JS file. Then you'll be able to call them from GML side as per usual.
This way you can access LocalStorage\Cookies, transmit\receive data from JS backends, and overall mess with the runtime as you please (with various degrees of understanding required to access internal data).

Connect Sproutcore App to MySQL Database

I'm trying to build my first Sproutcore App and I struggle to connect it to a MySQL-Database or any datasource other than fixture. I can't seem to find ANY tutorial except this one from 2009 which is marked as deprecated: http://wiki.sproutcore.com/w/page/12413058/Todos%2007-Hooking%20Up%20to%20the%20Backend .
Do people usually not connect SC-Apps to a Database? If they do so, how do they find out how to? Or does the above mentioned tutorial still work? A lot of gem-commands in the introduction seems to already differ from the official Sproutcore getting-started-guide.
SproutCore apps, as client-side "in-browser" apps, cannot connect directly to a MySQL or any other non-browser database. The application itself runs only within the user's browser (it's just HTML, CSS & JavaScript once built and deployed) and typically accesses any external data via XHR requests to an API or APIs. Therefore, you will need to create a service wrapper around your MySQL database in order for your client-side app to be able to load and update data.
There are two things worth mentioning. The first is that since the SproutCore app contains all of your user interface and a great deal of business logic, your API can be quite simple and should only return raw data (such as JSON). The second is that, I should mention that the client-server design, while more tedious to implement, is absolutely necessary in practice, because you can never trust the client side code, which is in the hands of a possibly nefarious user. Therefore, your API should also act as the final gatekeeper to validate all requests from the client.
This tutorial I found helped me a lot. Its very brief and demonstrates how to implement a very simple login-app, how to send post-requests (triggered by the login-button-action) to the backend-server and how to asynchronously process the response inside the Sproutcore-App:
http://hawkins.io/2011/04/sproutcore_login_tutorial/

How can I use Flash to remember user data?

I am making a Flash game that stores user's statistics from previous sessions. I would also like to maintain some sort of leader board as well.
After I posted, I realized I was asking the wrong question. I feel that shared objects are the proper solution to this problem rather than using a database. Any further feedback for implementing shared objects is welcome.
Thanks for any feedback.
You can not directly query MySQL database table from Flash game, you must have some server-side technology backing you up for the job.
I would suggest using some PHP or Ruby - or whatever is easily available to you for the job.
Flash is going to be rendered on Client browser (as swf) and won't be in touch with server as it will be served as a static resource by the web browser.
I hope this reply will help you moving towards right direction.
As Dharmavir mentioned, you cannot process MySQL queries through Flash (AS*).
That said, its pretty easy to setup Flash to communicate with remote scripts, as it has the ability to POST/GET data through requests.
There are many tutorials on this.
First, write a simple script to input the data into the DB. I recommend using PHP (I think its the easiest to learn tbh).
If this is your first time performing queries with PHP, I also recommend using Prepared Statements instead of mysql_*.
Once you have your script setup, you can then move onto processing a request from your flash app to your script (which is also pretty easy).
I found a tutorial series on making a chat app with flash and PHP. The tutorial includes making requests to PHP scripts and inputting data to SQL DBs, so it should help you:
http://www.youtube.com/watch?v=XeWKauwFUEQ < This tutorial is split into many different videos. take a look at the suggestions to find the others.