How do I store desktop application data in a cross platform way for python?

Well, I hate to have been the one to answer my own question, but no one else seems to know. I’m leaving the answer for posterity. APPNAME = “MyApp” import sys from os import path, environ if sys.platform == ‘darwin’: from AppKit import NSSearchPathForDirectoriesInDomains # http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/func/NSSearchPathForDirectoriesInDomains # NSApplicationSupportDirectory = 14 # NSUserDomainMask = 1 # … Read more

Find current country from iPhone device

To find the country of the user’s chosen language: NSLocale *currentLocale = [NSLocale currentLocale]; // get the current locale. NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode]; // get country code, e.g. ES (Spain), FR (France), etc. In Swift: let currentLocale = NSLocale.currentLocale() let countryCode = currentLocale.objectForKey(NSLocaleCountryCode) as? String If you want to find the country code of … Read more

Difference between ‘SpecialFolder.LocalApplicationData’ and ‘SpecialFolder.ApplicationData’?

The Roaming folder is copied between machines when roaming profiles are enabled (in a domain environment). Use it for application data that you want to share between machines. But don’t store large files in there — IT departments don’t like it when you do that, and it increases the time taken for the user to … Read more

Which design patterns can be applied to the configuration settings problem?

I prefer to create an interface for setting query, loading, and saving. By using dependency injection, I can inject this into each component that requires it. This allows flexibility in terms of replacing the configuration strategy, and gives a common base for everything to work from. I prefer this to a single, global “settings loader” … Read more

How can I display the application version revision in my application’s settings bundle?

There is another solution that can be much simpler than either of the previous answers. Apple bundles a command-line tool called PlistBuddy inside most of its installers, and has included it in Leopard at /usr/libexec/PlistBuddy. Since you want to replace VersionValue, assuming you have the version value extracted into $newVersion, you could use this command: … Read more

Can a spring boot @RestController be enabled/disabled using properties?

I found a simple solution using @ConditionalOnExpression: @RestController @ConditionalOnExpression(“${my.controller.enabled:false}”) @RequestMapping(value = “foo”, produces = “application/json;charset=UTF-8”) public class MyController { @RequestMapping(value = “bar”) public ResponseEntity<String> bar( return new ResponseEntity<>(“Hello world”, HttpStatus.OK); } } With this annotation added, unless I have my.controller.enabled=true in my application.properties file, the controller won’t start at all. You can also use the … Read more

App.config: User vs Application Scope

Basically, application settings cannot be changed during the running of a program and user settings can. These user settings should then be saved so the user is presented with a familiar experience when (s)he runs the application next. Edit: For examples, you might write your application with different modules, and need to ensure that your … Read more

How to fix Error: “Could not find schema information for the attribute/element” by creating schema

Quickest, easiest laziest way to solve the problem: Right-click on the project icon in Solution Explorer and choose “Properties”. Go to the “Application” tab and choose an earlier .NET target framework. Save changes. Go to the “Application” tab and choose the initial .NET target framework. Save changes => problem solved!