Skip to content

Instantly share code, notes, and snippets.

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;
@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!');
};
@lperrin
lperrin / magic_number.md
Last active February 18, 2017 01:15
Find the magic number

Find the magic number

The goal is to find the smallest number (let's call it M) such that:

  • If M obeys property X, then the digit X is part of the number.
  • If M does not obey property X, then the digit X is NOT part of the number.

For example, if 2457 were a magic number, it would obey properties 2, 4, 5, 7 and not 0, 1, 3, 6, 8, 9. However we find that not to be the case, so it is not the number we are looking for.

Properties

Keybase proof

I hereby claim:

  • I am lperrin on github.
  • I am lperrin (https://keybase.io/lperrin) on keybase.
  • I have a public key whose fingerprint is 1782 E580 C9CB A9A2 87A1 E211 960A C648 7F97 C30C

To claim this, I am signing this object:

[$http:badreq] Http request configuration url must be a string. Received: null
http://errors.angularjs.org/1.5.0/$http/badreq?p0=null
https://app2.frontapp.com/build/js/libs.min.js?v=1463029656879:7:386
d@https://app2.frontapp.com/build/js/libs.min.js?v=1463029656879:8:15643
https://app2.frontapp.com/build/js/libs.min.js?v=1463029656879:8:16766
load@public/js/app/inboxes/cells/conversations_model.js:164:23
load@public/js/app/inboxes/cells/cells.js:86:27
stateChangeSuccess@public/js/app/inboxes/cells/cells.js:180:16
public/js/app/inboxes/cells/cells_ctrl.js:268:31
$broadcast@https://app2.frontapp.com/build/js/libs.min.js?v=1463029656879:9:11181
[Warning] Pusher : Error : {"type":"WebSocketError","error":{"type":"PusherError","data":{"code":null,"message":"No current subscription to channel private-conversation-72291667, or subscription in progress"}}} (libs.min.js, line 1)
[Warning] Pusher : Error : {"type":"WebSocketError","error":{"type":"PusherError","data":{"code":1006,"message":"Connection interrupted (200)"}}} (libs.min.js, line 1)
[Info] pusher connecting (libs.min.js, line 8)
[Info] pusher connected (libs.min.js, line 8)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (smooch, line 0)
[Log] pushState (3) (app.min.js, line 244)
[Log] pushState (3) (app.min.js, line 244)
[Log] pushState (3) (app.min.js, line 244)
[Log] pushState (3) (app.min.js, line 244)
[Warning] The page at https://app2.frontapp.com/inboxes/team/me/assigned/received/101125094 was allowed to display insecure content from http://codestarssummit.com/miscpages/header_svcc_2016.png. (libs.min.js, line 5)
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;
function findAvailablePort(app, done) {
var port = portrange;
portrange += 1;
var server = http.createServer(app);
server.listen(port, function (err) {
done(server, port);
});
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
});
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) {