I have a question, I am using FSharp.Configuration (https://fsprojects.github.io/FSharp.Configuration/YamlConfigProvider.html) library to read configuration file in my project using Yaml provider. Well it all works well and good but I started to wonder how to detect if there is no configuration file, if some no good user deleted this file.
I could replace it with some default hard coded config. But documentarian says none about it.
Anyone maybe solved this problem?
All values from the config file passed to the TP at compile time are stored as default values (right in the generated code), except lists of compound types, which will always be empty due to the TP restriction. So, when you instantiate a TP at runtime, it's "filled" with the default values already. If you need to fill it with different values, you can load a file, a string, or set individual properties in code. Maybe it would be a good idea to add an ability to load config from resources, but I'm not sure it's an idiomatic way in .NET world (in contrast with, say, Scala).
Related
Good morning,
does anyone know how I could configure MAMP (or WAMP) in order to automatically change my project URLs, to localhost without having to search/replace inside my documents (operation I suppose to be a bit gross because possibly altering my code).
My goal is to develop on local while keeping the final and real URLs in my documents.I suppose lot of you have encountered this issue one day :)
In other word, I would like to alternate between online and local more easily.
I a beginner, please consider,
for all the biginners, here's the thing. I've created a config.php file which contains constants: one config file for the local project folder and one for the online server folder.
Inside this config file, I've create a constant (constant are then available everywhere in the project) to define the main URL of the project. e.g.:
define('CST_MAIN_URL',http://www.myproject.com); // for the online config.php file
define('CST_MAIN_URL',http://localhost:8888); // for the local config.php file
Thus, each header or redirection can work with that constant, like:
header('location:' . CST_MAIN_URL . 'index.php');
Then, things must have to do with RewriteEngine in your htaccess file, for instance whenever you must modify the behavior of MAMP/WAMP if an interrogation point or a slash provokes you with its malicious resistance. But, unfortunately RegEx expression must be understood as a basic level for mastering those url rewritings.
Hope it'll helps.
I can use:
#+INCLUDE:
to include an org file in another org file, which allows me to assemble, say, a website from various org files. I'm exporting from the C-c C-e exporter in org-mode 7.5.
I could maintain a quite complex publication this way. This modular approach is quite common in, e.g. LaTeX and Texinfo publications.
However, links to images no longer work from the #+INCLUDEd org files. What seems to be happening is that the path to the images is taken as being from the org file that I am exporting from, rather than the actual org file that references the image.
The only ways I can see to resolve this are to:
use a flat file structure; or
make the image path from the referencing file (which I might not know in advance) rather than itself.
Neither of these is really sustainable.
How do I tell org to use the correct image path from its own relevant org file rather than the parent org file?
From what I know of the exporter, INCLUDE files are inserted into the document before export. Therefore the content is part of the document before it starts following paths to reach any links to files (images).
After a bit of testing you likely will need to use absolute file paths. Since you move between Windows and Linux your best bet would be to use a consistent scheme on both starting from your home directory.
Like that you can make the Org link:
[[~/path/to/image.jpg]], which will work on both systems (assuming you have set %HOME% on Windows).
Option 1 is potentially an alternative (although I agree it wouldn't be ideal at all), whereas the second option would have obvious pitfalls if you INCLUDE the file in more than one future document.
I am evaluating gnugettext for Delphi XE2. All seems to be OK except that it seems that we don't have translation directory(ies) choice : it is always "\locale\Lc_MESSAGES\".
As I need to share translation for some exe in the same application it's not very convenient. I looked in the sources and see :
BaseDirectory:=ExtractFilePath(ExecutableFilename);
OK, I may change the source but I don't like it.
Any elegant idea ?
You can use the provided bindtextdomain function to change the directory where your application looks for the dictionary files. The first parameter will normally be the string 'default', and the second parameter is the directory to go to. The actual dictionary files will still need to be in a subfolder of the specified directory (using the same \locale\LC_MESSAGES\ pattern), but this at least gives a convenient way of sharing translations across multiple programs.
i'm working on a symfony project and i generated a set of model classes called Base<name>.php, <name>.php, <name>Peer.php and Base<name>Peer.php
I did the famous jobeet tutorial and i still have doubts about locating functions in these files of the model. So my question is:
What kind of functions i have to put in which file?
or expressed other way
How i know where to locate a function in these files?
thank you very much
You should never edit the files prefixed with Base, they can be overwritten if you change something in your schema and regenerate these files.
The custom methods you are writing yourself should be in the Peer class.
To easily locate a method, I use a good IDE like PDT that parses the files and allows searching methods.
I'm wondering where's the best place to save some simple insensitive data? Like a few URLs and some settings.
Please advise.
If this is a per-user file, you should save it in the current user's profile. For example, on my Windows 7 system, you should use
C:\Users\Andreas Rejbrand\AppData\Local\Your Company Name\Your Product Name\Version
such as
C:\Users\Andreas Rejbrand\AppData\Local\Rejbrand\AlgoSim\2.0
To get the C:\Users\Andreas Rejbrand\AppData\Local path, you use the SHGetSpecialFolderPath function.
Settings, and specifically user-specific settings, can be stored in the registry. Have a look at the Registry unit and the TRegistry object.
Here's some demo code to get you going:
var
r:TRegistry
begin
r:=TRegistry.Create;
try
r.OpenKey('\Software\MyApplication',true);
r.WriteInteger('Setting1',Setting1);
r.WriteString('Setting2',Setting2);
finally
r.Free;
end;
end;
INI file or JSON file or XML file depending on your needs for local usage.
DB is for net usage.
It all depends on the purpose of those settings! If you want XCopy deployment, I would suggest an XML file next to the exe. But if you also need to write to this, you should find a suitable location in the current user's profile or the "all users" profile. The registry (local machine or current user) would also be a good option for simple settings.
Another question is the type of settings that you need to store. If it's simple settings, I generally start with Altova's XMLSpy to generate an XML schema, defining the structure of the settings. Then I use Delphi's XML import wizard to generate code from this schema and just use that generated code. It allows me to modify the structure in an easy way and also makes sure there's at least some documentation (the schema) telling others about the structure. It might sound complex at first, but once you're used to this, it's perfect! No more manual editing of registry settings or forgetting about the structure of your INI files. And no more thinking about writing code to read and write those settings, since Delphi will do that for you!The Registry would also be a good location for settings but not every user will have proper access rights to read from, or write to, the registry which could crash your application. Besides, the registry has some other limitations which makes it unsuitable if you need to store a lot of settings! It would be okay to store a connection string and maybe username and encrypted password for some user account, but if you need to store 40 settings or more, then the Registry becomes unsuitable.The same is true about INI files, which tend to be limited to a maximum size of 64 kilobytes. Of course, you could also store those settings in a regular text file or just some binary file. In the past, I even stored settings inside a ZIP file, because I needed to store dozens of grid-related settings. So each grid would read and write it's settings to some binary stream which would then be stored in an encrypted ZIP file.
There are many options like XML (structured data storage), ini files (simple data), databases or flat files.
I will go for XML's saved with ClientDatasets. They allow lot of options like searching, sorting, usage of the database controls and many more.