Skip to content

Instantly share code, notes, and snippets.

View bajtos's full-sized avatar

Miroslav Bajtoš bajtos

View GitHub Profile
_doGetResourceTree: function(params, done) {
this._debuggerClient.evaluateGlobal('process.argv[1]', function(err, argv1) {
if (err) return done(err);
this._scriptStorage.findApplicationRoot(argv1, function(root) {
this._scriptStorage.findAllScripts(root, function(err, files) {
if (err) return done(err);
return done(null, this._createResourceTreeResponse(files));
}.bind(this));
}.bind(this));
}.bind(this));
// Set this to the directory where you have node sources
// The test uses node's test certificates for the TLS server
var PATH_TO_NODE_SOURCES = '/Users/bajtos/src/node';
/** Usage **
1. Start a SSL server in terminal 1
$ openssl s_server -cert test_cert.pem -key test_key.pem
(..lots of SSL logs..)
2. Run the client in terminal 2 - don't reuse sessions
@bajtos
bajtos / gist.gradle
Created October 14, 2013 17:52
Poor man's propagation of Android JAR Library dependencies to pom.xml
pom.withXml {
def root = asNode()
def deps = new Node(root, 'dependencies')
configurations.compile.allDependencies.each { dep ->
def node = new Node(deps, 'dependency')
new Node(node, 'groupId', dep.group)
new Node(node, 'artifactId', dep.name)
new Node(node, 'version', dep.version);
}
}
@bajtos
bajtos / rfc.js
Created December 9, 2013 19:17
RFC: syntax sugar for mocha tests calling multiple async functions
// Original code
it('does something complex', function(done) {
async.waterfall(
[
function setupSchema(cb) {
db.setupSchema(/*...*/, cb);
},
function createTestUser(cb) {
db.createUser({ name: 'a user name' }, cb);
}
@bajtos
bajtos / checklist.md
Created January 15, 2014 11:52
Checklist for LBUser implementation in iOS and Android SDKs.

Checklist for LBUser implementation in iOS and Android SDKs.

Basic auth worklow:

  1. Login as an existing user (email + password).
  2. All REST calls are using the access token obtained in step 1
  3. Log out

Advanced:

@bajtos
bajtos / 1-test.js
Last active August 29, 2015 13:56
JavaScript function displayName
var f = function() {
throw new Error('oops');
};
f.displayName = 'myfunc';
f();
@bajtos
bajtos / bug.js
Created March 6, 2014 12:37
Code to reproduce a bug in loopback-storage-service
var fs = require('fs');
var net = require('net');
var path = require('path');
var loopback = require('loopback');
var request = require('supertest');
var http = require('http');
var storageDir = path.join(__dirname, '_storage');
if (!fs.existsSync(storageDir)) fs.mkdirSync(storageDir);
@bajtos
bajtos / test.js
Created July 25, 2014 09:19
Test for how strong-remoting handles request pause/resume
var net = require('net');
var extend = require('util')._extend;
var express = require('express');
var RemoteObjects = require('strong-remoting');
var objects = RemoteObjects.create();
var reqUrl = givenStreamingEchoMethodWithAsyncSharedCtor();
var app = express();
@bajtos
bajtos / server.js
Created July 25, 2014 15:05
Customize Model.sharedCtor
var loopback = require('loopback');
var boot = require('loopback-boot');
var app = module.exports = loopback();
// hack sharedCtor
var setup = loopback.PersistedModel.setup;
loopback.PersistedModel.setup = function(rec) {
var extend = require('util')._extend;
# output of `dtruss -p {pid}` for /System/Library/CoreServices/launchservicesd
SYSCALL(args) = return
workq_kernreturn(0x20, 0x0, 0x1) = 0 0
process_policy(0x1, 0xF, 0x7) = 0 0
process_policy(0x1, 0xF, 0x7) = 0 0
kevent64(0x3, 0x7FFF72E3F130, 0x1) = 1 0
workq_kernreturn(0x20, 0x0, 0x1) = 0 0
kevent64(0x3, 0x7FFF72E3F130, 0x1) = 1 0
workq_kernreturn(0x20, 0x0, 0x1) = 0 0
process_policy(0x1, 0xF, 0x7) = 0 0