Skip to content

Instantly share code, notes, and snippets.

@dmachi
dmachi / pom.xml
Created December 8, 2010 22:22
maven profile example for generating and copying docs.
<profile>
<id>docs</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
#content {
border: 3px solid gray;
height: 300px;
width: 150px;
}
@dmachi
dmachi / getChildren
Created December 2, 2010 16:07
Recursive tree item getter for tree.
var getChildren = function(model, item){
children = [];
if (model.mayHaveChildren(item){
var ch = model.getChildren(item);
dojo.forEach(ch, function(child){
children.push(child)
children = children.concat(getChildren(model, child));
});
}
return children;
@dmachi
dmachi / dynrequire.js
Created November 27, 2010 17:56
wrapped dojo require to work around addOnLoad issue in xd when the module has already been loaded
// check to see if this loaded module already exists. Returns a deferred that will already be resolved or
// or will resolve with an addOnLoad after the require
var dynrequire = function(names){
var def = new dojo.Deferred();
var loading=false;
dojo.forEach(names, function(n){
if (!dojo._loadedModules[n]){
dojo.require(n);
loading=true;
var session = new Session({url: "http://192.168.5.16:4444/wd/hub"})
var capabilities = session.startSession({browserName: "internet explorer"});
var url = "http://google.com";
when(capabilities,function(capabilities){
print("Connected to Session");
print("sessionId: " + capabilities.sessionId);
print("Session Props: " + json.stringify(capabilities));
pshallow(capabilities);
exports.urlMap = function(map, nextApp){
return function(request){
for (var i = 0; i<map.length; i++){
var match = map[i][0];
var ctor = map[i][1];
var returnRequest = map[i][2];
if (request.pathInfo.match(match)){
print("found match:", match);
var res = ctor(request, match);
if (res && returnRequest) return res;
if (response.status > 400) {
//print("Error Response: " + response.status);
template = templateEngine.compile("/error/"+response.status);
}else{
template = templateEngine.compile(templateId, (mediaParams && mediaParams.template));
}
return {
var nodes = multiNode.listen({port: settings.port || 8080, nodes: settings.processes || 1},
require( "http" ).createServer(
require("jsgi-node").Listener(
// uncomment this to enable compression with node-compress
//require("pintura/jsgi/compress").Compress(
// make the root url redirect to /Page/Root
require("pintura/jsgi/rewriter").Rewriter("\/$", "/page/test",
require("pintura/jsgi/cascade").Cascade([
// cascade from static to pintura REST handling
// the main place for static files accessible from the web
// Defines the data model for the given user by request
pinturaConfig.getDataModel = function(request){
var user = request.remoteUser;
if(user){
if(admins.indexOf(user)>-1){
return fullModel; // admin users can directly access the data model without facets
}
return getUserModel(user, publicModel);
}
//ttrenka's connection counting function
(function(){
var connect = 0, disconnect = 0;
dojo.connect(dojo, "connect", function(){ connect++; });
dojo.connect(dojo, "disconnect", function(){ disconnect++; });
dojo.__getConnectCount = function(){
console.log("dojo.connect has run: ", connect);
console.log("dojo.disconnect has run: ", disconnect);
console.log("Total current connections: ", (connect - disconnect));
};