How do I get a platform-independent new line character?
Java 7 now has a System.lineSeparator() method.
Java 7 now has a System.lineSeparator() method.
Check out the InteractiveBrokers API or the Cunningham T4 API. Both are really good, although I’m not exactly sure T4 allows forex trading.
If you really want to define a REST api, then do the following: forget all technology issues other than HTTP and media types. Identify the major use cases where a client will interact with the API Write client code that perform those “use cases” against a hypothetical HTTP server. The only information that client should … Read more
The motivation for implementing a “true” async method is clear, as stated by @Steven_Cleary, but sometimes you have legacy code you cannot simply make async. For those in desperate need for keeping the old interface: Use Task.Run. E.g. when you had IAsyncResult ar = someDelegate.BeginInvoke(state, null, null); and use properties of ar in order to … Read more
What you are asking for is possible but needs a bit of work. Define a preprocessor variable in your csproj <PropertyGroup Condition=” ‘$(OS)’ == ‘Windows_NT’ “> <DefineConstants>_WINDOWS</DefineConstants> </PropertyGroup> Use that in your code #if _WINDOWS // your windows stuff #else // your *nix stuff #endif I find this technique useful when you have constants that … Read more
instead of repeating yourself and writing the same #ifdef …. lines again, again, and again, you’re maybe better of declaring the probe() method in a header, and providing three different source files, one for each platform. This also has the benefit that if you add a platform you do not have to modify all of … Read more
Use a single make file and put the platform-specifics in conditionals, eg ifeq ($(OS),Windows_NT) DLLEXT := .dll else DLLEXT := .so endif DLL := libfoo$(DLLEXT) lib : $(DLL)
Use os.path.abspath(), and also os.path.expanduser() for files relative to the user’s home directory: print os.path.abspath(“/var/lib/blob_files/myfile.blob”) >>> C:\var\lib\blob_files\myfile.blob print os.path.abspath(os.path.expanduser(“~/blob_files/myfile.blob”)) >>> C:\Users\jerry\blob_files\myfile.blob These will “do the right thing” for both Windows and POSIX paths. expanduser() won’t change the path if it doesn’t have a ~ in it, so you can safely use it with all paths. … Read more
You can reduce one line 🙂 startupinfo = None if os.name == ‘nt’: startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW proc = subprocess.Popen(command, startupinfo=startupinfo)
It’s a good thing you’re using Python, I created a library to do just that a while ago: http://www.hardcoded.net/articles/send-files-to-trash-on-all-platforms.htm On PyPI: Send2Trash Installation Using conda: conda install Send2Trash Using pip: pip install Send2Trash Usage Delete file or folders from send2trash import send2trash send2trash(“directory”)