config
Config is a lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files
I'm having a very hard time trying to access a custom configuration section in my config file.
The config file is being read from a .dll that is loaded as a plug-in. I created the Configuration and necessary code using the Configuration Section Designer VS addin.
The namespace is 'ImportConfiguration'. The ConfigurationSection class is 'ImportWorkflows'. The assembly is ImportEPDMAddin.
The xml:
<configSections>
<section name="importWorkflows" type="ImportConfiguration.ImportWorkflows, ImportEPDMAddin"/>
</configSections>
Whenever I try to read in the config, I get the error:
An error occurred creating the configuration section handler for importWorkflows: Could not load file or assembly 'ImportEPDMAddin.dll' or one of its dependencies. The system cannot find the file specified.
The dll will not reside in the same directory as the executable as the software that loads the plugin places the dll and it's dependencies in it's own directory. (I can't control that.)
I edited the code for the singleton instance to the following:
string path = System.Reflection.Assembly.GetCallingAssembly().CodeBase;
path = path.Replace("file:///", "");
System.Configuration.Configuration configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(path);
return configuration.GetSection(ImportWorkflowsSectionName) as ImportConfiguration.ImportWorkflows;
I have also tried using a simple NameValueFileSectionHandler as well, but I get an exception saying that it can't load file or assembly 'System'.
I have read numerous blog posts and articles and it sounds like it is possible to read a config file in for a dll, but I just can't get it to work. Any ideas? Thanks.
Source: (StackOverflow)
I am writing my first gem and I'd like specific options to be retrieved and set by the user through a config.yml file.
Where should this file be placed within my gem file structure and how does someone modify the file when installing my gem? I'm guessing they can pass in specific options when installing the gem, and those options can be mapped to the config.yml file, but how is this possible?
Also, is the best way to retrieve the file through YAML.load_file?
I've watched Ryan's railcasts on creating a gem via Bundler, but he doesn't cover this topic.
Source: (StackOverflow)
After a merge failed with some conflicts I can list those with git diff
,
but git difftool
won't display them with the difftool set in the config(in my case Kaleidoscope), instead it will just use normal diff.
A git difftool
comparing with a previous commit will work.
Is there a way to use git difftool on merge conflicts?
Greets Jan
Source: (StackOverflow)
I want to use a single app.config by 3 different projects.
How to access the configurations?
ConfigurationManager.AppSettings["config1"]
Source: (StackOverflow)
How do get the path of a installed Perl module by name,
e.g. Time::HiRes
?
I want this just because I have to run my perl script on different nodes of a SGE Grid Engine system. Sometimes, even run as other username.
I can use CPAN.pm to install packages for myself, but it is not so easy to install for other users without chmod 666 on folders.
Source: (StackOverflow)
Hadoop has configuration parameter hadoop.tmp.dir
which, as per documentation, is `"A base for other temporary directories." I presume, this path refers to local file system.
I set this value to /mnt/hadoop-tmp/hadoop-${user.name}
. After formatting the namenode and starting all services, I see exactly same path created on HDFS.
Does this mean, hadoop.tmp.dir
refers to temporary location on HDFS?
Source: (StackOverflow)
Does anyone know if there's a way to get Eclipse to do a "Save all" before building java code? (I don't use the "Build automatically" option, I'm talking when you use "Ctrl+B" to do a build all)
I've dug thru the preferences, and can't seem to find anything, so I figured I'd check the hive mind at Stack Overflow just in case.
I'm using Ganymede, V3.4.1, Build id: M20080911-1700, if it's relevant.
Thanks in advance,
Dave Mackie
Source: (StackOverflow)
I'm looking to hear some best practices...
Assuming a web application that interacts with a few different production servers (databases, etc.)... should the configuration files that include database passwords be stored in source control (e.g., git, svn)?
If not, what's the best way to keep track of server database (or other related) passwords that your application needs access to?
Edit: added a bounty to encourage more discussion and to hear what more people consider best practice.
Source: (StackOverflow)
Have config (applicationContext-security.xml):
<authentication-manager alias="authenticationManager">
<authentication-provider>
<password-encoder hash="sha"/>
<jdbc-user-service data-source-ref="dataSource"/>
</authentication-provider>
</authentication-manager>
from other side have SQLs from my dataSource
(it's JdbcDaoImpl):
...
public static final String DEF_USERS_BY_USERNAME_QUERY =
"select username,password,enabled " +
"from users " +
"where username = ?";
...
There is now word about sha
in this code,so password selected from standard Spring Security users
table not encoded.
Perhaps, I should provide some sha
attribute for password
column in my hibernate mapping config here:
<class name="model.UserDetails" table="users">
<id name="id">
<generator class="increment"/>
</id>
<property name="username" column="username"/>
<property name="password" column="password"/>
<property name="enabled" column="enabled"/>
<property name="mail" column="mail"/>
<property name="city" column="city"/>
<property name="confirmed" column="confirmed"/>
<property name="confirmationCode" column="confirmation_code"/>
<set name="authorities" cascade="all" inverse="true">
<key column="id" not-null="true"/>
<one-to-many class="model.Authority"/>
</set>
</class>
For now password saved to DB as is,but should be encoded.
How to friend applicationContext
config and DB queries to be the same password encoding?
Source: (StackOverflow)
In previous versions of ASP.NET many of us used Web.Debug.config
/Web.Release.config
files trasformations that would look something like this:
Web.config:
<connectionStrings>
<add name="AppDB" connectionString="Data Source=(LocalDb)\\..." />
</connectionStrings>
Web.Release.config:
<connectionStrings>
<add name="AppDB" connectionString="Data Source=(ReleaseDb)\\..." xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
As per ASP.NET vNext tutorial you still can use Web.config. But config.json
appear to be the new way to handle configurations now as per the same article:
config.json
{
"Data": {
"DefaultConnection": {
"ConnectionString": "Server=(localdb)\\..."
}
}
}
And in Startup.cs:
var configuration = new Configuration();
configuration.AddJsonFile("config.json");
configuration.AddEnvironmentVariables();
So I'm wondering what would be the suggested way to handle config-transofrmation with this shift to json?
Source: (StackOverflow)
What is the fastest way to store config data in PHP so that it is easily changeable (via PHP)? First I thought about having config.php file, but I can't edit it on fly with PHP, at least not very simply? Then I thought about having XML files, but parsing them for each HTTP request is overwhelming. So, I thought about INI files, but then I figured that INI files are restricted to int/string values. In the end, I have come to the conclusion that JSON encoded file is the best:
$config['database']['host'] = ...;
$config['another']['something'] = ...;
...
json_encode($config);
Since JSON can store arrays, I can create quite complex configurations with it, and it parses faster than INI files.
My question: did I miss something or is there a better way to do this?
Source: (StackOverflow)
I have 4 states: dashboard, dahboard.main, dashboard.minor, login.
dashboard is abstract and it is a parent state for .minor and .main states.
Below is my code:
.state('dashboard', {
url: "/dashboard",
abstract: true,
templateUrl: "views/dashboard.html",
resolve: {
auth: function ($q, authenticationSvc) {
var userInfo = authenticationSvc.getUserInfo();
if (userInfo) {
return $q.when(userInfo);
} else {
return $q.reject({ authenticated: false });
}
}
},
controller: "DashboardCtrl",
data: { pageTitle: 'Example view' }
})
.state('dashboard.main', {
url: "",
templateUrl: "views/main.html",
controller: "DashboardCtrl",
data: { pageTitle: 'Main view' }
})
As you see in dashboard state I have resolve option. By this I would like to redirect user to login page if he is not authorized. For this reason I use special authenticationSvc service:
.factory("authenticationSvc", ["$http", "$q", "$window", function ($http, $q, $window) {
var userInfo;
function login(email, password) {
var deferred = $q.defer();
$http.post("/api/login", { email: email, password: password })
.then(function (result) {
if(result.data.error == 0) {
userInfo = {
accessToken: result.data.accessToken
};
$window.sessionStorage["userInfo"] = JSON.stringify(userInfo);
deferred.resolve(userInfo);
}
else {
deferred.reject(error);
}
}, function (error) {
deferred.reject(error);
});
return deferred.promise;
}
function getUserInfo() {
return userInfo;
}
return {
login: login,
logout: logout,
getUserInfo: getUserInfo
};
}]);
I check auth value in config :
.run(function($rootScope, $location, $state) {
$rootScope.$state = $state;
$rootScope.$on("routeChangeSuccess", function(userInfo) {
consol.log(userInfo);
});
$rootScope.$on("routeChangeError", function(event, current, previous, eventObj) {
if(eventObj.authenticated === false) {
$state.go('login');
}
});
});
But unfortunately when I go to my website root or dashboard state I get an empty page. What is wrong with this code? Thanks!
Source: (StackOverflow)
I have a Rails 3 application, call it "MyApp". In my config\environments\production.rb file I see such things as
MyApp::Application.configure do
config.log_level = :info
config.logger = Logger.new(config.paths.log.first, 'daily')
...or...
config.logger = Logger.new(Rails.root.join("log",Rails.env + ".log"),3,20*1024*1024)
So, questions are focusing on terminology and wtf they mean... (or point me to some site ,I have looked but not found, to explain how this works.)
- MyApp is a module?
- MyApp::Application is a ...? What, a module too?
- MyApp::Application.configure is a method?
- config is a variable? How do I see it in console?
- config.logger is a ???
- config.paths.log.first is a ...??
--in console I can see "MyApp::Application.configure.config.paths.log.first" but don't know what that means or how to extract info from it!?!
Is this too much for one question? :)
I have looked at the tutorial http://guides.rubyonrails.org/configuring.html but it jumps right into what things do.
Source: (StackOverflow)