I have been working on my webpage, created in a Jekyll template and hosted by Github.
When I try to include the date in the YAML of a .rmd document, the commit fails. There is no error message, but it does not update the webpage.
This YAML is failing.
---
title: "My Title"
author: "Author"
date: "`r format(Sys.time(), '%d %B, %Y')`"
layout: default
permalink: /pages/Folder/Name/
output: html_document
---
However, when I try to add the date as the author, it appears without any problem (i.e., the commit is successful, and the page is updated).
---
title: "My Title"
author:
- "Author"
- "`r format(Sys.time(), '%d %B, %Y')`"
layout: default
permalink: /pages/Folder/Name/
output: html_document
---
So, the last option works, but it is not cooler.
Could someone tell me what document should I modify? I have tried multiple formats for:
date: "April 20, 2017"
'r format(Sys.time(), '%d %B, %Y')'
Thanks in advance.
Related
I'm using https://mikefarah.gitbook.io/yq/ . How can I filter a list of dictionaries by a particular value in a list under a particular key? In the example below I want to filter the layouts list by condition "iso3166 list contains value 'GB'".
Example
Yaml output (condensed) from xkbcli list with one model and three layouts
models:
- name: pc86
vendor: Generic
description: Generic 86-key PC
layouts:
- layout: 'ch'
variant: ''
brief: 'de'
description: German (Switzerland)
iso639: ['deu', 'gsw']
iso3166: ['CH']
- layout: 'gb'
variant: 'gla'
brief: 'gd'
description: Scottish Gaelic
iso639: ['eng', 'gla']
iso3166: ['GB', 'CA']
- layout: 'gb'
variant: 'colemak'
brief: 'en'
description: English (UK, Colemak)
iso639: ['eng']
iso3166: ['GB']
Desired output: the two 'GB' layouts
- layout: 'gb'
variant: 'gla'
brief: 'gd'
description: Scottish Gaelic
iso639: ['eng', 'gla']
iso3166: ['GB', 'CA']
- layout: 'gb'
variant: 'colemak'
brief: 'en'
description: English (UK, Colemak)
iso639: ['eng']
iso3166: ['GB']
So far I've tried yq ".layouts"
Use map and select.
# Selects by .layout
yq '.layouts | map(select(.layout == "gb"))'
# Selects by .iso3166[]
yq '.layouts | map(select(.iso3166[] == "GB"))'
- layout: 'gb'
variant: 'gla'
brief: 'gd'
description: Scottish Gaelic
iso639: ['eng', 'gla']
iso3166: ['GB', 'CA']
- layout: 'gb'
variant: 'colemak'
brief: 'en'
description: English (UK, Colemak)
iso639: ['eng']
iso3166: ['GB']
You need to use select on the iso3166 list to see if a match for "GB" is present. To update the original layouts list back use |= instead of just |
yq '.layouts | map(select( .iso3166[] == "GB" ))'
Note: Since 4.18.1, yq's 'eval/e' command is the default command and no longer needs to be specified.
I test my Api with DREDD against it's specification (written in Openapi3 considering, painfull limitations of Support by Dredd considered). No I have one endpoint, which produces CSV-data if the Accept-header is set so.
'/my-endpoint':
summary: ...
description: ...
get:
# parameters:
# -
# in: header
# name: Accept
# description: "Response format: application/json or text/csv"
# example: "text/csv"
responses:
'200':
description: ...
content:
text/csv:
schema:
type: string
example:
summary: 'csv table'
value: 'cell1, cell2'
When I run the test with Dredd the test fails with
expected:
headers:
body:
[
{
"key": "summary",
"value": "csv table"
},
{
"key": "value",
"value": "cell1, cell2"
}
]
statusCode: 200
Clearly there is something misunderstood and Dredd expects still JSON. Also the API is not told to produce the CSV Version. If I commit in the Accept header in the code abvoe I get the very same result - the expecetd result above and as actual result the JSON version of the my-endpoint-data and also ad warning:
warn: API description parser warning in .../tmp/transformed.specs.yml: 'Parameter Object' 'name' in location 'header' should not be 'Accept', 'Content-Type' or 'Authorization'
I read here and here: Header parameters named Accept, Content-Type and Authorization are not allowed. To describe these headers, use the corresponding OpenAPI keywords - but what are they? According to this and this page it seems to be enough to specify a response of the given type but that is clearly not enough to tell Dredd to produce such a header.
You got an error because the value of the example key is meant to be a literal example value. So in your case it's treated as an object with the summary and value properties.
Change your definition to:
content:
text/csv:
schema:
type: string
example: 'cell1, cell2'
Or if you want to provide a summary/description for an example, use examples instead:
content:
text/csv:
schema:
type: string
examples:
csv table:
summary: A CSV table with 2 cells
value: 'cell1, cell2'
I'm using OpenAPI to Document a Microprofile application. As the Endpoint contains a large set of methods, I'd like to know if it's possible to filter through the /openapi REST, so that it returns just a specific Path, for example "/users".
Thanks
You can have multiple paths selected. In openapi file the whole path section is called "paths" (so even the name is plural). If you're not sure how to use it, walk through openapi's in the "search" section of Swagger portal (you need to be logged in for this).
Example:
paths:
/{users}:
options:
security:
summary: "Temp summary"
description: "Temp description"
tags:
- "TAG"
parameters:
..
/test/{table}:
options:
security:
summary: "Temp summary"
description: "Temp description"
tags:
- "TAG"
parameters:
..
/test2/user/{id}:
options:
security:
summary: "Temp summary"
description: "Temp description"
tags:
- "TAG"
parameters:
as per our use case we found this to be working.
Annotate your endpoint with #Operation and add a hidden = true parameter to the annotation.
Here in Kotlin:
#GET #Path("/{id}")
#Operation(
summary = "your summary",
hidden = true
)
fun getDataset(#RestPath id: String): Response {
....
}
I am trying to send HTML file in email body itself (not attachment). I have written Jenkins declarative pipeline as follows
post {
always {
presendScript: "def reportPath=build.getWorkspace().child("target/serenity-summary.html")
msg.setContents(reportPath.readToString(), "text/html")"
emailext attachmentsPattern: "Serenity_Test_Results${env.BUILD_NUMBER}.zip" ,
body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} More info at: ${env.BUILD_URL}Unzip the attached document and click on index.html to view complete test results",
subject: "API Testing: Jenkins Job Results - Build # ${env.BUILD_NUMBER} - Failed",
mimeType: 'text/html',to: "xyz#abc.com"
}
}
I am getting error as follows
WorkflowScript: 30: expecting anything but ''\n''; got it anyway # line 30, column 102.
target/serenity-summary.html")
^
1 error
I need to attach the HTML file to email body itself and I need proper presend script in post section.
I think you made a wrong usage of pipeline step emailext. You can try as following.
post {
always {
emailext(
to: "xyz#abc.com",
mimeType: 'text/html',
attachmentsPattern: "Serenity_Test_Results${env.BUILD_NUMBER}.zip",
subject: "API Testing: Jenkins Job Results - Build # ${env.BUILD_NUMBER} - Failed",
presendScript: 'def reportPath=build.getWorkspace().child("target/serenity-summary.html");msg.setContents(reportPath.readToString(), "text/html")',
body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} " +
"More info at: ${env.BUILD_URL}Unzip the attached document and click on index.html to view complete test results"
)
}
}
I have a text file where I have to read the content and append to it. i.e. make a copy of the file and append to it. I wrote the following code
#!/usr/bin/perl
use strict;
use warnings;
my $line;
open FILL, ">> fred"
or warn "Cannot open : $!";
while(<FILL>){
# s/^Author:.*/Author: Randal L. Schwartz/;
# s/^Phone:.*\n//;
# s/^Date:.*/Date: $date/;
$line.=$_;
print $line;
}
select FILL;
print $line;
But it doesn't enter the while loop at all and when I open a filehandle for the same file in read mode and select the file handle in append mode to print it works.
Input :
Program name: granite
Author: Gilbert Bates
Company: RockSoft
Department: R&D
Phone: +1 503 555-0095
Date: Tues March 9, 2004
Version: 2.1
Size: 21k
Status: Final beta
Output :
Program name: granite
Author: Gilbert Bates
Company: RockSoft
Department: R&D
Phone: +1 503 555-0095
Date: Tues March 9, 2004
Version: 2.1
Size: 21k
Status: Final beta
Program name: granite
Author: Gilbert Bates
Company: RockSoft
Department: R&D
Phone: +1 503 555-0095
Date: Tues March 9, 2004
Version: 2.1
Size: 21k
Status: Final beta
This program works correctly
#!/usr/bin/perl
use strict;
use warnings;
my $line;
open FIL, "fred"
or warn "Cannot open : $!";
open FILL, ">> fred"
or warn "Cannot open : $!";
while(<FIL>){
# s/^Author:.*/Author: Randal L. Schwartz/;
# s/^Phone:.*\n//;
# s/^Date:.*/Date: $date/;
$line.=$_;
print $line;
}
select FILL;
print $line;
It appends correctly in file but the terminal output is
Program name: granite
Program name: granite
Author: Gilbert Bates
Program name: granite
Author: Gilbert Bates
Company: RockSoft
Program name: granite
Author: Gilbert Bates
Company: RockSoft
Department: R&D
Program name: granite
Author: Gilbert Bates
Company: RockSoft
Department: R&D
Phone: +1 503 555-0095
Program name: granite
Author: Gilbert Bates
Company: RockSoft
Department: R&D
Phone: +1 503 555-0095
Date: Tues March 9, 2004
Program name: granite
Author: Gilbert Bates
Company: RockSoft
Department: R&D
Phone: +1 503 555-0095
Date: Tues March 9, 2004
Version: 2.1
Program name: granite
Author: Gilbert Bates
Company: RockSoft
Department: R&D
Phone: +1 503 555-0095
Date: Tues March 9, 2004
Version: 2.1
Size: 21k
Program name: granite
Author: Gilbert Bates
Company: RockSoft
Department: R&D
Phone: +1 503 555-0095
Date: Tues March 9, 2004
Version: 2.1
Size: 21k
Status: Final beta
Program name: granite
Author: Gilbert Bates
Company: RockSoft
Department: R&D
Phone: +1 503 555-0095
Date: Tues March 9, 2004
Version: 2.1
Size: 21k
Status: Final beta
Why does it print so many times?
$line is the variable in which you accumulate everything read so far. So within the loop, you probably wanted to do
print $_;
or just
print;
instead of
print $line;
To answer your original question... You will want to open the file in both read and write (append) mode.
open FILL, '>>+', 'fred';
(Please don't use the 2-argument version of open. It's unsafe.)
But this places the file pointer at the end of the file, so you'll have to do a
seek FILL, 0, 0;
before reading. Since you read before writing, it makes no difference whether or not you open the file in append mode.
You should even be able to add another seek after reading the file, but I am not sure whether this is going to be portable across Unix and Windows.