Skip to content

Instantly share code, notes, and snippets.

View mauriciofs's full-sized avatar

Maurício Ferreira da Silva mauriciofs

View GitHub Profile
@mauriciofs
mauriciofs / pairPalindrome.php
Created July 8, 2017 12:42
Palindrome problem solution.
declare(strict_types=1);
/**
* Resolution to the problem:
* Five Dwarves ( Gimli Fili Ilif Ilmig and Mark) met at the Prancing Pony and played
* a word game to determine which combinations of their names resulted in a palindrome.
* Write a program in that prints out all of those combinations
* */
//Class to pipe functions for better readability
@mauriciofs
mauriciofs / query.json
Created June 6, 2017 13:52
Elasticsearch query with date range, company id and tracker id filter
{
"sort": [
{
"_script": {
"type": "number",
"script": {
"lang": "painless",
"inline": "def date = LocalDateTime.ofInstant(Instant.ofEpochMilli(doc.start_date_time.value), ZoneId.of(\"+01:00\")); return Integer.parseInt(date.format(DateTimeFormatter.ofPattern(\"yyyyMMdd\")))"
},
"order": "asc"
My mapping template is defined this way for the above field:
curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -H "Postman-Token: c5cae459-7bcb-55fa-ad4d-593aa5a5c289" -d '{
"template" : "journeys-*",
"settings" : {
},
"mappings": {
"journeys": {
receive(){
//Arrow function to not change this context
return new Promise((resolve, reject) => {
let params = {
QueueUrl: this.url,
WaitTimeSeconds: this.waitTimeSeconds,
MaxNumberOfMessages: this.maxNumberOfMessages,
MessageAttributeNames: [
'reprocess'
]
receive(){
//Arrow function to not change this context
return new Promise((resolve, reject) => {
let params = {
QueueUrl: this.url,
WaitTimeSeconds: this.waitTimeSeconds,
MaxNumberOfMessages: this.maxNumberOfMessages,
MessageAttributeNames: [
'reprocess'
]