Skip to content

Instantly share code, notes, and snippets.

@mrvisser
mrvisser / nakamura-message-example.java
Created May 29, 2012 13:19
Creating a simple entity for the OAE Infinispan Storage API proto-type
@Indexed @ProvidedId
public class Message implements Entity, DeepCopy<Message>, Serializable {
public String key;
public String from;
@Field
public String to;
@mrvisser
mrvisser / gist:3084440
Created July 10, 2012 16:20
New solr search "parameters" handling whiteboard
// DomainObjectQueryHandler will assert a generic "SearchInfo" data-type
public abstract class DomainObjectQueryHandler<T extends SearchInfo> {
...
public abstract T buildSearchInfo(HttpServletRequest request);
...
public String refineQString(T searchInfo) {
return null;
}
}
@mrvisser
mrvisser / context-plugin
Created September 12, 2012 21:21
Sample plugability in Context
// oae-context/lib/api.js
/**
* A generic context object that represents a user execution context.
*
* @param {String} tenantId The unique id of the tenant in the context (e.g., 'cam')
* @param {String} userUuid The UUID of the active user in the context (e.g., 'u:cam:nicolaas')
*/
var Context = module.exports.Context = function(tenantId, userUuid) {
@mrvisser
mrvisser / i-stink-less.js
Created September 21, 2012 21:50
Manually monitoring parallel permission checks
/**
* Determine whether or not one of the principals in the array of principalUuids is able to perform the action on the
* resource specified. If the action is null, then we will determine if the user can perform *any* action on the
* resource specified.
*
* @param {Array<String>} principalUuids The array of principals to check
* @param {String} action The action to check. If null, check for any action.
* @param {String} resourceUuid The resource to check
* @param {Function(err, isAllowed)} callback A function invoked when the process is complete.
* @param {Object} callback.err An error that occured, if any
@mrvisser
mrvisser / gist:3941458
Created October 23, 2012 20:49
Query DSL
{
"filtered": {
"query": {
"queryString": {
"default_field": "general",
"query": "hazardous"
}
},
"filter": {
"and": [
@mrvisser
mrvisser / gist:3946016
Created October 24, 2012 13:20
Filtered query
{
"query": {
"filtered": {
"query": {
"default_field": "general",
"query": "link"
},
"filter": {
"and": [
{
@mrvisser
mrvisser / gist:3949834
Created October 25, 2012 00:43
Sort field tokenized
// Query:
{
"query": {
"query_string": {
"default_field": "general",
"query": "*"
}
},
"from": "0",
"size": "10",
@mrvisser
mrvisser / gist:4002675
Created November 2, 2012 16:55
Unit test error.
2) Users User timezone Test timezones:
TypeError: Cannot call method 'toString' of undefined
at ServerResponse.writeHead (http.js:980:45)
at ServerResponse.res.writeHead (/private/tmp/Hilary/node_modules/connect/lib/patch.js:75:22)
at ServerResponse._implicitHeader (http.js:931:8)
at ServerResponse.OutgoingMessage.end (http.js:766:10)
at res.end (/private/tmp/Hilary/node_modules/connect/lib/middleware/session.js:284:13)
at module.exports.RedisStore.set (/private/tmp/Hilary/node_modules/connect-redis/lib/connect-redis.js:128:18)
at try_callback (/private/tmp/Hilary/node_modules/redis/index.js:520:9)
at RedisClient.return_reply (/private/tmp/Hilary/node_modules/redis/index.js:590:13)
@mrvisser
mrvisser / gist:4155177
Created November 27, 2012 16:17
MOCHA_GREP
diff --git a/grunt.js b/grunt.js
index 3412fd7..8b35d4a 100644
--- a/grunt.js
+++ b/grunt.js
@@ -1,6 +1,7 @@
module.exports = function(grunt) {
var shell = require('shelljs');
+ var grep = process.env['MOCHA_GREP'] || undefined;
// MyModule.js
define(['jquery-loader', 'oae.core', 'jquery.timeago', 'jquery.infinitescroll'], function($, oae, timeago, infiniteScroll) {
return function(uid, showSettings, widgetData) {
/////////////////////////////
// Configuration variables //
/////////////////////////////