print,printto on MAC OS X - c++

I'm trying to call printing of a document from my C++(XCode) application on MAC.I'm currently using Launch Services framework,but I didn't noticed where is printto option(flag).Is this supported by Launch Services at all?Is there some other way to do this?
Thanks,
Marko

According to Technical Note TN2082: The Enhanced Print Apple Event (in the legacy docs), you should be able to specify a keyAEPropData parameter of type kPMPrinterAEType whose value is a PMPrinter reference.
That TechNote is a bit unclear, though. It seems as though the keyAEPropData parameter carries both the print settings and the printer. The receiver can retrieve both pieces of information by coercing the parameter's "actual" value to two different types. That raises the question of whether you can specify the parameter value with just kPMPrinterAEType and have it work, or if it needs to be some other type.
Anyway, you can construct an AEDesc for the parameter and pass it in to LSOpenFromRefSpec() in the passThruParams field of the LSLaunchFSRefSpec structure.
It may help to use the Script Editor to send an enhanced print Apple Event to a test application which then dumps that event. That may clear up how exactly the parameter is constructed, so you can construct it in the same way.

Related

passing custom messages downstream in spring cloud function's MessageRoutingCallback

Hey I m using MessageRoutingCallback to route to a function in spring cloud functions. It needs FunctionRoutingResult for routing. I also wanted to edit the message. The spring cloud docs says.
"Additionally, the FunctionRoutingResult provides another constructor allowing you to provide an instance of Message as second argument to be used down stream".
But the problem is the constructor with Message type in FunctionRoutingResult is internal and cannot be accessed outside.
Am I doing something wrong here. Any insight would be helpful
Couple of things.
As the documentation explains it is made to assist with routing decisions. For example if routing decision should be made based on payload which may need to be temporarily converted.
The reality is that it is a very bad practice to let framework make such decisions based on the payload, since payload is a privileged information. Similar to the letter in the envelope where mailman does not read the actual letter to make proper routing decisions. .. those all come from the envelope itself. So I will actually update the documentation to remove that paragraph.
And it is definitely not there to modify the message. That would be improper use of MessageRoutingCallback. To modify message you can use function composition. For example MessageRoutingCallback you check some header in the incoming message, determined that the function name should be foo but then actually output modifier|foo as function definition.

Django - can I sotre and run code from database?

I build program, when in one part I have some ranking, and I would like to give users option to customize it.
In my code I have a function that gets objects and returnes them packed with points and position in ranking (for now it calculates the arithmetic mean of some object's values).
My question is is it possible to give e.g. admin chance to write this function via admin panel and use it, so if he would like to one day use harmonic mean he could without changing source code?
Yes, you could just store a string in the database and exec() it with suitable arguments...
However, you'll have to be careful – Python code can practically never be sandboxed perfectly. In the event that you accept any arbitrary Python code for this, and someone with nefarious intents gets to your admin panel to change the expression, they can do practically anything.
In other words, don't use raw Python for the code you store.

Dialogflow: Respond based on values and other conditional responses

I have $dinetype variable obtained from the user.
But I would like to give response based on what value has been set in $dinetype variable. In addition to giving responses, I also need to set relevant context. How do I do this in DialogFlow?
if($Dinetype=='dineout')
ask ('which restaurant would you like to go to?')
set_context ('awaiting-restaurant')
if($Dinetype=='takeaway')
ask ('When would you like to take away?')
set_context ('awaiting-takeaway-time')
Is it programmable at all? Or is it possible to achieve something equivalent to the above in the UI?
Edit: A much easier way has been added to handle this issue directly in Dialogflow
(Updated Solution) Follow-up Intents:
After creating an intent, you can add follow-up intents now.
Intents -> Create Intent >
[Response=Prompt For Conditional Response]
Intents -> Add Follow-up Intent -> Custom/Yes/No
Then set the training praise to a matching entity you want to conditionally respond to
  
 
OLD HACKY SOLUTION:
Late reply, but maybe someone will find this useful.
If the conditional response only needs to reference a single parameter
value, then I figured out what you can do is utilize the Entity's
"Reference Value" as the response you want to give for a particular
set of Synonyms.
So you'd have an entity that looked like this:
Then, setup your intent like this, with a response of $Dinetype:
Then the end result will look like this:
And you can make whatever follow-up intent you need from there.
Down-side is Dinetype won't be as reusable. But I still think it
beats writing a fulfillment webhook every time you need a simple
conditional response.
You can't do this in the Response section directly. The Response section is meant for fairly simple responses that don't require significant logic to process. Although you can use parameters in the response, you can't give a different response based on the value of the parameter. So you can set a response to something like
I think $Dinetype is great food.
but not
{{#if $Dinetype == "Thai"}}I think Thai food is too hot{{/if}}
or anything like that
However, you can add code that sends conditional responses and contexts by implementing a Fulfillment webhook. Although you can't do this for each Intent as part of the Intent editor screen, the Fulfillment screen includes a built-in code editor.
I found a solution to my similar problem using composite entities, which may or may not be overkill for your agent. The value assigned to a parameter associated with the (composite) entity will contain a JSON structure, if a synonym in that entity was matched.
Using the "Dot" notation, you can assign the matched sub-entity's property (similar to the reference value of a normal entity) to another parameter in the Actions and Parameters section. You can have one parameter for each sub-entity and hence, you can evaluate these parameters in your response section to select each response variants:
$Parameter_A ResponseA
$Parameter_B ResonseB
....
etc.
Clunky but works. Just have to be careful to reference the property exactly as it is defined in the composite entity.

How to define a Lex slot type(custom /built in ) that will accept any given value?

I have slot name "remark". I need a slot type which takes any value given by user to this field.
Amazon support staff have responded to similar questions in this way:
From aws dev forum:
The recommended approach for capturing free form text through a slot is to create a custom slot type, and provide enough representative sample/training data as slot values. This will allow Lex to learn from these samples, and recognize a much larger set.
So in your slot value samples, you should add single words, multiple words, and even whole sentences if that is what you expect. This lets Lex know and learn the wide range of data to fill the slot with.
The more sample values you give, the better Lex should be.
I have had the same problem, and firstly I tried to proviode wide range of training data but whenever I typed something new it never got captured correctly in the Lex.
So I created a slot without any value and unchecked the required checkbox (important). Then I enabled Lambda initialization and validation hook so that it goes to DialogCodeHook.
In the backend code, in DialogCodeHook, I grabbed the input of user from event['inputTranscript'] and assigned that value to the slot.
Hope it helps.
I have been working on lex platform for more than a year now. As per my understanding, it is not possible to capture free text as a slot. The approach to add more training data only to handle free text will make the slot (as thus the intent) greedy and have an negative impact on the overall performance of the bot.
The best alternative (in case of custom channel only) is to make use of session attributes to pass free text from the chat interface and pass a pre defined text (one of the values from slot) as input to lex; write logic in lambda to capture the free text from session attributes.
Let me know if you need more clarity.
You can use the AMAZON.AlphaNumeric inbuilt slot type

TMG SF_NOTIFY_POLICY_CHECK_COMPLETED Event

According to http://msdn.microsoft.com/en-us/library/ff823993%28v=VS.85%29.aspx, during this event the web filter can request GUID of the matching rule. I am assuming that is done by performing a GetServerVariable with type of SELECTED_RULE_GUID, since I could find no other readily identifiable means of doing so.
My problem comes from the fact that I want to see if the rule is allowing or blocking the request. If it's being blocked then my filter doesn't have to take any action, but if it's being allowed I need to do some work. SF_NOTIFY_POLICY_CHECK_COMPLETED seems to be the best event to watch, since it occurs last enough that authentication and various ms_auth traffic has been handled, but just before the request either gets routed or fetched from cache.
I had thought that perhaps I needed to use COM and the IFPC interfaces (following along with example code for registering Web Filters to TMG) to get details on the rule. However, going down via FPC -> FPCArray -> FPCArrayPolicy -> FPCPolicyRules, the only element-returning function takes either an index or a name.
Which is problematic given that I only have a GUID.
The FPCPolicyRule object (singular) doesn't seem have any field related to GUID either, which eliminates just iterating over the collection for it.
So my question boils down to, from the SF_NOTIFY_POLICY_CHECK_COMPLETED event, how would a web filter determine if the request has been allowed or denied?
After more investigation and testing, the GUID is accessible via the PersistentName of the FPCPolicyRule object. Since FPCPolicyRules->Item member only works on either Name or Index, I had to iterate through its items comparing each PersistentName against the GUID.
Apologies if this was obvious, took me a good day to work out :)