issue with yql (yahoo api's) using oauth - oauth

i am using oauth_util.rb ( https://gist.github.com/383159 ) and my YQL query is
"select * from search.termextract where context=\"#{text}\""
This works where text is a short string, but fails for the longer ones with the following error:
RuntimeError (Please provide valid credentials. OAuth oauth_problem="signature_invalid", realm="yahooapis.com" for text [ Virdhawal Khade Wins Historic Medal | Sports News Bangalore November 16, 2010 -19-year-old Indian swimmer and GoSports Foundation awardee, Virdhawal Khade, has made history at the Guangzhou Games by clinching the Bronze Medal in the Men's 50m Butterfly event. ... Starting the Finals in fifth place, Veer's performance was nothing short of astonishing, as he finished with his season best time of 24.31 seconds. He finished 0.65 seconds shy of first placed 27-year-old Zhou Jiawei, the top ranked Chinese Swimmer who is also ... ]):
Thanx in advance.

got it... needed to use URI.encode to encode the URI instead of CGI::escape

Related

Cognos 11 Analytics

First time posting.
Our fire response agency just moved to Cognos 11 after qRep. I know little to nothing about SQL, modules, cubes, or data analytics, but I'm one of the few in our agency that can write an excel function so I guess I am considered the in-house data expert.
With that in mind, I need some help.
I want to compare a calculated result (time interval) to a static goal. For instance, if the calculated result is 01:00, how do I express a static goal of 01:20 as a time interval to make the calculation work?
Here is the formula I used for my "Static Goal" column:
IF([Inc Cat]='EMS') then ('60')) else
IF([Inc Cat]='FIRE') then ('80')) else
NULL
I need to convert the 60 and 80 above as seconds so I can compare a calculated time interval to these values.
I appreciate any help, but please review the second sentence of this post prior to replying.
Solved. I removed the single quotes and wrote out the complete time.
IF([Inc Cat]='EMS') then (0 00:01:10.000) else
IF([Inc Cat]='FIRE') then (0 00:01:20.000) else
NULL

String.removingPercentEncoding returns nil on particularly large strings

I am building an application that shows events that are near to the user. Some of these events are scraped from the web, and some are posted to my backend from users of the app. The ones that have been posted to the backend by users are returned with a description string property that is URL percent encoded (this has to do with storing emojis in my SQL database, and is a whole other story).
When the events are pulled from my API, some events will have percent encoding while others will not. Typically, when using String.removingPercentEncoding on a string that isn't encoded, nothing in the string changes.
Example:
let example = "This is an example text"
let decodedExample = example.removingPercentEncoding!
print(decodedExample)
The above code returns This is an example text.
Now, with particularly long event description strings that do not have percent encoding, we use the same method and expect that it would just return the same string. What I am finding however, is that calling .removingPercentEncoding on one of these very long strings is actually returning nil. The string in the following example has 3,123 characters.
Example:
print("Encoded event description: ", event.description!)
print("Decoded event description: ", self.event.description.removingPercentEncoding ?? "Decoding failed")
The above code returns:
Encoded event description: The Experience:\nThe Pavel Barber Hockey School is coming to St. Louis May 17th - 19th, 2019! Join head instructor Pavel Barber, a world renown stickhandling and shootout specialist, and friends for an experience that will challenge these young athletes to get better and encourage mental and physical skill development in a fun and creative environment. \nThe Features:\n\n\n4 Hours On-Ice Skill Development: 1 Hour Friday, 2 Hours Saturday, 1 Hour Sunday\n\n\n4 Hours Off-Ice Skill Development w/ Our Floorball+ HKY Training Program: 1 Hour Friday, 2 Hours Saturday, 1 Hour Sunday\n\n\n1 Personal Growth Group Session Saturday and Sunday\n\n\nScrimmage Game on Sunday\n\n\nPavel Barber Jersey and Socks Included\n\n\nLunch Included Saturday and Sunday\n\n\n \nThe Schedule:Friday, May 17th, 2019 - Day 1 - 5:30 pm - 8 pmSaturday, May 18th, 2019 - Day 2 - 7:30 am - 2 pmSunday, May 19th, 2019 - Day 3 - 7:30 am - 12:30 pm*Times and location subject to change. \n \nOther School Info:\n\n\nSpace is limited and will be filled on a first come, first serve basis\n\n\nAge groups include 7-10 year olds, 11-12 year olds, 13-15 year olds\n\n\nSkill Level Requirements - Kids should be proficient in the basics of hockey before attending the school\n\n\nRefund Policy: Refunds will only be allowed 30 days prior to the start of the school. All refunds are subject to a 20% cancellation fee.\n\n\nThis is not an overnight camp. All kids will need to be picked up and dropped off daily.\n\n\nPlease send your child with the following items each day of the school: workout clothes (such as shorts, t-shirt and gym shoes) for the off-ice sessions and sunscreen as there will be some outdoor activity. Water will be available for the players for all on-ice and off-ice training sessions.\n\n\nPavel Barber and Floorball Merch will be available at the school as well, but we recommend adding to your order now to ensure sizing and product availability\n\n\n \nAbout Pavel Barber:Pavel Barber has quickly emerged as one of the most sought after stick handling and skill development insturctors in the world. He is an internet hockey legend for his incredible hands, creative shootout moves and dangles and his skill development work. His YouTube channel has over 23 MILLION views on it and growing. Barber specializes in stick handling, shoout moves and creative skill development for both hockey and floorball. In fact, he is obsessed with it. He has studied talent generation across all fields and enjoys passing on that knowledge and training hockey players of all ages and skill levels.\nIn 2016, Barber was selected to the Team Canada National Floorball team that competed in Riga at the World Floorball Championships. \nBarber is a GoPro sponsored athlete and has played Indoor Hockey and Field Hockey for Team Canada between 2010 and 2015.\nOriginally from Toronto, Barber currently resides in Vancouver (or anywhere he can have a stick and puck/ball in his hands).\n\nPrice: $350 – $450\n\nFor more info, click here: https://www.eventbrite.com/e/pavel-barber-hockey-school-st-louis-registration-46948450078?aff=ebdssbdestsearch
Decoded event description: Decoding failed
Any idea why String.removingPercentEncoding works on typically lengthed strings, but returns nil on very large strings (3,000+ characters)?
I have tried some millions times with random String of length far more than 3,000, and cannot reproduce the same issue.
Your event.description! has a non-escaped percent symbol, which is the reason removingPercentEncoding fails.
...to a 20% cancellation...
The length of the string is irrelevant.
Generally, removingPercentEncoding fails when the original String contains non-escaped percent symbols.
You can check it easily:
let str = "20%"
print(str.removingPercentEncoding ?? "*fail*") //->*fail*
If the original string may contain percent symbols, always applying removingPercentEncoding would not be a good strategy.

Change Amazon Lex Chat bot Time zone

Now,I am integrating my amazon Lex chat bot to my web. I got the time zone issue. Time zone is in US East (N. Virginia). So if I say today, that is based on Virginia time. So I find how to change time zone and the suggestion is to set the x-amz-lex:time-zone request attribute to my region. but I donot know how to do and where to do. PLs help me!! Thanks.
I used simple Template "https://s3.amazonaws.com/aws-bigdata-blog/artifacts/aws-lex-web-ui/artifacts/templates/master.yaml".
I copied the codes from SnippetUrl and paste to my web page. The Chat Bot appear. So how should I pass these request attribute.
this this my chat bot in amazon lex
this is my cloud formation
These codes are from SnippetUrl in CodeBuildDeploy
There may be an option in the template you are using but I can't find it, so here is what you need to know about setting timezones in Lex.
First of all, the only way to change the timezone from the default East US is to use PostContent API or PostText API. They should really have a timezone setting in the Lex Console so you can set the default timezone at least, but they don't.
The correct way:
The AWS SDK is needed to use PostContent API or PostText API to pass the user's input to your Lex chat bot. When passing data to Lex this way, you can include requestAttributes with the user's input, unique ID and session attributes (optional). Here's an example of how you would set the timezone in requestAttributes to Singapore Time:
{
"inputText": "What the user said.",
"requestAttributes": {
"x-amz-lex:time-zone" : "Singapore"
},
"sessionAttributes": null
}
The workaround:
If you cannot use or cannot access the use of PostContent or PostText, then you need to work with what you have. Right now, it looks like you are only using a Lambda function for fulfillment, but you should really also use it for "initialization and validation" too.
This will pass a request to your Lambda function every time Lex processes an input and you can direct Lex with exactly how to reply. This gives you much greater control of your chat bot.
To understand the format of the Request (sometimes called "Event") and how to format the Response in that Lambda function, you will want to read these docs.
Now, Lex processes the date and time from the user's input...(In your example, the user says "today")...and Lex will fill the date or time slots with something like (date) 2018-11-02 (time) 13:00 which will be appropriate for Eastern Standard Time (UTC -5). But Singapore is UTC +8. So you will need to convert that date and time in your Lambda function and overwrite the slots to the equivalent Singaporean time then pass those slots back in your Lambda's response to Lex.
There are multiple ways to do that conversion depending on whether your Lambda is in Node.js or Python and plenty of answers and guides on timezone conversion.
Example:
User Input: "I want to book a meeting room from 1pm to 2pm for today"
To capture the values of this input, your Intent should be set up with something like:
3 slots: {date} {time_start} {time_end}
Intent Utterance: "I want to book a meeting room from {time_start} to {time_end} for {date}"
Lex will then parse the input and fill the slots (using timezone default: East US). Then Lex will pass the request to your "initialization and validation" Lambda Function. The request (or "event") will include:
{
"currentIntent": {
"name": "BookRoom",
"slots": {
"date": "2018-11-05",
"time_start": "13:00",
"time_end": "14:00",
},
},
...
}
Then in the Lambda Function you can take those values (Node.js):
var date = event['currentIntent']['slots']['date'];
var time_start = event['currentIntent']['slots']['time_start'];
var time_end = event['currentIntent']['slots']['time_end'];
Now for your conversion logic:
Since Singapore is 13 hours ahead of East US, just take those times and add 13 hours to them. If when doing that, it passes midnight, then also increase the date by 1 day.
This will work for inputs of "today", "tomorrow", "next tuesday", or even "25 Jan 2035", because Lex parses all of those the same way and simply delivers them to your Lambda in default East US time formatted as (date) yyyy-mm-dd and (time) hh:mm.
After you convert them, just set those slots as the new date and times, then pass the slots back to Lex in your response. Lex will then hold the slot values in Singapore time.
This is the solution image
Finally, I got the solution. If someone want to know the solution check in the photo. I just try to fix the codes from aws github. Thanks.

Query InfluxDB for specific hours every day

What is the best way to query InfluxDB for specific hours every day, for example, I have a Series that have checkin/checkout activities, and I need to see them between hour 2PM - 3PM every day for last month, am aware that there's no direct way to do this on the query language -current version 1.2- Not sure if there is a work around or something ?
I have been searching for the same and found your question. As you say, the syntax does not seem to allow to do it.
My closest attempt was trying to use a regular expression for a time WHERE clausule, which is not currently supported by InfluxDB.
So that should probably be the answer, and I would not post an answer to just say that.
However, working on a different problem, I have found a way that may or may not help you in your specific case. It is a workaround that is not very nice, but it seems to work in the case that you can formulate an aggregation/selection of what you want to see in that given hour so that you end up with having one value per hour. For example, (mean/max/count number of checkin-checkouts in that hour for a given person, which may be what you are looking for, or that you may use to identify the days that you would like to them individually query to see what happened there).
For example, I want to obtain the measurement of electricity consumption daily from 00:00 to 06:00 a.m. I make a first subquery that divides the measurements grouping by 6 hours starting at 00:00 of a given date. Then in the main query, I group by 24 hours and I select the first value. Like this
SELECT first("mean") FROM (SELECT mean("value") FROM "Energy" WHERE "devicename" = 'Electricity' AND "deviceid" = '0_5' AND time > '2017-01-01' GROUP BY time(6h) ) WHERE time > '2017-01-01' GROUP BY time(24h)
If you want 2-4 pm, so 14:00-16:00, you need to first group by 2 hours in the subquery, then offseting the set by 14h so that it starts at 14:00.
SELECT first("mean") FROM ( SELECT mean("value") FROM "Energy" WHERE "devicename" = 'Electricity' AND "deviceid" = '0_5' AND time > '2017-01-01T14:00:00Z' GROUP BY time(2h) ) WHERE time > '2017-01-01T14:00:00Z' GROUP BY time(24h,14h)
Just for checking it. In my 1.2 InfluxDB this is the final result:
Energy
time first
2017-01-01T14:00:00Z 86.41747572815534
2017-01-02T14:00:00Z 43.49722222222222
2017-01-03T14:00:00Z 81.05416666666666
The subquery returns:
Energy
time mean
2017-01-01T14:00:00Z 86.41747572815534
2017-01-01T16:00:00Z 91.46879334257974
2017-01-01T18:00:00Z 89.14027777777778
2017-01-01T20:00:00Z 94.47434119278779
2017-01-01T22:00:00Z 89.94305555555556
2017-01-02T00:00:00Z 86.29542302357837
2017-01-02T02:00:00Z 92.2625
2017-01-02T04:00:00Z 89.93619972260748
2017-01-02T06:00:00Z 87.78888888888889
2017-01-02T08:00:00Z 50.790277777777774
2017-01-02T10:00:00Z 0.6597222222222222
2017-01-02T12:00:00Z 0.10957004160887657
2017-01-02T14:00:00Z 43.49722222222222
2017-01-02T16:00:00Z 86.0610263522885
2017-01-02T18:00:00Z 86.59778085991678
2017-01-02T20:00:00Z 91.56527777777778
2017-01-02T22:00:00Z 90.52565880721221
2017-01-03T00:00:00Z 86.79166666666667
2017-01-03T02:00:00Z 87.15533980582525
2017-01-03T04:00:00Z 89.47988904299584
2017-01-03T06:00:00Z 91.58888888888889
2017-01-03T08:00:00Z 41.67732962447844
2017-01-03T10:00:00Z 16.216366158113733
2017-01-03T12:00:00Z 25.27739251040222
2017-01-03T14:00:00Z 81.05416666666666
If you would need 13:00-15:00, you need to offset the subquery in the previous example by 1h.
For 14:00-15:00:
SELECT first("mean") FROM ( SELECT mean("value") FROM "Energy" WHERE "devicename" = 'Electricity' AND "deviceid" = '0_5' AND time > '2017-01-01T14:00:00Z' GROUP BY time(1h) ) WHERE time > '2017-01-01T14:00:00Z' GROUP BY time(24h,14h)
Hope this helps :)

Formatting Script For Automated Email in Google Spreadsheets

I am a restaurant owner trying to automate the creation of a message to my employees using google spreadsheets.
I have this:
=E2&CHAR(10)&CHAR(10)&"Here are your tip numbers:"&CHAR(10)&CHAR(10)&"Cash Tips: "&I2&" Credit Card Tips: "&J2&" Form 4070's are due in the office by 4pm Wednesday and they are required by law from every tipped employee. Thank you. -- Management Team"
Here are the cell values:
E2 = "Ron"
I2 = "19"
J2 = "25"
Currently, it looks like this:
Ron
Here are your tip numbers:
Cash Tips 19 Credit Card Tips: 25 Form 4070's are due in the office by 4pm Wednesday and they are required by law from every tipped employee. Thank you. -- Management Team
But I would like it to be formatted like this:
Ron,
Here are your tip numbers:
Cash Tips: $19
Credit Card Tips: $25
Form 4070's are due in the office by 4pm Wednesday and they are required by law from every tipped employee.
Thank you.
-- Management Team
Can anyone help an old guy out who has zero experience doing this?
So, I am looking for:
A comma after "Ron"
"Cash Tips:" in BOLD letters
"Credit Card Tips:" in BOLD letters
A "$" sign before the number in the I2 and J2 fields
Lines skipped as noted above.
Partial formatting, for the bold, is unavailable at this time.
This takes care of the rest though:
=E2&","&CHAR(10)&CHAR(10)&"Here are your tip numbers:"&CHAR(10)&CHAR(10)&"Cash Tips: "&"$"&I2&CHAR(10)&CHAR(10)&"Credit Card Tips: "&"$"&J2&CHAR(10)&CHAR(10)&"Form 4070's are due in the office by 4pm Wednesday and they are required by law from every tipped employee."&CHAR(10)&CHAR(10)&"Thank you."&CHAR(10)&CHAR(10)&"-- Management Team"
Update to accommodate the rounding of currency values to 2 decimal places:
=E2&","&CHAR(10)&CHAR(10)&"Here are your tip numbers:"&CHAR(10)&CHAR(10)&"Cash Tips: "&"$"&ROUND(I2, 2)&CHAR(10)&CHAR(10)&"Credit Card Tips: "&"$"&ROUND(J2, 2)&CHAR(10)&CHAR(10)&"Form 4070's are due in the office by 4pm Wednesday and they are required by law from every tipped employee."&CHAR(10)&CHAR(10)&"Thank you."&CHAR(10)&CHAR(10)&"-- Management Team"

Resources