Questions tagged [configuration]

Configuration is the process of specifying the settings used for a system or application.

Filter by
Sorted by
Tagged with
4 votes
1 answer
425 views

Extracting username, password and host from a config file

The code below calls the parse_config() function which populates the global variables user, ...
  • 181
1 vote
1 answer
106 views

ConfigurationManager to access entry assembly's config settings from within any other dependent assembly

I inherited a solution with many projects, and one of them contains hard coded database connection parameters. These are referenced in a number of other projects, and many of those are dependencies of ...
  • 111
0 votes
1 answer
61 views

Determine the URL to use for a REST API based on configuration

There is a bit of if-else-if going in within the code. Is there a construct which could come handy. Also the section names are very similar too ...
  • 103
1 vote
2 answers
316 views

Python function to connect to MS SQL using connection parameters from environment variables

I have the following file that is included in others. I realise I need to put in try/except but for the purposes of this question, the below should suffice We're ...
  • 360
-2 votes
1 answer
121 views

Write portable Git aliases

The following aliases return all the same number of results, on my Cygwin (on Windows): ...
2 votes
1 answer
101 views

Stop exam cheating using python: Part 2 - Argparse and config

Intro This is a spiritual successor to the question Stop cheating on home exams using python The details are not important, but I decided to reimplement everything using dataclasses. My script is now ...
1 vote
1 answer
1k views

Python - Share global variables across modules from user-defined config file

Goal My program takes a yaml config file as parameter python myprogram.py cfg.yml. all modules can access the cfg content with a simple module import the imported <...
  • 21
0 votes
1 answer
57 views

Utilize values in a parameters file for function inputs [closed]

In my Python projects, I often define parameters in a TOML, YAML, or JSON file. Those parameters are loaded into a dictionary which is utilized by various functions in the project. See below for some ...
  • 265
0 votes
1 answer
63 views

Config for each environment (for a simple Python SDK)

I have a simple SDK in Python for internal use. It's basically 150~200 lines of code of simple API calls wrapped around nicely that is comfortable for us to use. It holds a few clients with methods (...
  • 407
4 votes
2 answers
181 views

CGI script that reads or writes its height and weight configuration

UPDATES: I'm looking for an answer that can answer the questions listed in the post. Moreover, this answer will not only continue my way of thinking, but also give feedback based on it. It's just like ...
3 votes
3 answers
3k views

How to handle configuration from a config file and global variables transparently in python?

This is how I handle configuration in my python code, currently, but I guess it might look magic to people, and it is cumbersome to code. How can this be improved? Are there better solutions? The ...
0 votes
1 answer
227 views

Remove and add connection string

I want to remove a connection string that may already have been set in a different config file and then set it again. Say my application has a Web.config file and a Web.Debug.config file then I can ...
  • 101
0 votes
1 answer
74 views

Reading configuration variables in a Python project

I am new to python, in .NET we use web.config to store environment specific variables... I want to achieve the same for my python program (scraper) I have created .env file at the root of the project ...
2 votes
1 answer
161 views

Determine dependency injection type at runtime from config

I have a .NET application with a .config file that has content like this: ...
2 votes
1 answer
2k views

Systeminfo, a C++ class to retrieve system management data from the BIOS

Please review my System information class. Systeminfo can be used to retrieve system management data from the BIOS. This data is mostly strings. Is the code easy to understand and maintainable? Is ...
  • 2,329
9 votes
0 answers
209 views

React Typescript Boilerplate [closed]

I'm trying to build a React Boilerplate Using multiple tools. They are all: React, TypeScript, ESLint, Webpack, Babel, Prettier, VSCode and with Airbnb's code style guide. Actually, this is my first ...
1 vote
1 answer
389 views

How to avoid using exec() and eval() in Python

I wrote a script to execute a service on the Forestry TEP platform via its REST API. This service has certain input parameters, some of them are numerical values, other strings or files. The current ...
  • 219
3 votes
1 answer
55 views

IPython - Clipboard Extension

I often copy things from my terminal to other places (like Discord), and to make my workflow even easier I decided to use the IPython API to make an extension that has two magic functions ...
  • 33
3 votes
1 answer
87 views

config files for different development environments (Production, Dev, Testing)

I am following a guide that specifies how to manage different configurations (DB_URI, LOGGER_NAME, etc...) per development environments. I create a config module ...
  • 270
1 vote
1 answer
95 views

Finding all alphanumerical words in a text line using std::string

Preliminaries I am working on a software that controls CAEN digitizer. The current step is to provide an ability to save/load configuration to/from an external source (hereafter - "config file&...
  • 771
2 votes
0 answers
147 views

SharedPreferences singleton wrapper

I was wondering wether my implementation of the PreferenceService below is thread safe or could cause memory leaks. Android Studio gives me the warning "Do not place Android context classes in ...
  • 121
4 votes
1 answer
111 views

Sanitize and build data structure from Consul configuration

I have a piece of working code that takes some strings from Consul configuration exports, sanitizes them a little and converts them into valid json and/or hocon structures. While I am iterating over ...
  • 163
1 vote
0 answers
42 views

Providing JavaScript Configuration (Laravel config() style)

This may be better suited on Stackoverflow, in which case, please let me know and I will move it over... Background Consider the following file structure: ...
  • 199
3 votes
2 answers
79 views

Static global settings class with serializing

I have a class that is used for serializing and deserializing global application variables. I would like to know if there is anything that I can improve. I know I could inject a dependency to support ...
  • 205
4 votes
2 answers
184 views

Function to get current value or default from a string of two values

I have SQL scripts that I want to be executable directly in the editor (like DataGrip or SSMS) and also in automated integration tests. However, in each use-case they require different environment and ...
  • 44k
11 votes
6 answers
9k views

Parse a simple key=value config file in C

Write a program that should read a file formatted strictly like this below: $ cat sample bingo=2 bingo2=939 bingo3=text The left and right side of ...
3 votes
2 answers
90 views

Script to create shell aliases

Can anybody find anything to pick apart in this script? ...
  • 131
1 vote
1 answer
31 views

PHP/Apache - Production/staging consts file path

Is there anything wrong with having a file path as an env variable and using that as-is in a require_once? ...
  • 119
2 votes
1 answer
79 views

Fetching configuration or default value

I have two code snippets, doing exactly the same thing and both get the job done: use defaults use from config Which is cleaner to use in golang and why? first option: ...
  • 141
-2 votes
1 answer
50 views

Is it ok to use subclasses to define just a couple of attributes? [closed]

I'm working with some code left from other developers. Here we have several projects we can work with. The project object is instantiated at the runtime. Then it used in other classes. There are no ...
  • 1
9 votes
3 answers
289 views

Toggle any application feature ON or OFF

When testing or debugging applications it'd be often useful to be able to run it without certain features like committing things to the database, saving files, sending emails, reading files, executing ...
  • 44k
4 votes
2 answers
250 views

Simple INI file parser in Haskell

I've written a rudimentary parser for INI files: ...
1 vote
1 answer
66 views

INI File configuration handler

I am currently working on a game, and I get the configuration in an .ini file, and I get information with this library https://github.com/benhoyt/inih I would like to improve the readability / ...
  • 153
3 votes
1 answer
57 views

Opening YouTube videos according to chakra cycles

I'm learning how to write code in Python. This code makes an .ini that saves different cycles adding one new operation to the previous cycle. It starts at 1;1, saves that it has run 1 cycle and will ...
1 vote
1 answer
80 views

ASP.net service that sends email whenever an entity is updated [closed]

I have an ASP.net MVC5 project which involve different domain services, and one of it are EmailService which will send email if entity is updated. ...
  • 127
3 votes
1 answer
179 views

Settings class implementation

I have a settings.txt file with the following format: ...
  • 1,122
2 votes
1 answer
122 views

Create Apache2 virtualhost, Mysql db & user. CLI tool and GUI on top of it

Review for optimization, code standards, missed validation. What's in this version: Rewritten, instead of large complex script - few tools with each own task. Solid CLI tool and GUI script on top of ...
  • 169
6 votes
1 answer
352 views

Simple bash script creates apache2 virtualhost config for subdomain

Simple bash script to create apache2 virtualhost for localhost. Can be used for public subdomains on developer server with changes - "replace .localhost". Tested on Ubuntu, but should work where ...
  • 169
4 votes
0 answers
406 views

Wrapping argparse to use configuration file

I want to be able to both provide options through command line and from a configuration file. A single option could be served either by the user or by the configuration. But if is provided by both, ...
  • 181
1 vote
1 answer
201 views

Saving settings to Windows registry as a tuple

Regarding an application written in C++ using the Windows API. I'd like to store a user setting like the window position on program exit, to the Windows registry and retrieve settings like these on ...
  • 11
1 vote
1 answer
1k views

Java classes to load configuration data from a JSON file, with Scala tests

I want to implement classes in a project that will support the loading of configuration data from a JSON file. The JSON file is in the following form. Please be as critical as you can be. I'm a junior ...
7 votes
1 answer
131 views

Perl one-liner for parsing host names from ssh config file

Here is the working code (intended to be executed with perl -e '<code>' ~/.ssh/config): Actual version: ...
3 votes
1 answer
354 views

Editing a configuration file using C++ and Win32

I have made a small and simple tool for Windows using C++ and the Win32 API to allow people to change their resolution in Fortnite, without having to search for the configuration file and manually ...
1 vote
1 answer
39 views

Database as a config and class structure to call it

I have question regarding best practices. I've decided instead having config inside either app.config or xml file to have my config file inside SQLite file database. This config will contain basic ...
  • 11
3 votes
1 answer
61 views

Read a single int from an optional .properties file

I am no newcomer to Java. One thing that confounds me is why it is so messy to load values from .properties files. I have an application where, if the .properties file is found, then the value if ...
4 votes
1 answer
143 views

Dynamic setting names based on properties

In one of my frameworks that I use with many tools I have an ExpressionVisitor whose job is to resolve the exact property, it's declaring type and instance. I ...
  • 44k
2 votes
1 answer
792 views

SSMTP configuration in Ubuntu 18.04 with Bash in my own system (one user)

This is how I configure the utility SSMTP that allows me to send mail via smtp protocol through a Google-Gmail proxy instead I'll have to manually configure an "...
user avatar
6 votes
2 answers
232 views

Minimalistic, self-contained class for reading a sectionless INI file

When sections are ignored and no writing capability is needed, an INI reader becomes quite simple to implement. Here is my attempt at reading a sectionless INI file without any non-...
  • 309
3 votes
1 answer
3k views

Elastic Beanstalk configuration using ebextensions container_commands combining leader_only and test

For our Django app running on AWS Elastic Beanstalk, we use a web-server/worker setup. The same code is deployed to the web-server and worker environments, and environment-specific configuration is ...
  • 151
2 votes
2 answers
254 views

Node.js configuration object based on environment variables

In the code below, I am building a NODE_ENV-sensitive config object from environment variables. ...
  • 131