What should a developer know before building an API for a community based website?

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

BeginInvoke not supported on .NET core? (PlatformNotSupported exception)

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

C# preprocessor differentiate between operating systems

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

Using absolute unix paths in windows with python

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

How can I move file into Recycle Bin / trash on different platforms using PyQt4?

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”)

tech