Change figure and table captions in blogdown - hugo

I'm tinkering with blogdown and would like to create figures and table with non-English caption headers. The following chunk
```{r label1, echo=FALSE, fig.cap="Fancy caption", fig.fullwidth=TRUE}
plot(1,1)
```
produces the plot and a caption that reads
Figure 1: Fancy caption
I'd like to be able to change the label such that, say, "Figure" becomes "Plot". I thought I could fix it in the same way as for bookdown: In the _bookdown.yml file I could have
language:
ui:
chapter_name: "Chap "
appendix_name: "App "
label:
fig: 'Plot '
tab: 'Fancy table '
but I'm not sure how to do something similar with a Hugo-based setup from blogdown. How can I add the above information to, say, the config.toml file or set it somewhere else?

First, store the _bookdown.yml file you described in the same folder as the blog post source .Rmd file, e.g. content/post/_bookdown.yml if your file is at content/post/my_post.Rmd.
Then, add _bookdown.yml to the list of ignoreFiles in your config.toml so that Hugo doesn't move _bookdown.yml to the public directory.
This works because blogdown::html_page() is based on bookdown::html_document2(), which will pick up the _bookdown.yml in the same directory of the source Rmd. I don't think it's possible to set this globally from your blogdown root dir, but if you store all your posts in content/post it's basically the same thing.

Related

How to move files in Google Drive automatically with Google Script, based on partial file name?

I'm rather new to Google Scripts. We are wanting to make all files uploaded to a single folder in Google Drive be automatically moved to other folders, based on part of their file name.
3 example files: APX PMT 05.02.2019, ALT PMT 05.03.2019, BEA PMT 05.04.2019
We want these files to be moved to their destination folders based on the first 3 letters of their file name. APX PMT 05.02.2019 gets moved to the APX folder, ALT PMT 05.03.2019 gets moved to the ALT folder, ect.
Do not have code samples as I'm extremely new to this. Move files automatically from one folder to another in Google Drive is a good start on me learning this, but still unsure how to make it move file based on only part of the file name.
Results: Wanting people to be able to upload files to a single destination, and the code auto moves them to their proper folders.
Test Code version 2.0 . Works as below if I remove the spaces between the 2 character sets (change BEA RFT to BEARFT or BEA_RFT) , as our workplace would like them sorted by the first 7 characters in the file name now. How can i make it work when there is a space in the characters?:
function moveFiles() {
var dfldrs=['BEA RFT', 'BEA ADJ', 'BEA PMT', 'BEA CHG'];//Seven letter prefixes
var ofObj={BEA RFT:'ID',BEA ADJ:'ID',BEA PMT:'ID',BEA CHG:'ID'};//distribution folder ids
var upldFldr=DriveApp.getFolderById('ID');
var files=upldFldr.getFiles();
while(files.hasNext()) {
var file=files.next();
var key=file.getName().slice(0,7);
var index=dfldrs.indexOf(key);
if(index>-1) {
Drive.Files.update({"parents": [{'id': ofObj[key]}]}, file.getId());
}
}
}
Moving Files
Please, Read these instructions before running script
You need to provide the three letter prefixes
You need to provide the distribution folder ids associated with each prefix
You need to provide the upload folder id
You need to run this program from your upload file script or provide an alternate trigger function as you desire.
You need to enable Advance Drive API version 2
The Code
function moveFiles() {
var dfldrs=['APX','ALT','BEA'];//Three letter prefixes
var ofObj={APX:'APX id',ALT:'ALT id',BEA:'BEA id'};//distribution folder ids
var upldFldr=DriveApp.getFolderById('folderid');
var files=upldFldr.getFiles();
while(files.hasNext()) {
var file=files.next();
var key=file.getName().slice(0,3);
var index=dfldrs.indexOf(key);
if(index>-1) {
Drive.Files.update({"parents": [{"id": ofObj[key]}]}, file.getId());
}
}
}
Drive API Reference

How to download an Interactive Report as a Word (.doc) file?

I am new to Oracle Apex 5.1, and I have been asked to implement a button that when clicked, the user gets (downloads) a .doc file of an Interactive report.
I have noticed that the Interactive Report gives you the option to download it as .pdf, .xls, and so, but I need it to be a Word (.doc) file.
In addition, the file must be in a specific format (with heading, indentation, font, etc.) that I was given (as a template) in a Word file.
Any help would be appreciated.
Additional Information: I was able to open the template (.doc) file in NotePad++ and get the <html> version of it, so I could edit it in both NotePad++ and Word.
One of the best actually to do that is APEX OFFICE PRINT(AOP) but isn't free licence.
otherwise you can check this solution
How do we export a ms-word (or rtf) document (from a web browser) to generated by pl/sql?
I end up finding information in this page: http://davidsgale.com/apex-how-to-download-a-file/ and I wrote this code:
declare
l_clob clob;
begin
l_clob := null;
sys.htp.init;
sys.owa_util.mime_header('application/vnd.ms-word', FALSE,'utf-8');
sys.htp.p('Content-length: ' || sys.dbms_lob.getlength( l_clob ));
sys.htp.p('Content-Disposition: inline; filename="test_file.doc"' );
sys.owa_util.http_header_close;
sys.htp.p(SET_DOC_HEADER);
sys.htp.p(SET_TABLE_HEADER);
sys.htp.p(ADD_TABLE_ENTRY("arguments"));
sys.htp.p(SET_TABLE_FOOTER);
sys.wpg_docload.download_file(l_clob);
apex_application.stop_apex_engine;
exception when others then
--sys.htp.prn('error: '||sqlerrm);
apex_application.stop_apex_engine;
end;
It works, but I had to create functions in the SQL Workshop because writting a table in html is really long.

Saltstack: Transfer multiple files (using wildcard?)

I'm new to Staltstack and I'm starting to do some tests with it, however, I'm facing a small issue and I cant find how to solve it.
I would like to transfer all the files inside a path on the master to a slave, however, I can't get it to work.
Configuration:
/destination_path_on_slave/*:
file.managed:
- source: salt://path_on_master/*
- user: root
However, when trying to apply this, I get the following error:
----------
ID: /destination_path_on_slave/*
Function: file.managed
Result: False
Comment: Source file salt://path_on_master/* not found
Changes:
----------
Any clue about how to get this working?
The destination path exists. Thank you.
I think the module you're looking for is file.recurse. It's used to recurse through a set of files whereas file.managed is for a single file.

Renaming Xcode Header and Implementation files

I was wondering if, in Xcode, it was possible to find and change all references to the name of a header file, and chage it with something else and still have it work, what I mean is find a name like this: , and have it find all references to it like this: , and this: and replace them with the new name. Thank you
You can rename a class with the "Refactor" function in Xcode:
Select the class name "BlueJaysViewController" in "#implementation BlueJaysViewController".
Choose Edit -> Refactor -> Rename ...
Enter the new class name and select "Rename related files"

getting the file in a sub-folder # Isolated Storage - WP7

I would like to get all the files that a sub-folder holds in a string array.
So, I have tried something like the following:
var IOstore = IsolatedStorageFile.GetUserStoreForApplication();
string searchpath = System.IO.Path.Combine("product", ProductName);
string filesInSubDirs[] = IOstore.GetFileNames(searchpath);
But I got all the files in the "product" folder. I have also tried with "productname" only as the parameter.
Thanks for your help.
The search pattern for a sub-folder needs to include "*.*" at the end to pattern match any file, which would make your code something like the following:
var IOstore = IsolatedStorageFile.GetUserStoreForApplication();
string searchpath = System.IO.Path.Combine("product", ProductName);
searchpath = string.Format("{0}\\*.*", searchpath);
string filesInSubDirs[] = IOstore.GetFileNames(searchpath);
Something you might want to try. (this is sort of a left field answer, sorry). In my dropbox client http://sharpdropbox.codeplex.com/) I have a set of facades for System.IO.File, System.IO.FileInfo, System.IO.Directory, and System.IO.DirectoryInfo. They work pretty good and I have tested them.
Basically, you add a Using or Import for System.IO.IsolatedStorage and then PSFile, PSDirectory, PSFileInfo, or PSDirectoryInfo. It's saved me from having to remember all the nuances... for instance if you are querying a directory, it knows to add a slash, etc. BTW, the "PS" prefix stands for "Persisted Storage" which is what IsolatedStorage is sometimes called (starting them with an "I" implies they are interfaces.. and having no prefix makes things even more confusing).
Anyway, you can grab the code from source or I believe the last release had the DLLs for them (it's called something like "IsolatedStorageFacade-WP7")

Resources