News for hackers. Stuff that matters.
Re:Show HN: Scratchpad.io - a real-time HTML and CSS editor by nbashaw on Monday December 17, 2012 @01:58PM (#4933724)
Thanks! It was actually really simple to make with two tools: http://ace.ajax.org and http://www.firebase.com

If you want to chat about building it I'd love to give you any tips - i'm [email protected]

Re:Show HN: Scratchpad.io - a real-time HTML and CSS editor by gbadman on Monday December 17, 2012 @02:02PM (#4933739)
How did you accomplish the real-time text editing? Is there any OT engine that you hacked into Firebase?
Re:Show HN: Scratchpad.io - a real-time HTML and CSS editor by nbashaw on Monday December 17, 2012 @02:14PM (#4933800)
Basically on keyup I ship the whole contents of the editor and the cursor position to firebase. I'm also keeping track of all the active connections to a scratchpad document so I know who is typing. Anytime the code changes on the server, it triggers a callback function on each client that will update the contents of the textarea. If someone else is typing, the document is locked so only 1 person can type at a time. This way I can avoid all the potential merge conflicting type things that can happen.

I'm not sure what an OT engine is. What is that?

Re:Show HN: Scratchpad.io - a real-time HTML and CSS editor by gbadman on Monday December 17, 2012 @02:21PM (#4933844)
OT (See: http://en.wikipedia.org/wiki/Operational_transformation) is one of the technology solutions to the problem that you've solved through a locking mechanism.

Not sure what server architecture you're using, but in Node.js there is a pretty amazing package that integrates with ACE called ShareJS (http://sharejs.org/).

Have you experimented with synchronizing cursors at all?

Re:Show HN: Scratchpad.io - a real-time HTML and CSS editor by nbashaw on Monday December 17, 2012 @02:39PM (#4933931)
Thanks! I'll have to read up on OT. Our backend is totally hosted by Firebase, other than a simple Sinatra app that generates the unique IDs.

When you say synchronizing cursors, do you mean having multiple cursors (google docs style) or having a single cursor be in the same position for all clients? We are doing the latter, and I wasn't aware it was possible to do the former with ace but I would love to do it if I can

Re:Show HN: Scratchpad.io - a real-time HTML and CSS editor by gbadman on Monday December 17, 2012 @02:45PM (#4933960)
Seems that I can't reply to the child of my sibling comment so I'm replying here.

ACE is quite ridiculously powerful. On its primary implementation (http://c9.io), it supports multiple cursors with concurrent editing.

I've been able to use ShareJS to get concurrent editing working (see: http://plnkr.co/edit/?p=preview&s=HN4933608) but haven't had a chance to display visual cursors for all simultaneous users. I was thinking that I could get that working using Firebase.

Re:Show HN: Scratchpad.io - a real-time HTML and CSS editor by michaelbuckbee on Monday December 17, 2012 @02:30PM (#4933881)
Do you know what/how Firebase is doing the realtime updates? Websockets with fallback to flash?
Re:Show HN: Scratchpad.io - a real-time HTML and CSS editor by gsoltis on Monday December 17, 2012 @02:44PM (#4933956)
Hi, I'm one of the Firebase engineers working on keeping clients connected.

We use a mix of different methods to maintain a connection. We normally start with our custom long polling implementation and move to websockets when they are available. We do not currently make use of any flash sockets.

Re:Show HN: Scratchpad.io - a real-time HTML and CSS editor by daemon13 on Tuesday December 18, 2012 @01:47AM (#4936361)
Is Firebase open source?

It states so on the sites/GH pages, but could not find pointers to repo [after 2 circle through 5 different pages poiting to each other].

Re:Show HN: Scratchpad.io - a real-time HTML and CSS editor by nbashaw on Monday December 17, 2012 @02:34PM (#4933904)
I believe that's it but I'm not sure. I've emailed the firebase founder and he might be able to chime in here