UpUp to force the offline.html even when online - service-worker

So I am trying to use the UpUp library to build a offline first webpage.
The library shows the offline page when I am offline. How do i force UpUp to show the offline page irrespective of being online or offline.
What I am trying to do is build something like, the app shell will always be loaded from the service worker cache and the network calls be made from there. That would make my app load much faster as the initial page load won't be from the web.

I'm not the author of UpUp, but my understanding is that the library isn't intended to facilitate using the Application Shell model. Perhaps at some point it will evolve to fill that role, and you could always ask on the project's Issue Tracker.
In the meantime, there are a few resources out there describing how you can build applications following that model, either using the sw-precache/sw-toolbox library combination, or writing your own service worker code:
https://developers.google.com/web/updates/2015/11/app-shell
https://speakerdeck.com/jeffposnick/instant-loading-with-service-workers-chrome-dev-summit-15
http://www.pocketjavascript.com/blog/2015/11/23/introducing-pokedex-org

Related

Accessing a user's webcam in Heroku

I am interested in gathering eye tracking data and would like to create a Heroku app that uses this GazeTracking package (or similar) so I can capture and capture and store data for where people are looking on their screen for given images. After going through dozens of related answers on Stack Overflow and elsewhere, I am still unable to get this working correctly since I can't figure out how to access the user's web camera. Here is the GitHub repo I've got going right now. Is there a way to access the user's webcam for this project? Thanks.
Edit: I am using the buildpack https://github.com/heroku/heroku-buildpack-apt.git
Heroku apps run server-side. they're web apps. users interact with them through browsers.
if you wanted to access a user's webcam, that would have to happen through the browser. that requires WebRTC or similar APIs. that means serving a web page that contains client-side javascript (or other) code which accesses the user's webcam through the browser, and then sends a video feed (or single pictures) of that back to the server.
you can only directly access server resources inside the web app, not client-side resources.
if you wanted to do eye tracking browser-side, there's OpenCV.js which runs completely in the browser. I don't know if the required procedures for eye tracking have been ported to OpenCV.js but it's worth a look. you could do the analysis client-side and just send back heatmaps or lists of coordinates.

PWA: what happens if my web app has a service worker without a manifest file?

In progressive web application (PWA), it is said to make a web app fully PWA-compliant, I need to have a manifest file.
(1) But what happens if my web app registers a service worker but I didn't define a manifest file? Any typical examples?
(2) Is it correct that service worker is a technique used in PWA, but is not necessarily exclusive to PWAs (i.e. non-PWA web apps could have service workers as well)?
PWAs are Progressive Web Apps which means you progressively enhance your site with the features you need.
If you want your site to be installable you'll need a web manifest.
If you want your site to cache resources on the device or work offline you'll need a service worker.
Those pieces work independently but complementary and you can pick and choose them at your whim.
Answering to the first part:
It won't prompt user for add to home screen as this is one of the
requirements for PWA, but PWA isn't limited to it. So if you have
Service worker registered, you will get all the other functionalities of PWA other than Add to home Screen.
In precise, loading a
manifest files tell browser that our website is an application
Answer to your other questions. Can't see any other use of the
Service Worker other than PWA, as Service Worker is a proxy, sits between the user and N/W request and decides very cleverly if the internet is available or not or whether the SW should intercept the
n/w request or not. So, soon you register SW it automatically counts towards PWA.
Major components of PWA are:
Adding a Web App Manifest
Adding a Service Worker (SW)
Caching and serving Static assets
Serving Cached Contents
Dynamic Caching
Out of these 5 steps, you can achieve 2,3,4,5 with the help of SW. Adding a web app manifest is more like an intimation and giving your website a more native look/feel regardless of desktop or mobile device. cheers :)

Good way to get streaming Twitter data using Apache Storm?

I'm building a Twitter crawler system. Requirement is to crawl both Twitter Profile and Twitter Streaming. There's a project manager which puts all projects (1 project is a Twitter profile, or a keyword for Twitter Streaming) into Kafka. Then Storm will read from Kafka to get project metadata and start to run. The project manager will check all projects periodically and eventually restart the project (by putting data into Kafka), so every project has the latest data. I have a couple of questions:
Since we need to keep a connection to Twitter Streaming, we cannot let a Bolt run for a very long time for the Twitter streaming project. Can you suggest a good way to do this, like implement a separate process for crawling?
Another question is about tokens. We want each access token to run on one server only in order to improve stability and prevent reaching the rate limit too soon. When a project (tuple) starts to be processed in Storm, it would be assigned an access token of its supervisor IP. Is there any good solution for this? Someone recommends me to use Zookeeper to assign access token but I'm not sure if it's a good way and how to implement?

Which is better to make a web application offline -application cache or service worker?

I want to make my web application available even if network is not preset or when user is offline.
I searched about this and find two solution:
1) use Application cache
2) use Service worker
As service worker is in developing state and not supported by all browser so can not find this is a feasible according to my requirements.
On the other hand, application cache is about to deprecated(MDN site) from most of browser(still supporting in many browsers), I can not go with this solution too.
Please give some suggestion or correct me if I am wrong on above points.
Thanks in advance.
Your arguring is correct. Currently service workers are not supported by all browser and I doesn't look like Safari will support it in the near future, but at least it appears on their five year plan.
You can still use application cache, even if it doesn't have all the features sw brings and even if it will be deprecated. It is possible to have a sw / application cache mix on your site.
You have to compare the benefits against the work/money you want to put in your site to make it work offline. If you have an existing site you can check your browser stats and then make a decision.

Is iOS capable of accessing and manipulating files on a Windows network file share?

I'm planning an app for work and venturing into potential features which I've not used before.
Essentially I need to be able to access files on a network share, read, write and delete files as well as amend the file names. As a pretty closed platform I'm not sure whether iOS is capable of such a thing and if it is, what features should I look for to begin researching?
My Google-Fu hasn't come up with anything thus far so hopefully looking for someone to point me in the right direction.
Thanks.
I know this isn't very secure, but I'd personally create an ASP.NET app on your target Windows Server, or a different Server on the domain. Create web services exposed, and make an iOS app with UIWebView. You can do RPC calls from the web service that do WMI/ADSI/File System manipulation. You can prompt for domain credentials, and do remote calls essentially is the gist.
You could expose the web app so that your app can access it from local network, or URL. If you were to access it from outside I'd suggest using some secure credentials in Windows/IIS.
Some years ago I created a "mobile-friendly" web app that allowed me to manage servers, perform RPC, and do basic Active Directory queries. Also allowed file listing and deletion/moving/copying with some creative scripting. It was essentially a ASP.NET/C# web app that loaded in a iPhone app. UIWebView in iOS was a able to load it, used AJAX and some other client side scripting that looked decent. You'd essentially have to make sure that your web app renders properly in Safari/UIWebView (which is bastardized safari).
Here's a link to a demo of what I created:
https://www.youtube.com/watch?v=czXmubijHwQ&t=12s
I ran it in a browser, but it'd run from my PSP, Android test devices, iPod Touch, Blackberry, etc.

Resources