Is it possible to replace placeholders from one configuration source with values from another in Microsoft.Extensions.Configuration? - asp.net-core

Let's say I have JSON configuration files where multiple entries have placeholders like these:
"fooUri": "https://{DOMAIN}/api/fooResource",
"userId": "{USER_GROUP}_{USER_NAME}"
I'd like to replace the {PLACEHOLDERS} with values from other configuration sources, e.g. environmental variables.
Right now, the easiest way I see is to:
Build an IConfiguration from the JSON files.
Build a separate IConfiguration from environmental variables.
Recursively iterate through all values in the first configuration and replace the placeholders with values from the second.
Is there a simpler way to do this easily with the Microsoft.Extensions.Configuration API?
Support for automatic replacement in case of JSON file change would also be nice.

Related

Define variables per folder in dbt

I'm trying to have a structure to run a dbt project, where I have multiple entities (bank, names, cars). I'm going to have exactly the same code for them all.
Based on that, I'm trying to have several folder with the same code, where I can define inside the dbt_project.yamlfile. The idea is something like this:
vars:
db_name: 'db_official'
staging:
bank: 'variable_bank'
car: 'variable_car'
name: 'variable_name'
The variable "db_name" works. So, my the two problems I'm having are:
How to have this structure inside the the yaml file?
How to reference this structure inside each file?
(extra) Any other ideas how to handle this?
Thanks!
vars are basically globals. They can be scoped to your whole project, or to a package within your project, but not more specifically than that (they share a flat namespace). See the docs.
I would pull out the common code into a macro, then call that macro from each model file, passing in the unique values as string literals in the model file:
-- models/staging/bank.sql
{{ my_model_template('variable_bank') }}
-- models/staging/car.sql
{{ my_model_template('variable_car') }}

Is there a way to list the directories in a using PySpark in a notebook?

I'm trying to see every file is a certain directory, but since each file in the directory is very large, I can't use sc.wholeTextfile or sc.textfile. I wanted to just get the filenames from them, and then pull the file if needed in a different cell. I can access the files just fine using Cyberduck and it shows the names on there.
Ex: I have the link for one set of data at "name:///mainfolder/date/sectionsofdate/indiviual_files.gz", and it works, But I want to see the names of the files in "/mainfolder/date" and in "/mainfolder/date/sectionsofdate" without having to load them all in via sc.textFile or sc.Wholetextfile. Both those functions work, so I know my keys are correct, but it takes too long for them to be loaded.
Considering that the list of files can be retrieve by one single node, you can just list the files in the directory. Look at this response.
wholeTextFiles returns a tuple (path, content) but I don't know if the file content is lazy to get only the first part of the tuple.

Jmeter : Number of active threads

I am using jmeter in elemetery freya (14.04)
I have a jmeter test plan with view results tree
I am trying to generate a csv file in view results tree including the number of active threads field.
It appears to me that the detail is being entered in the result.csv file, but the values representing this attribute has no field name, and hence that detail cannot be used in a graph which I want to create from the result.csv
I have changed JMETER-INSTALL-DIR/bin/jmeter.properties according to https://jmeter-plugins.org/wiki/PluginInstall/#Configure-JMeter
How can I get a result.csv file with a suitable fieldname like "active-threads"
Don't change anything in jmeter.properties file, upgrade to new JMeter version will discard your changes. Use user.properties file instead
The in order to add column names to CSV file add the following property to user.properties file:
jmeter.save.saveservice.print_field_names=true
Assuming good configuration you should be seeing grpThreads and allThreads columns along with the values.
See Apache JMeter Properties Customization Guide for more information on JMeter properties and ways of working with them

Getting the data from backend to display it on Front end in X-CART

I am working on a X-Cart Module. I need the backend configuration values to the front end. In admin/configuration file I have created an array which contains the value which I need to use it in adv_search.php which is in the root folder. I don't know how to pass that array to adv_search.php.
Thanks in advance.
It is not quite clear how you store the configuration values. It may be easier to store them in the table xcart_config and access them directly as $config['Option-category']['option_name'] in php files and {$config.Option-category.option_name} in the Smarty-templates.
Or just define an array in module's config.php file and this array will be available everywhere in php-scripts. Look at the modules/UPS_OnLine_Tools/config.php file for example.

Indexing file paths or URIs in Lucene

Some of the documents I store in Lucene have fields that contain file paths or URIs. I'd like users to be able to retrieve these documents if their query terms contain a path or URI segment.
For example, if the path is
C:\home\user\research\whitepapers\analysis\detail.txt
I'd like the user to be able to find it by queriying for path:whitepapers.
Likewise, if the URI is
http://www.stackoverflow.com/questions/ask
A query containing uri:questions would retrieve it.
Do I need to use a special analyzer for these fields, or will StandardAnaylzer do the job? Will I need to do any pre-processing of these fields? (To replace the forward slashes or backslashes with spaces, for example?)
Suggestions welcome!
You can use StandardAnalyzer.
I tested this, by adding the following function to Lucene's TestStandardAnalyzer.java:
public void testBackslashes() throws Exception {
assertAnalyzesTo(a, "C:\\home\\user\\research\\whitepapers\\analysis\\detail.txt", new String[]{"c","home", "user", "research","whitepapers", "analysis", "detail.txt"});
assertAnalyzesTo(a, "http://www.stackoverflow.com/questions/ask", new String[]{"http", "www.stackoverflow.com","questions","ask"});
}
This unit test passed using Lucene 2.9.1. You may want to try it with your specific Lucene distribution. I guess it does what you want, while keeping domain names and file names unbroken. Did I mention that I like unit tests?