My query url is:
var url = 'https://api.mongolab.com/api/1/databases/database/collections/collection?'
+ 'q={'
+ '\"visible\": true'
+ ', \"date\": ' + JSON.stringify( jsonDate )
+ ', \"country\": \"' + country + "\""
+ '}'
+ '&s={"date": -1}'
+ '&apiKey=' + this.key;
I have and option to sort after with Backbone or Jquery, but I hope to do it with query.
The url you generated is correct, however it is not a valid URL unless you do proper URL encoding of special characters like spaces.
Use encodeURIcomponent of your query parameters, and it should work.
Or use jQuery to pass your parameter as javascript object in jQuery.get method.
Query is working. Problem was in PhoneGap framework, because I've open platform related JS/HTML code and made changes in there. But changes should be made in special www directory, one with source for every platforms.
I would prefer using cursor.sort(sort).
cursor.sort(date)
check this http://docs.mongodb.org/manual/reference/method/cursor.sort/
Related
Does anyone know how to access the test.parameters key-value pairs passed as input to the ScheduleRun API?
This is what I am doing:
Passing the input for the test to be run under test.filter.
Passing the parameters I need for my test under test.parameters. I have ensured it is a valid JSON object.
I am not passing any yaml file, so a "standard" test run gets triggered on DeviceFarm.
Here is my code that I use to retrieve the data:
final Bundle bundle = InstrumentationRegistry.getArguments();
for (final String key : bundle.keySet())
{
final Object obj = bundle.get(key);
Log.i(TAG, "Key - '" + key + "' ; Value - '" + obj.toString() + "'");
}
I know the test.filter part works because the InstrumentationRegistry.getArguments() bundle is able to retrieve the class value which is the test that needs to be run. Unfortunately, the test.parameters values are not present in the bundle.
Is there anything that I am missing or should I use some other mechanism to retrieve the test.parameters ?
Got confirmation from the AWS team that, at this point, they don't support this feature for Custom environments.
I'm trying to star a repository using the GithubAPI. This is done via a PUT request to /user/starred/:owner/:repo. I attempted to implement this feature in python using the requests library, but it isn't working. Here is a minimum working example:
The constant are defined as GITHUB_API = api.github.com, GITHUB_USER = the username of the owner of the repo to be starred, and GITHUB_REPO = the name of the repo to be starred
url = urljoin(GITHUB_API, (user + '/starred/' + GITHUB_USER + '/' + GITHUB_REPO))
r = requests.put(url,auth=(user,password))
print r.text
This code results in an error that reads:
{"message":"Not Found","documentation_url":"https://developer.github.com/v3"}
I think that I'm missing something fundamental about the process of issuing a PUT request.
The problem here is the parameters you pass to urljoin(). The first parameter is supposed to be an absolute URL, while the second parameter is a relative URL. urljoin() then creates an absolute URL from that.
Also, "user" in this case is supposed to be a literal part of the URL, and not the username.
In this case, I would forgo the urljoin()-function completely, and instead use simple string substitution:
url = 'https://api.github.com/user/starred/{owner}/{repo}'.format(
owner=GITHUB_USER,
repo=GITHUB_REPO
)
We are using a query as follows:
FROM users u INNER JOIN FETCH u.roles where u.password='" + password + "'" + " AND u.username='" + username + "'";
To prevent sql-injection, we are using regular expression to filter "username" and only allow whitelist of characters such as "^[a-zA-Z0-9]*$" and for "password" field we are using the check such as,
if(password.indexOf("'") != -1) { Sql injection attack }
Is there any ways for attackers to bypass the checks we have used to launch successful sql-injection attack?
We are using MySql v5.1
Thanks,
Seeing as it seems the moderators don't approve of me telling you to improve your code, the answer is simply "Yes, there is a flaw in the above code".
this question might sound a little bit weired... But I will try to explain:
I got an Android App, that makes calls against a RAP-Build Website (to that I only have access via Webbrowser).
Until now I am sending pure HTTP Requests for example:
HttpPost request = new HttpPost(url + ";jsessionid=" + jsessionid
+ "?nocache=" + System.currentTimeMillis()
+ "&org.eclipse.swt.events.widgetSelected=w131"
+ "&requestCounter=" + (requestCounter++) + "&uiRoot=w1"
+ "&w1.cursorLocation.x=282" + "&w1.cursorLocation.y=148");
then I get back a lot of stuff like this:
var wm = org.eclipse.swt.WidgetManager.getInstance(); [...] ;
wm.add( w, "w17", true );[...];w.setCaption( "THIS IS WHAT I NEEED" );
Then I use some complex Regular Expressions to parse what I want and send back another post with the actions.
But to get to my question: Is there an easier way to do this? Does RAP perhaps have a build in API for such external requests oder does a JAVA Library exist, that makes communication with RAP easier.
I hope you did understand my problem - if not please leave a comment and I will try to explain it further.
Thanks!
Here you can see the example "How to provide download link?" You can change the example to work in your way providing custom service handler and using it from the Android App.
I'm trying to write an iPhone offline webapp using jqtouch/jquery. When I disable my connectivity, it looks like the jquery .load() function silently fails and doesn't even call its callback function. I've set $.ajaxSetup ({cache: true}); but it seems to have no effect. I also have my manifest file etc. working fine - the only issue is the .load() function.
Any ideas?
Are you serving your manifest files with the correct MIME type? From JQTouch Offline Support:
Also, the manifest must be served with
a MIME type of text/cache-mainfest,
which you can accomplish on most
servers with a .htaccess directive:
AddType text/cache-manifest .manifest
To implement the Cache Manifest,
simply reference it in your HTML like
this:
<html manifest="sample.manifest">
Turns out they way I was calling .load() was causing it to do a POST instead of a GET, which meant it bypassed the cache.
I called it as
$.('#some-element').load('path/to/data',
[],
function(responseText, status, XMLHttpRequest) {
alert("Load finished: " + status + ". " + responseText);
}
);
I assumed second empty array was the correct invocation, but this made JQuery do a POST, presumably with zero arguments. The correct invocation for a GET is:
$.('#some-element').load('path/to/data',
function(responseText, status, XMLHttpRequest) {
alert("Load finished: " + status + ". " + responseText);
}
);
Local files return 0 as HTTP status code. This is because they are not retrieved with HTTP (it's local!). jQuery treats this as an error, which is not necessarily bad.
Try the onComplete handler to retrieve both status code, compare it to 0 and try to read the response text.
You may also want to test window.navigator.online (onLine?) to check if you're offline (because the status code 0 should only occur when you're offline).