I would like to prefix all URLs in my Meteor app using Iron Router with a random constant string. I am thinking it might make it more secure. How do I do it?
Use Meteor's random package: meteor add random and call Random.id([n]), where n is the length of the random string you want. See documentation for more details.
Related
Hello I am trying to read a module with this code:
(: Entry point - must be a read-only query. :)
xdmp:invoke(
'/path/mydocument.xqy',
(xs:QName('var1'), 'test',
xs:QName('var2'), "response"))
I am new in MarkLogic, I am using groovy and the api to connect to it, but also I saw I can invoke the module with this and indeed I did but it returns me
your query returned an empty sequence
I want to know if I can query xs:QName('var1'), 'test', changing test with a wildcard or how can I get all the information from the file called /path/mydocument.xqy?
I tried to use this:
xdmp:document-get("/path/mydocument.xqy)
but it says the file is not found. Although, if I use invoke I can query it, but I don't know what are the values I have to pass. I was wondering if there is something like sql using %% or something to give me all the data.
To answer the first question: "I am trying to read a module "
IF the module is in the database, then you must query the Modules database in which the module resides.
If the module is in the filesystem then you cannot directly access its source as a document but you can by executing xdmp:filesystem-file()
Simplification:
With the Default configuration of the server and REST client, user placed modules are in the "Modules" database and user placed documents are in the "Documents" database. This means, if you do a GET (read a "Document") with no additional parameters, it will return documents from the "Documents" database. Assuming you are using the default configuration for client and server, this would result in the behavior you are seeing. E.g. your Module code is in the Modules database, doing a GET for it by name will search the Documents database and correctly not find it.
You don't mention, and I don't know, the groovy library being used, but the REST API itself and all implementations of general purpose ML REST client libraries I am familiar with have options for overriding the default database with another. If the groovy library supports that, then specify the "Modules" database for your query and it should return the module document. Note: content-type will be application/text not text/xml.
You can simplify things for testing by bypassing the libraries and simply use a browser and try a URL like this http://yourserver.com:8000/v1/documents?uri=/your/module.xqy&database=Modules
Ref: https://docs.marklogic.com/REST/GET/v1/documents
Making the appropriate changes to the path and server for your use.
If you are still confused, then you should start with the basic MarkLogic tutorials and work through them one by one. You will most likely succeed faster by doing this then jumping straight into coding you don't understand yet.
DETAIL:
Note: The default behaviour is to EXECUTE documents when doing a GET call, using the Modules database. Thus doing a GET of http://yourserver:8000/your/module.xqy will EXECUTE it not return its source.
You will notice the REST API has a uri query parameter. This is EXECUTING the REST API code on /v1/documents which in turn will read the document specified by the uri and database parameters and return it.
I guess I can use:
xdmp:invoke(/pview/get-pview-browse-profiles.xqy,
cts:and-query((
cts:element-value-query(
xs:QName("letter"),"*", "wildcarded"),
cts:element-value-query(
xs:QName("collection"),"*", "wildcarded"))))
although it doesn't return anything
*** Test cases ***
TestDB
Connect To Database Using Custom Params None database='TestDB', user='system', password='system', host='10.91.41.101', port=1521
Please help - the error is:
ImportError: No module named None
The error most probably comes from the way you call Connect To Database Using Custom Params - the first argument you're passing, which should be the value for the dbapiModuleName, is passed as a string object, with the value "None".
If you wanted to call it with the value None object (as it's written in the library's help), that should have been ${None} in robotframework format.
I doubt that's going to work though - the DatabaseLibrary probably needs some DB type identifier. So if you are using postgres for example, you'd call it with "psycopg2":
Connect To Database Using Custom Params psycopg2 database='TestDB', user='username', password='mypass', host='10.1.1.2', port=1521
Have in mind you'd need the DB driver already installed through pip, psycopg2 in the case of the example here.
P.S. please don't paste actual credentials in SO.
I assume your question should have been posted something like this...
Issue
When attempting to execute the following test case in Robot Framework, I receive the following error: ImportError: No module named None
Here is the test case in question:
*** Test Cases ***
TestDB
Connect To Database Using Custom Params None database='TestDB', user='system', password='system', host='10.91.41.101', port=1521
If so, your issue may be as simple as spacing. Robot Framework can accept pipes as delimiters, but if you choose to use spaces, you must use 2 or more.
Based on your copy/paste, it looks like you have only one space between Connect To Database Using Custom Params and None (which, I'm assuming you're specifying as the DB API Python module the system default - not sure if that's recommended or supported). Make sure you have at least two spaces (I generally try for 4 unless I have a lot of parameters) between keywords and their parameters.
So:
Make sure you have at least two spaces between the keyword and parameters. Here is the keyword in question's reference.
Verify that you don't need to specify the Python database driver for the database you are using. Based on the port you've specified, I'm guessing it's an Oracle database. Here's a list of Python Oracle drivers.
I had a similar error and read on it for hours not knowing I hadn't created a .env file yet. credit to a friend who brought me to this page. (which gave me the hint on what I was missing).
I created a .env file in my root folder where the manage.py file is and configured my database settings and voila. Thanks Suraj
When you create a function with Cloud Functions for Firebase you get a url something like this - https://firebase-app.cloudfunctions.net/helloWorld - I want to be able to create a cname to go to a url like this - https://firebase-app.cloudfunctions.net/ - Is it possible to create a "default function" which would give me a root path like that?
If not, will it be possible in the future?
First, you should try to create your own Express app and specify routes through that.
If that's not what you want, please file a feature request to indicate that you're interested in this.
You can also try to fully control you own domain powered by Cloud Functions by using a reverse proxy.
I'm trying to convert beta web-service to live. after removing beta word from the web-service [i.e. in web.config: endpoint address="https://wsbeta.fedex.com:443/web-services/rate"], this web service is not fetching the value. Any suggestions, why this is happening or I'm missing any procedure. Any guidance/suggestions on this.
To move a system from testing to production is not only needed to remove the word beta from the testing URL address:
From:
"https://wsbeta.fedex.com:443/web-services/rate";
To:
"https://ws.fedex.com:443/web-services/rate";
(when doing this change make sure you are replacing ALL occurrences of wsbeta. to ws. in your solution.)
But also you need to change the MeterNumber, include the Password and Key. When you sign up for the Production Key you will get all this information on the email and also you'll get the Key as soon as you sign up (you won't get that key on the email so be careful and write down that information).
With those pieces of information you should be good to go. If you are getting an exception that's a different story, let us know what exception you are getting.
I would like to use httr to link up/upload my R image outputs to flickr, but am having difficulty with the initial stages where i need to authenticate myself using OAuth 1.0.
I previously created an app by going to the following link http://www.flickr.com/services/apps/create/apply/
and then got a secret and key string for that app...
I then used it in the httr package function to get a token but to no avail. I have been trying to use the provided documentation on this link http://www.flickr.com/services/api/auth.oauth.html to help out but, I am struggling...
The following is the code I used.
flickr.app <- oauth_app("flickr",key="xxxxxx", secret="xxxxxxxx")
flickr.urls <- oauth_endpoint(request="http://www.flickr.com/services/oauth/request_token",
authorize="http://www.flickr.com/services/oauth/authorize",
access="http://www.flickr.com/services/oauth/access_token")
flickr.token <- oauth1.0_token(flickr.urls,flickr.app)
from which i get the error message
Error: http client error (400)
Not too sure where to go from here...any help would be much appreciated.
N.B. Also I recognise that due to the nature of setting up api links, that there are secrets , api-keys, logins and passwords that need to be kept secret etc, but it does not take long to set up a dummy flickr account from www.flickr.com , to be able to reproduce the problem...in my opinion...perhaps others could try setting one up and letting me know if they got similar issues, and potential methods to work around the situation?
I have never used the httr library, but I recently (as of yesterday) just finished writing from scratch Objective-C code to access Flickr. The biggest pain point for me was figuring out how to correctly encode the signature. I don't know the httr library well enough, but if I had to guess my guess would be that it is not encoding the signature properly.
If you read through this: http://www.flickr.com/services/api/auth.oauth.html
You will find very detailed instructions on how to authorize with Flickr - it was useful to me because I wrote the code in Objective C from scratch. Might be less useful to you unless you are able to debug through the httr source and figure out if it is doing things exactly as Flickr expects.