Skip to content

Instantly share code, notes, and snippets.

function fetchEmails = function (range, options, query, mailbox, done) {
var emails = [];
if(!mailbox)
return done({error: 'mailbox not ready'});
query.cb = function (fetch) {
fetch.on('message', function (msg) {
var headers = {},
body = '';
exports.fetchConversationDetail2 = function (req, res) {
var contact = req.params.contact;
console.log(contact);
async.auto({
search_from: function (done) {
imap.search([['HEADER', 'FROM', contact]], done);
},
search_to: function (done) {
var IMAP = require('imap');
var imap = new IMAP({
user: 'frontapp@gmail.com',
password: 'redcontact',
host: 'imap.gmail.com',
port: 993,
secure: true,
debug: console.log
});
@lperrin
lperrin / gist:5934098
Created July 5, 2013 12:04
A quick example of circular dependency with node.js. This code will crash unexpectedly because module A is only partially loaded by C.
// a.js
var moduleB = require('./b');
function ModuleA() {
}
ModuleA.hello = function () {
console.log('hello!');
};
function findAvailablePort(app, done) {
var port = portrange;
portrange += 1;
var server = http.createServer(app);
server.listen(port, function (err) {
done(server, port);
});
frontApp.directive('fastScroll', ['$parse', function ($parse) {
var Interval = function(min, max) {
this.min = min || 0;
this.max = max || 0;
};
Interval.prototype.clip = function(min, max) {
if(this.max <= min || this.min >= max) {
this.min = this.max = 0;
app.directive('faFastScroll', ['$parse', function ($parse) {
var Interval = function(min, max) {
this.min = min || 0;
this.max = max || 0;
};
Interval.prototype.clip = function(min, max) {
if(this.max <= min || this.min >= max) {
this.min = this.max = 0;
defaults write com.yourcompany.YourApp WebKitDeveloperExtras -bool true
- (void)runJavaScript:(NSString *)command {
NSLog(@"js: %@", command);
[self.web stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"if (typeof jsapi !== 'undefined') %@;", command]];
}
- (void)toggleArchived {
[self runJavaScript:@"jsapi.toggleArchiveConversation()"];
}
$window.jsapi = {
refresh: function () {
emitRootScope('refresh');
},
search: function (query) {
$rootScope.$apply(function () {
locations.search(query);
});
},