How to do tmux live streaming to a webapp? - ruby-on-rails

Is there a way to live stream a tmux session to web application?
Is there a proper preferred way of doing something like this to be shared with other developers online who don't have access to a console.

This is probably a little overkill, but seems like it would solve your problem:
http://liftoffsoftware.com/Products/GateOne

Related

Does the secure browser in "Good for Enterprise" support SQLite?

The "Good For Enterprise" solution from good.com is a very very difficult thing to google for!
It comes with a secure browser that... well, if you don't know by all means read all about it, but you probably can't answer my question :-)
Which is: does the secure browser (on the iPad specifically) support the SQLite database (or similar), and if so does that data get persisted when the Good "session" ends? From what I can tell, the browser clears its cache when the session is ended - but I'm not sure if that would include stuff like this.
I'm trying to figure out whether I can create an offline-capable web application that will be a front-end to a CRM system. The web app would have to cache CRM data locally, and that would need to persist between sessions. The browser does not currently fully support HTML5 - and so I'm not even sure that SQLite or similar will be available, but it does have some support for HTML5 features. I'm just not sure of the extent of that support...
Here is the document which lists out the secure browser's HTML5 compatibility.
http://media.www1.good.com/documents/SecureBrowser.pdf
As for your question, I don't think you can do this right now because all cached data will be removed once the Good session ends.
See Good Mobile Access (Secure Browser): Support for HTML5 and CSS3 for a much more thorough list of supported features.
Acccording to this document, SQLite databases are not supported by the Secure Browser.

What WebSockets system should I use for this?

I'm building a Rails app where I need a real time commenting system. I'm going to use WebSockets, but I'm new to them and I'm kinda lost. I tried em-websockets and websocket-rails, but neither worked well with what I have to do. I also though of a Node.JS and Socket.io app, but I don't know how to start with that.
What I want to do is send a WebSocket message when a new comment is made on a post, on the create action of my CommentsController. I'll send a message containing the comment content and creator and the post ID.
Thanks in advance! :D
Sorry, but I dont think so. Be careful with WebSockets. It is fundamental concept that provides a very powerful mechanism.
Websockets is good for super, absolutely real-time applications like online games. For commenting system (even realtime) you dont need them, the AJAX is more then enought for this.
You could use a realtime hosted service if you don't want to deal with your own realtime infrastructure, fallbacks for older browsers, scaling complications etc.
I recently wrote a post on Smashing Mag on building a realtime commenting system. It uses PHP and Pusher (who I work for) but the separation between client and server should meant that you could use any backend technology/service. It also demonstrates how to progressively enhance your app.
The most commonly used self-hosted ruby technologies for realtime communication does seem to be Faye, as #Alfred suggested.
Just using websockets as the only available transport is not a good idea, because websockets are not yet supported in every browser. Luckily for example Faye does support multiple transports so that it will work in every browser. I also found this interesting video in the past explaining how you could use Faye in conjunction with RoR from RailsCast.

What are some best-practices for web-based iOS applications?

I have recently started playing around with iOS development and have got most of the basics down. I would however like to know about some best practices and what you guys think is the best in coding practice and application architecture.
What I have in mind is a simple application that gets information from a web server, displays the data to the user, and allows the user to edit the data which must then be updated on the web server.
What I would like to know is:
1) What type of web server / architecture is best suited for something like this? For example, data passing / updating similar to something like the facebook or twitter etc. applications where data is retrieved, potentially updated, and sent back for updating.
2) What type of authentication / security can be built into an application like this? I was thinking something in the line of username / password being stored on the server. Obviously the data should be secure when being transfered.
3) Are there any "free" web servers out there to play around with. I'm not building anything enterprise size, just need somewhere to play. Would the Google App Engine be suitable for something like this? What I have thought up to now is that you would probably need to implement a web service or something. Is this correct? Or are there better ways?
4) Are there any good tutorials around? I have started looking at the ones in the apple.com developer center, but I would like to get other people's point of views too.
I realise these are not really programming questions, but I would appreciate any insight that some more experienced iOS developers have. I would like to get the best practices down by incorporating the above into an app.
Thanks!
This doesn't sound like you need an iOS app, more like just a browser based app that works on the iPhone. If you need features like the GPS, Camera, Gyroscope, taking offline things that are native to the phone, then yes build it on iOS.
But if it's a simple web application that performs the operations you mentioned, then you can look at building a mobile web application. The nice thing is that it will work across iPhone, Droid, WiMo 7, really anything that can host a browser.
1) You can pick almost anything you're comfortable with. I program in both ASP.NET and Python for web apps. Personally, I'm building a web app on Django with Python. It's cheap (free) and there are lots of resources for learning as well as an active community.
2) Security is a rather large topic, there are many things beyond authentication and authorization, like cross-site scripting, sql injection, etc that need to be taken into consideration. Django has some things that help with this. But at the simplest you can secure your site with SSL encryption when performing authentication. You should also consider OpenID as an alternative for authentication, like how StackOverflow gives you the option.
3) I do all my "play" on my macbook pro or pc at home. You can do all of this for free on your own machine, and when you're ready to deploy pick a host, like Amazon or something like Media Temple.

How can I retrieve updated records in real-time? (push notifications?)

I'm trying to create a ruby on rails ecommerce application, where potential customers will be able to place an order and the store owner will be able to receive the order in real-time.
The finalized order will be recorded into the database (at the moment SQLite), and the storeowner will have a browser window open, where the new orders will appear just after the order is finalized.
(Application info: I'm using the HOBO rails framework, and planning to host the app in Heroku)
I'm now considering the best technology to implement this, as the application is expected to have a lot of users sending in a lot of orders:
1) Each browser window refreshes the page every X minutes, polling the server continuously for new records (new orders). Of course, this puts a heavy load on the server.
2) As above, but poll the server with some kind of AJAX framework.
3) Use some kind of server push technology, like 'comet' asynchronous messaging. Found Juggernaut, only problem is that it is using Flash and custom ports, and this could be a problem as my app should be accessible behind corporate firewalls and NAT.
4) I'm also checking node.js framework, seems to be efficient for this kind of asynchronous messaging, though it is not supported in Heroku.
Which is the most efficient way to implement this kind of functionality? Is there perhaps another method that I have not thought of?
Thank you for your time and help!
Node.js would probably be a nice fit - it's fast, loves realtime and has great comet support. Only downside is that you are introducing another technology into your solution. It's pretty fun to program in tho and a lot of the libraries have been inspired by rails and sinatra.
I know heroku has been running a node.js beta for a while and people were using it as part of the recent nodeknockout competition. See this blog post. If that's not an option, you could definitely host it elsewhere. If you host it at heroku, you might be able to proxy requests. Otherwise, you could happily run it off a sub domain so you can share cookies.
Also checkout socket.io. It does a great job of choosing the best way to do comet based on the browser's capabilities.
To share data between node and rails, you could share cookies and then store the session data in your database where both applications can get to it. A more involved architecture might involve using Redis to publish messages between them. Or you might be able to get away with passing everything you need in the http requests.
In HTTP, requests can only come from the client. Thus the best options are what you already mentioned (polling and HTTP streaming).
Polling is the easier to implement option; it will use quite a bit of bandwidth though. That's why you should keep the requests and responses as small as possible, so you should definitely use XHR (Ajax) for this.
Your other option is HTTP streaming (Comet); it will require more work on the set up, but you might find it worth the effort. You can give Realtime on Rails a shot. For more information and tips on how to reduce bandwidth usage, see:
http://ajaxpatterns.org/Periodic_Refresh
http://ajaxpatterns.org/HTTP_Streaming
Actually, if you have your storeowner run Chrome (other browsers will follow soon), you can use WebSockets (just for the storeowner's notification though), which allows you to have a constant connection open, and you can send data to the browser without the browser requesting anything.
There are a few websocket libraries for node.js, but i believe you can do it easily yourself using just a regular tcp connection.

Work flow for authentication and API use with Twitter on OAuth

I'm a bit confused about all this OAuth bruhaha in the sense that all the examples I can find are for web applications and none of them for desktop applications.
I understand the Web application work flow, but that includes some redirections between the web app and twitter.
How does one do this in an desktop application?
How does the redirects work?
Should I have to include a Web Browser object?
Is there a way to go around this?
Could anyone point me to resources instead of a full blown solution please?
Thanks
Not sure which language you're using, but the .NET library for Twitter called Tweetsharp has a post on using Tweetsharp from a desktop app and authenticating via OAuth. See http://tweetsharp.com/?p=68. If you're not using .NET then perhaps it will inspire something you can do?
Basically, what tweetsharp does is launch the browser to the authentication URL and then waits for the user to return. I don't know of any way to do this other than something like that (Or include a WebBrowser control of some kind to launch the authentication URL in your own window).
Here's a straightforward solution, implemented as a set of PHP scripts for running from the command line. Well documented and explained, with a helpful 'verbose' option for debugging.
http://nullinfo.wordpress.com/oauth-twitter/
After some poking around and asking some questions about this subject to some other programmers, it looks like it's still an ongoing discussion, with no visible light at the end of the tunnel.
But for people interested on the ongoing discussion, here's the best link to have:
OAuth Desktop Discussion
I've seen a few desktop apps get around this by effectively embedding a browser into their program, so they can just open the in-app browser window to let you do the login and authorisation. This strikes me as a bit of a cheat or defeat of purpose because you still end up typing your ID and password inside the application anyway.
One possibility I was thinking of was, your desktop application could embed a mini HTTP server inside it. So then it launches the default browser to perform the authorisation, with a callback URL something like http://127.0.0.1:8765/oauthorized and then just listen for it.
Would that work?
Not sure what you would do for console applications... spawn a copy of lynx?
Include a WebBrowser control in your app. Put it in a panel or a separate form that you'll Form.ShowDialog().
Create a callback for the browser's successful posting of OAuth and one for a rejection. Don't forget to check for a FailWhale.
In the callback, you close the panel or form and store the token.
Here's a nice overview with sample code and everything: http://tweetsharp.com/2009/04/how-to-authenticate-a-desktop-application-with-oauth/

Resources