I am learning how to make a website on App Engine using Golang. I want a way to do performance profiling. I am trying to use appstats. However there are two issues
Is there a work around to avoid using strict function structure
func(appengine.Context, http.ResponseWriter, *http.Request)
Second, I am using httprouter for mapping multiple pages. How to use appstats with httprouter? Is there better alternative than appstats?
r := httprouter.New()
http.Handle("/", r)
r.GET("/", HomePage)
//Signup routes
r.GET("/form/signup", GoToSignupPage)
Related
I have successfully implemented video sharing in my app using react native and firebase, but I want to ensure videos being stored are no more than 1080x1080 (maybe 720 depending how it looks).
Videos are max 8 seconds long, I am trying my best to keep them under 5MB each if possible. I was able to do some compressing on the client side (crop to square/trim), but I am hoping to be able to compress the videos even more without losing that quality via cloud functions (storage trigger).
After doing some looking around, it looks like Moviepy is a good option, but it use's python and I am not sure how I can use this script inside of a cloud function storage trigger.
Here is what that looks like:
//Not sure how this will import
import moviepy.editor as mp
//Can I get the video here from the bucket path in a cloud function?
clip = mp.VideoFileClip("video-stored.mp4")
clip_resized = clip.resize(height=1080) # make the height 1080px ( According to moviePy documenation The width is then computed so that the width/height ratio is conserved.)
//resize video, then we need to store it in the same location (same file path)
clip_resized.write_videofile("video-stored-resized.mp4")
I would love to hear some suggestions regarding video compressing via a cloud function and thoughts on using the above script/module with cloud functions.
At this point, firebase functions does not support languages other than node.js.
Thus, there are 2 solutions.
if you would like to keep using moviepy.
Writing a part to call moviepy-related apis when firebase storage is triggered in node.js and having the python api in any preferred environments. (I guess you should use pubsub provided by gcp to call the python apis)
writing all parts in node.js
There is a great module called fluent-ffmepg in node.js too but I know adding a watermark with the module is not as easy as moviepy is...
By the way, when I tried to combine vids in firebase functions, I was not able to make it maybe because of the limitation of the environment.
So, I personally recommend the very first solution: ofc it depends on your situation such as how big your video files are.
I just started learning some Clojure and i have some general questions about it, since i can't find anything about it in google.
I will create a website with clojure. How can i call a function on the website via an a-Tag or a button? Is this even possible? If not, how can i react to user interactions?
is it possible to pass data through clj files? I have experiance with Angular JS. There, if I want to share data, I just store it in a global factory and later I can just access it. Is this also possible in clojure? I don't want to use angular or JS in this application.
how can i get data from an url: /myroute/myId (car/5). I want to get the ID 5.
I hope you can understand my questions. Thanks in advance
You can use Clojure to make a robust back end server. You can use a library such as compojure for routing. This enables you to transfer data via request and response maps. For the front end you can use Clojurescript (which unlike Clojure, runs on javascript). Clojurescript is not easy to set up until you are very comfortable with how projects are set up in Clojure.
The libraries and plugins that I definitely recommend are:
For Clojure (back end):
Ring
Compojure
clj-http or http-kit
For ClojureScript
figwheel
I suggest you start off with learning the back-end (pure Clojure) and then move on to the front-end (ClojureScript). You could make a simple REST api using Compojure and use static HTML files to talk to them (or use Swagger).
There are other and better (IMO) libraries for building web backends in Clojure out there, but Compojure is a good one if you're not very experienced yet.
Don't jump to ClojureScript before you're comfortable enough with Clojure! Otherwise you'll get lost :-).
I have been thinking implementing translation for my app and I have the following idea
Make the English and My language [Amharic] mirror jsons and render English if selected. Just configuration Json file from the server that gets called once app routed
Make all in one API to get the json once and persist
will it be a good idea,How is this implemented on real world
Don't need to implement it yourself. angular-translate is an excellent module, here you can take a look at it: https://angular-translate.github.io/ .It covers everything you need.
It is plenty of features and some of them are:
Flexibility
Pluralization
Directive
Filter
Service
Asynchronous loading
Keep in mind that this module has been there for a long time and many people use it. You can solve everything you need and there is no need to reinvent the wheel.
Searching for ways to build REST APIs, I found skue (https://code.google.com/p/skue/). However there is not much information on the site. My plan is to build a rest api as follows strictly:
Models << Business logics << Restful Resources.
What this means is: the models are access exclusively by the business logic; the restful resources interface is the only layer a client has direct access to. I am specifying all this to avoid people suggesting using the appengine-rest-server.
My question is: has anyone ever successfully used Skue? If so do you have any examples you would not mind sharing? GET and POST would be sufficient, but more is welcomed. If not Skue, are there any frameworks out there that allow building such rest-apis on top of the google-app-engine?
Why not just use json.loads() and get dictionary? In python (unlike in Java) dictionary is a first-class citizen.
As a seasoned Java programmer I was tempted, when moved to Python, to load all data into objects which I defined elsewhere, but I found that it's perfectly OK in python to get a dictionary and use it instead. It's so much easier to pass dictionaries and use them in many places (for example as keyword parameters in methods). Simply use more tests ...
In python you are moving the static compile check towards the dynamic unit-test check, and that's perfectly ok in pythonic way.
I'd like to use line_profiler to profile a single large method line by line in my GoogleAppEngine application.
Unfortunately GAE doesn't seem to let you import .so libraries, even on a local dev server.
How could I go about achieving my goal?
I'd be happy to use a python-only solution, if there's one out there, or take suggestions as to how to write my own.
Use gae_mini_profiler.
It can either keep track of all function calls and their timings (instrumented) or can periodically examine the call stack to figure out in which functions time is being spent during a request (sampling). You can see an example of it in action here - http://mini-profiler.appspot.com/