GmailApi - search mails newer then minutes - java

Simple question:
Is it possible to search for mails that are newer then, say, 5 minutes using GMailApi?
The newer_then samples I found only have a day-resolution.
Update
I tried something like
mService.users().messages().list(user).setQ("after:2017/05/02 17:00:00").execute();
without any success.

Try using a timestamp as the after value:
1493761547 secs (2017/05/02 21:45)
5 mins is 300 sec
.setQ()"after:1493761247"

Related

Get all items of the last 15 minutes in DynamoDB

As I come from RDBM background I am bit confuse with DynamoDB, how to write this query.
Problem : need to filter out those data which is more than 15 minutes.
I have created GSI with hashkeymaterialType and createTime (create time format Instant.now().toEpochMilli()).
Now I have to write a java query which gives those values which is more than 15 minutes.
Here is an example using cli.
:v1 should be the material type I'd that you are searching on. :v2 should be your epoch time in milliseconds for 30 mins ago which you will have to calculate.
aws dynamodb query \
--table-name mytable \
--index-name myindex
--key-condition-expression "materialType = :v1 AND create time > :v2" \
--expression-attribute-values '{
":v1": {"S": "some id"},
":V2": {"N": "766677876567"}
}'

Time spent on each chrome tab/website from data stored in History sqlite

I am trying to find out the time spent on each tab/website by the user.
For example if I visited youtube and watched it for 10 minutes then I should be able to see something like this
www.youtube.com ---> 10 minutes
I already made a connection with sqlite database i.e. History file present in chrome directory and was able to run the following sql command to fetch the data:
SELECT urls.id, urls.url, urls.title, urls.visit_count, urls.typed_count, urls.last_visit_time, urls.hidden, urls.favicon_id, visits.visit_time, visits.from_visit, visits.visit_duration, visits.transition, visit_source.source FROM urls JOIN visits ON urls.id = visits.url LEFT JOIN visit_source ON visits.id = visit_source.id
So can anyone tell me which combination of column can i use to get the time spent on each website.
Please note that: visit_duration is not giving me appropriate data.
visit_duration Stores duration in microseconds, you need to convert and format that number. Here is one way to show a human-readable visit duration:
SELECT urls.url AS URL, (visits.visit_duration / 3600 / 1000000) || ' hours ' || strftime('%M minutes %S seconds', visits.visit_duration / 1000000 / 86400.0) AS Duration
FROM urls LEFT JOIN visits ON urls.id = visits.url
Here is a sample output:
URL
Duration
http://www.stackoverflow.com/
3 hours 14 minutes 15 seconds
You can also use strftime if you want more format options

Why would a JUnit Test fail between 12 - 1pm during Jenkins deployment?

I have a JUnit test that looks for a user that hasn't changed their password in the past 355 days. In the test, I save a user with their last password update date to the system's date/time - 355 days. Then I run the function that should pick up that user for additional processing.
The test passes locally, both when the test is run on its own AND when the entire test suite is run. However, for some reason, the test fails between 12 - 1pm when deploying our code in Jenkins. It's not a consistent failure, either. Sometimes, simply running the deployment again with no changes allows the test to succeed. What could be causing this issue?
For reference, the test looks like:
#Test
public void passwordExpiryTest() {
Timestamp currentTimeMinus355Days = new Timestamp(System.currentTimeMillis() - 30672000000L);
createUser("expiringUser", currentTimeMinus355Days);
createUser("recentUser", new Timestamp(System.currentTimeMillis() - 864000000L));
List<User> passwordExpiringUsers = userDao.getUsersWithPasswordExpiringInTenDays();
Assert.assertEquals(1, passwordExpiringUsers.size());
}
And userDao.getUsersWithPasswordExpiringInTenDays is a SQL query (into a Postgres table):
SELECT * FROM users WHERE last_password_update IS NOT NULL AND EXTRACT(epoch FROM (NOW() - last_password_update))/86400 >= 355 AND EXTRACT(epoch FROM (NOW() - last_password_update))/86400 <= 356")
I would investigate the logic in userDao.getUsersWithPasswordExpiringInTenDays(). The concept of a "day" depends on an interpretation - is it 24 hours, or the next day number (e.g. 11 vs 12 of April?)? And is there an impact of time zones? e.g. are you testing in India, but the server lives in the US (12 hours time difference?)

Spring SimpleTriggerContext get proper nextExecutionTime

I have job that will run every 10 mins. I don't want to use Spring Scheduler based on last job run next job will schedule to run. Suppose First job ran at 10:15 AM, Subsequent job needs to run at 10:25 AM. When i googled i saw posts with nextExecutionTime. When i use nextExecutionTime my subsequent job is running at 10:20 instead of 10:25. Below is my code, Can any one give an idea how i can run my job at exact 10 mins from last run.
CronTrigger trigger = new CronTrigger("0 0/10 * * * ?");
SimpleTriggerContext triggerContext = new SimpleTriggerContext();
triggerContext.update(Date.from(ZonedDateTime.now().toInstant()), Date.from(ZonedDateTime.now().toInstant()), Date.from(ZonedDateTime.now().toInstant()));
Date nextFireAt = trigger.nextExecutionTime(triggerContext);
System.out.println(nextFireAt);
Can you try the below. I provide below the sequence.
Get the date now.
Add 10 mins to the date and get a new updated date
Update the like triggerContext.update(null, null, date in which you have added 10 mins);

DNS Java no text format defined for TSIG

I am using the Master class in the DNS Java library to parse bind zone files. However, when I try to parse the .BIZ zone file from Neustar, I get this error:
org.xbill.DNS.Tokenizer$TokenizerException: 486: no text format defined for TSIG
I would catch this exception and just continue processing entries but the TokenizerException class is not accessible outside the package so I am not able to catch it. I am calling zoneFileRecord.rdataToString() for each record.
Their file contains TSIG entries that look like this:
4h039a453.biz. 3600 IN NS ns1.rbe1.g-srv.net.
monitor.reg.neustar.com. 0 ANY TSIG hmac-md5.sig-alg.reg.int. 1553302104 300 16 YWDHVhM3MpeTglOvyaj5fA== 27955 NOERROR 0
4h039a453.biz. 3600 IN NS ns2.rbe1.g-srv.net.
4h06-ro1eyrm9.biz. 3600 IN NS ns1.gm111.parklogic.com.
4h06-ro1eyrm9.biz. 3600 IN NS ns2.gm111.parklogic.com.
dnsjava supports TSIG records, but it looks like constructing it from string representation wasn't implemented. There's an issue logged to fix the library: https://github.com/dnsjava/dnsjava/issues/38

Categories

Resources