smallseo.info

Nimble

A Matcher Framework for Swift and Objective-C

What makes nimble better than shiro?

What makes nimble a better choice than shiro?

I'm trying to decide between nimble and shiro for a new grails project right now and I'm curious what makes nimble the better choice.


Source: (StackOverflow)

how to fix illegal package import checkstyle warning

I am using "java.lang.reflect.Type" in web app project all working fine..but I am stuck with code review how to fix "java.lang.reflect.Type illegal package import " -checkstyle warning.. I am more intrested in explanation of this warning.

Thanks


Source: (StackOverflow)

GORM createCriteria and list do not return the same results : what can I do?

I am using Nimble and Shiro for my security frameworks and I've just come accross a GORM bug. Indeed :

User.createCriteria().list { 
   maxResults 10 
} 

returns 10 users whereas User.list(max: 10) returns 9 users !

After further investigations, I found out that createCriteria returns twice the same user (admin) because admin has 2 roles!!! (I am not joking).

It appears that any user with more than 1 role will be returned twice in the createCriteria call and User.list will return max-1 instances (i.e 9 users instead of 10 users)

What workaround can I use in order to have 10 unique users returned ?

This is a very annoying because I have no way to use pagination correctly.


My domain classes are:

class UserBase { 
   String username 
   static belongsTo = [Role, Group] 
   static hasMany = [roles: Role, groups: Group] 
   static fetchMode = [roles: 'eager', groups: 'eager'] 
   static mapping = { 
     roles cache: true, 
     cascade: 'none', 
     cache usage: 'read-write', include: 'all' 
   } 
}

class User extends UserBase { 
  static mapping = {cache: 'read-write'} 
} 

class Role { 
  static hasMany = [users: UserBase, groups: Group] 
  static belongsTo = [Group] 
  static mapping = { cache usage: 'read-write', include: 'all' 
    users cache: true 
    groups cache: true 
  } 
} 

Source: (StackOverflow)

How does nimble work in nodejs?

i am trying to understand how to use nimble for flow control with nodejs but I am having trouble understanding how it actually works and there's really no documentation that explains it(that I could find)

For example, take this code from the docs:

_.parallel([
    function (callback) {
        setTimeout(function () {
            console.log('one');
            callback();
        }, 25);
    },
    function (callback) {
        setTimeout(function () {
            console.log('two');
            callback();
        }, 0);
    }
]);

I am having trouble understanding the callback argument that the functions take, what actually gets passed as a callback? The next function in line? If that is the case, then why does the second(and last) function also run callback()? If there is no more functions to run then what is the point of this? Thanks!

I did my own little test and took out the callbacks:

var flow = require('nimble');

flow.parallel([
function() {
    setTimeout(function() {
        console.log('this happens');
    }, 3000);
},
    function() {
        setTimeout(function() {
        console.log('and this happens at the same time');
    }, 3000);
}
]);

And the code works the same as if I had callbacks passed in, so now I feel likeI really don't understand what the callback args do.


Source: (StackOverflow)

Grails request filters: what's the source of this mysterious authorization method?

I'm building a custom authentication filter class in Grails. It's working, but it bugs me that I don't know why it's working.

In the following Grails request filter, where/how is the "role" method defined? It's got to be part of the Nimble plugin for Grails, but I don't see it in NimbleFilterBase, which my filter class extends.

public class MySecurityFilters extends MyCustomExtensionOfNimbleFilterBase {
    def filters = {
        reports(controller: 'foo', action: 'bar') {
            before = {
                accessControl {
                    role('Administrator')
                }
            }
        }

Also, what exactly is the "accessControl" block? Is that a built-in part of Grails, or something Nimble somehow provides, or just a random scoping mechanism that I could get rid of?

Thanks!


Source: (StackOverflow)

API call by HTTP POST method without using parameter name for the body

I'm using Java. How I can make a HTTP POST call API and inform in body only "JSON" value (without parameter name)?

Per example call this URL: https://api.nimble.com/api/v1/contact?access_token=12123486db0552de35ec6daa0cc836b0 (POST METHOD) and in body would only have this (without parameter name):

{'fields':{'first name': [{'value': 'Jack','modifier': '',}],'last name': [{'value': 'Daniels','modifier': '',}],'phone': [{'modifier': 'work','value': '123123123',}, {'modifier':'work','value': '2222',}],},'type': 'person','tags': 'our customers\,best'}

If this is correct, someone could give me an example please?


Source: (StackOverflow)

Get non-authenticated user's details

In some CRM applications, I've seen functionality which looks like it is pulling FaceBook feeds for private profiles of other users/customers... how is this done? One example of this functionality is from Nimble: http://www.nimble.com/how-it-works/contact-management/

From everything I've read about the FaceBook API[s], they can only be used to pull information for the currently authenticated user or their friends, depending on the requested access. Am I simply misunderstanding the product, and it's just a mock-up showing the logged-on user's/friend's information that wouldn't actually be useful in the context of a CRM application? If not, I would like to develop a CRM tool to view the FaceBook details for any user, does anyone know where to start? Does FaceBook allow businesses to pay to access that information?

Any clarification would be appreciated.


Source: (StackOverflow)

409 HTTP ERROR when trying to send a JSON string in POST request

I need to make an HTTP POST sending a JSON string in body request, in the simplest way possible. The api is this: 'api.nimble.com/api/v1/contact' (https://nimble.readthedocs.org/en/latest/contacts/basic/create/).

The JSON is a String variable (not necessary to use any additional libraries), should be sent in the body of the request.

I have the following Java code but always return 409 HTTP ERROR.

Someone could tell me what I should change/add in the code to work correctly? Thanks a lot!

UPDATE: Solution is validate with: http://jsonlint.com/ . The correct JSON string is (escape double quote and remove commas to the end of the fields):

String str_JSON="{\"fields\": {\"first name\": [{\"value\": \"Jack\",\"modifier\": \"\"}],\"last name\": [{\"value\": \"Daniels\",\"modifier\": \"\"}],\"phone\": [{\"modifier\": \"work\",\"value\": \"123123123\"},{\"modifier\": \"work\",\"value\": \"2222\"}]},\"type\": \"person\",\"tags\": \"test\"}";

Code:

String str_response="";
String access_token=request.getParameter("at");
String data="{'fields': {'first name': [{'value': 'Jack','modifier': '',}],'last name': [{'value': 'Daniels','modifier': '',}],'phone': [{'modifier': 'work','value': '123123123',}, {'modifier': 'work','value': '2222',}],},'type': 'person','tags': 'test'}";
try{
    URL url = new URL("https://api.nimble.com/api/v1/contact?access_token="+access_token);
    HttpURLConnection connection = (HttpURLConnection)url.openConnection();
    connection.setRequestMethod("POST");
    connection.setRequestProperty("Content-Type","application/json");
    connection.setUseCaches(false);
    connection.setDoInput(true);
    connection.setDoOutput(true);
    //Send Request
    DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
    wr.writeBytes(data);
    wr.flush();
    wr.close();
    System.out.println("Api:"+url.getHost()+url.getPath());
    System.out.println("Header:"+connection.getHeaderField("Content-Type"));
    System.out.println("content:"+connection.getContent());
    //Get Response
    BufferedReader rd = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    String line;
    while ((line = rd.readLine()) != null) {
        str_response+= line + '\r';
    }
    rd.close();
}catch(Exception e){
    System.out.println("Exception:"+message);
}

I also tried change lines 13-15 with this, but the result is same:

OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);

Output:

Api:api.nimble.com/api/v1/contact
Header:application/json; charset=UTF-8
Exception:Server returned HTTP response code: 409 for URL: https://api.nimble.com/api/v1/contact?access_token=38fb4aa33a101ba1c385840409a8ae7b

Source: (StackOverflow)

Nimble parallel and series mix works in node.js

This sample of code from node.js in action book:

var flow = require('nimble');
var exec = require('child_process').exec;

function downloadNodeVersion(version, destination, callback) {
  var url = 'http://nodejs.org/dist/node-v' + version + '.tar.gz';
  var filepath = destination + '/' + version + '.tgz';
  exec('curl ' + url + ' >' + filepath, callback);
}

flow.series([
  function (callback) {
    flow.parallel([
      function (callback) {
        console.log('Downloading Node v0.4.6...');
        downloadNodeVersion('0.4.6', '/tmp', callback);
      },
      function (callback) {
        console.log('Downloading Node v0.4.7...');
        downloadNodeVersion('0.4.7', '/tmp', callback);
      }
    ], callback);
  },
  function(callback) {
    console.log('Creating archive of downloaded files...');
    exec(
      'tar cvf node_distros.tar /tmp/0.4.6.tgz /tmp/0.4.7.tgz',
      function(error, stdout, stderr) {
        console.log('All done!');
        callback();
      }
    );
  }
]);

but second function(callback) in flow.series does not executed i.e. final .tar archive does not created. What is wrong?


Source: (StackOverflow)

Using a common variable in Node.js Nimble flow.parallel control

I have the following code:

var flow = require('nimble');

exports.execute = function(data, estrategias, callback) {

    var estrategiaList = [];
    var resultList = [];

    for (var i in estrategias)
    {
            var estrategia = (function(item) {

                    return function(callbackFlow) {

                            // Cria uma nova instancia do indicador
                            var indicador = loadIndicador(item);

                            // Executa indicador
                            indicador.execute(item, data.fechamento, function(result) {
                                    resultList.push(result);
                            });

                            callbackFlow();
                    }

            })(estrategias[i]);

            estrategiaList.push(estrategia);
    }

    flow.parallel(estrategiaList, function() {
            callback(resultList);
    });
};

For some reason on the final flow.parallel callback callback(resultList) I'm getting the resultList empty.

I've checked that resultList.push(result) add successfully the result in the resultList array.

I think the problem is some small detail that I couldn't figured out.

Can someone help me ?

Regards. Kleyson Rios.


Source: (StackOverflow)

How do I customise table names in grails nimble?

I installed the Nimble 0.7 plugin for Grails just now, and have a running instance, but I now want to customise the table names. I followed the instructions in the plugin’s guide and restarted my app, but nothing happens. I also tried to manually delete the tables and restart the app, and it generated the tables with their original names.

NimbleConfig.groovy

nimble {
    ....
    tablenames {
        user = "auth_user"
        role = "auth_role"
        group = "auth_group"
        profilebase = "auth_profile_base"
        loginrecord = "auth_login_record"
        permission = "auth_permission"
        levelpermission = "auth_level_permission"
        url = "auth_url"
    }
    ....
}

Source: (StackOverflow)

Page loads without content when accessed directly

so we're having a very strange problem here. Whenever we try to open one of our blog entries directly by typing its URL into the browser, it doesn't load correctly (without any text). However, when we try to access it over a link on another page, it works just fine.

Even more strange: When we see the broken page and click Inspect Element, the missing content appears. This might be because the site is being reloaded when you click that.

The problem only exists in Chrome and only on this website:

Direct URL: http://www.myfeelix.de/immobilienkauf-behalten-sie-den-ueberblick-beim-papierkram/ (try copying this manually into the browser and you'll see what I mean)

Accessing it from this website works (first blog entry up top): http://www.myfeelix.de/category/feelix-experten-blog/ Anyone got any ideas?

UPDATE: The problem disappears when we disable Google Fonts. Any more ideas why this is causing a problem?


Source: (StackOverflow)

the callback and underscore in nimble flow-control tool

I have hard time understand nimble, and here are two questions:

1 -- I have a tiny test code below, almost direct copy from nimble's online tutorial. I didn't use any complicated asyn functions in there but just use a console.log for simplicity reasons.

var nimble = require('nimble');
nimble.series([
    function(cb) {
        console.log("first");
        cb();
    },
    function(cb) {
        console.log("second");
        cb();
    }
]);

It works as promised, but what's the point of the callback (cb)? From the code I seem never pass anything as cb to either function in the series.

Then I tried the modified version of the code. Basically, it deletes all callbacks.

var nimble = require('nimble');
nimble.series([
    function() {
        console.log("first");
    },
    function() {
        console.log("second");
    }
]);

It is sadly only output "first" but no "second", so it's wrong somewhere, not sure why. Now I am quite confused what that callback actually is and why we have to have it.

2 -- From nimble's tutorial, one seems to be able to use underscore (_) conveniently. I tried the following code, which is directly copied online, but I was just told the _ was not defined..

var nimble = require('nimble');
_.series([
    function (callback) {
        setTimeout(function () {
            console.log('one');
            callback();
        }, 25);
    },
    function (callback) {
        setTimeout(function () {
            console.log('two');
            callback();
        }, 0);
    }
]);

Probably I got something wrong. Should I import the underscore.js before I can use _ in nimble? But nimble says one of its selling points is that it is small, no need to import async and underscore. Then here I got confused again..


Source: (StackOverflow)

Mocha conflicting with Nimble (Async)

I'm using nimble.js in my app and mocha + chai for testing, but yesterday I found them to be possibly conflicting.

Basically, when I do a particular http request in my browser, I get

Unauthorized.

which is the correct response.

But using node's http module to do a http request using the same url, I get

not found

Which is confusing me.

I know the http request got the right url because I see it in the server console, even copy pasted it in my browser to be sure.

Additionally, I traced the code to the nimble.parallel function.

I have something like this:

// var _ = require('nimble');
_.parallel(
  [
    fetch_account(options)
  , fetch_invoice(options)
  , fetch_site(options)
  , fetch_account_stats(options)
  ]
, render(res, subdomain)
);
// each of the function above returns another function, no simple API gotcha here

In the browser case, an error was correctly identified in a fetch function, then also in the render case.

In the mocha case, an error was correctly identified in a fetch function, but render was not executed. Hence, mocha must've did its own res.render("not found");

Any ideas?


Source: (StackOverflow)