Skip to content

Instantly share code, notes, and snippets.

View gcr's full-sized avatar

Kimmy gcr

  • Google AI
  • 10:47 (UTC -04:00)
View GitHub Profile
HHHHHHHHH HHHHHHHHH lllllll lllllll
H:::::::H H:::::::H l:::::l l:::::l
H:::::::H H:::::::H l:::::l l:::::l
HH::::::H H::::::HH l:::::l l:::::l
H:::::H H:::::H eeeeeeeeeeee l::::l l::::l ooooooooooo
H:::::H H:::::H ee::::::::::::ee l::::l l::::l oo:::::::::::oo
H::::::HHHHH::::::H e::::::eeeee:::::eel::::l l::::l o:::::::::::::::o
H:::::::::::::::::H e::::::e e:::::el::::l l::::l o:::::ooooo:::::o
H:::::::::::::::::H e:::::::eeeee::::::el::::l l::::l o::::o o::::o
H::::::HHHHH::::::H e:::::::::::::::::e l::::l l::::l o::::o o::::o
THIS GIST SHOULD BE FILLED WITH BEES.
__ __ __ __ __
/ \ / \ / \ / \ / \
/ \__/ \__/ \__/ \__/ \
\ / \ / \ / \ / \ /
\__/ \__/ \__/ \__/ \__/
/ \ / \ / \ / \ / \
/ \__/ \__/ \__/ \__/ \
\ / \ / \ / \ / \ /
function gbDocument(docname) {
/* ..... */
this.destroy = function() {
// We've been destroyed! Best clean up our actions.
pagehandler.removeDoc(this.name, $(".tablist"));
console.log("I'm being deleted!");
console.log(this);
return undefined
pagehandler.clearAllActive = function(tlist) {
// tlist is the jQuery list of tabs.
// This function hides all the tabs' user lists and sets them to inactive.
$(tlist).find(".active").each(function (i, tab){ // For each active tab...
if (typeof session.subscribed_docs[$(tab).text()] != undefined) { // If our document still exists...
$(tab).removeClass("active"); // Make it inactive
$(tab).next().slideUp("medium"); // ...and slide up the user list (in the next node)
$(tab).find("img").hide(); // ...and remove all images
// Rebind our click handler.
a = {'a':1, 'b':2, 'c':3}
for (y in a) {
console.log(y + " " + a[y]);
}
a['b'] = undefined;
for (y in a) {
console.log(y + " " + a[y]);
}
a = {"a":1,"b": 2,"c": 3}
for (i in a) {
setTimeout(function(){console.log(i + " " + a[i]);},250);
}
/* Output:
c 3
c 3
c 3
*/
a = function() {
b = "Foo";
}
a();
alert(b);
// Outputs foo, strangely enough.
def new_chunk(self, **args):
"""
Adds a new chunk by the user into a certain document. The user
does not need to be subscribed to said document. Used like so:
http://localhost:8000/new_chunk?p=99&t=Hello+World
"""
cherrypy.session.acquire_lock()
assert self.is_logged_in(), "User is not logged in"
assert "doc_name" in args and "p" in args and "t" in args, "Bad request- please supply document name, position, and text."
d = self.gb.get_document_by_name(args['doc_name'])
this.parse_new_chunk = function(event) {
// This gets called whenever an event for a new chunk comes in.
var newchunk = .text(event.text);
// Get the position we want to insert at
var pos = event.position - 1;
console.log(pos);
// HACK: Are we at the beginning?
if (pos == -1) {
// If so, add it at the very beginning.
newchunk.prependTo(this.jqedit);
this.parse_new_chunk = function(event) {
// This gets called whenever an event for a new chunk comes in.
var newchunk = $("<span class='chunk'></span>").text(event.text);
// Get the position we want to insert at
var pos = event.position - 1;
console.log(pos);
// HACK: Are we at the beginning?
if (pos == -1) {
// If so, add it at the very beginning.
newchunk.prependTo(this.jqedit);