Skip to content

Instantly share code, notes, and snippets.

@EGreg
EGreg / gist:11236162
Last active August 29, 2015 14:00
Q.Promise
/**
* Q.Promise constructor.
* Call the .fulfill(...) or .reject(...) method to
* signal that the promise is fulfilled or rejected.
* Implemented according to http://promises-aplus.github.io/promises-spec/
* with two exceptions:
* 2.2.5) fulfill and reject can in fact accept "this", and pass it on
* 2.3.3.3.1) the first callback to .then() doesn't treat its arguments specially
*/
Q.Promise = function () {
@EGreg
EGreg / gist:11240354
Created April 24, 2014 03:21
Q.Promise standalone
/**
* Q.Promise constructor.
* Call the .fulfill(...) or .reject(...) method to
* signal that the promise is fulfilled or rejected.
* Implemented according to http://promises-aplus.github.io/promises-spec/
* with two exceptions:
* 2.2.5) fulfill and reject can in fact accept "this", and pass it on
* 2.3.3.3.1) the first callback to .then() doesn't treat its arguments specially
*/
Q.Promise = function () {
@EGreg
EGreg / OpenLetter
Created May 26, 2014 20:25
The Most Open Letter
This is the most open letter ever.
Other authors claim their letters are "open"
because you can all read them, but in reality,
they are nothing but the rants of one person,
which you might not even completely agree with,
or will piss you off.
By contrast, this letter is truly open and
gives you the freedom to fork and modify it.
Pissed about Mike Arrington investing?
@EGreg
EGreg / Patch
Created June 18, 2014 18:05
Streams/access patch to fix some things for now
From a93d584bfd081e352e06ea094cb07d07e1e8c15c Mon Sep 17 00:00:00 2001
From: Greg Magarshak <greg@qbix.com>
Date: Wed, 18 Jun 2014 12:38:03 -0400
Subject: [PATCH] Started working on the modern Streams/access tool
---
.../plugins/Streams/classes/Streams/Avatar.php | 5 ++-
.../plugins/Streams/classes/Streams/Stream.php | 6 +--
.../Streams/handlers/Streams/access/put.php | 6 +--
.../Streams/handlers/Streams/access/tool.php | 45 ++++++++++++----------
@EGreg
EGreg / accessdiff
Created June 18, 2014 18:05
Streams/access diff to fix some things for now
diff -r c3f7255b9205 platform/plugins/Streams/web/js/tools/access.js
--- a/platform/plugins/Streams/web/js/tools/access.js Wed Jun 18 12:38:37 2014 -0400
+++ b/platform/plugins/Streams/web/js/tools/access.js Wed Jun 18 14:05:18 2014 -0400
@@ -81,7 +81,7 @@
}
$this.closest('tr').remove();
if (criteria.ofUserId) {
- delete me.child('Streams_userChooser_').exclude[criteria.ofUserId];
+ delete me.child('Streams_userChooser').exclude[criteria.ofUserId];
} else if (criteria.ofContactLabel) {
@EGreg
EGreg / accessdiff
Created June 18, 2014 18:06
Streams/access diff to fix some things for now
diff -r c3f7255b9205 platform/plugins/Streams/web/js/tools/access.js
--- a/platform/plugins/Streams/web/js/tools/access.js Wed Jun 18 12:38:37 2014 -0400
+++ b/platform/plugins/Streams/web/js/tools/access.js Wed Jun 18 14:05:18 2014 -0400
@@ -81,7 +81,7 @@
}
$this.closest('tr').remove();
if (criteria.ofUserId) {
- delete me.child('Streams_userChooser_').exclude[criteria.ofUserId];
+ delete me.child('Streams_userChooser').exclude[criteria.ofUserId];
} else if (criteria.ofContactLabel) {
@EGreg
EGreg / chat-messages.js
Last active August 29, 2015 14:04
Please implement something like this
function loadMoreStuff(callback, options) {
// standard options stuff
var o = Q.extend({
max: -1,
limit: 10
}, loadMoreStuff.options, options);
// use streams api
Q.Message.get(publisherId, streamName, o,
@EGreg
EGreg / Q.normalize
Created August 13, 2014 00:11
Here is Q.normalize
/**
* Normalizes text by converting it to lower case, and
* replacing all non-accepted characters with underscores.
*
* @static
* @method normalize
* @param {String} text
* The text to normalize
* @param {String} replacement
* Defaults to '_'. A string to replace one or more unacceptable characters.
@EGreg
EGreg / Q.Promises.js
Created November 11, 2014 22:36
A clear and tested Promises implementation
/**
* Q Promises implementation
* @module Q
*/
(function (Q) {
/**
* Q.Promise constructor.
* Call the .fulfill(...) or .reject(...) method to
* signal that the promise is fulfilled or rejected.
@EGreg
EGreg / group.handlebars
Created March 15, 2015 19:44
Group template
{{&tool "Streams/participants" "group" max=10 maxShow=10 showSummary=false showControls=true showBlanks=true }}
<div class="Q_big_prompt Groups_going_prompt">
Are you in?
<span class="Groups_going" data-going="{{going}}">
<span data-going="no" class="Groups_no {{no}}">No
</span><span data-going="maybe" class="Groups_maybe {{maybe}}">Maybe
</span><span data-going="yes" class="Groups_yes {{yes}}">Yes</span>
</span>
</div>