Generate list of all possible permutations of a string

There are several ways to do this. Common methods use recursion, memoization, or dynamic programming. The basic idea is that you produce a list of all strings of length 1, then in each iteration, for all strings produced in the last iteration, add that string concatenated with each character in the string individually. (the variable … Read more

Automatically add all files in a folder to a target using CMake?

As of CMake 3.1+ the developers strongly discourage users from using file(GLOB or file(GLOB_RECURSE to collect lists of source files. Note: We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is added or removed then the generated build system … Read more

How to execute XPath one-liners from shell?

You should try these tools : xmlstarlet (xmlstarlet page) : can edit, select, transform… Not installed by default, xpath1 xmllint (man xmllint): often installed by default with libxml2-utils, xpath1 (check my wrapper to have –xpath switch on very old releases and newlines delimited output (v < 2.9.9)). Can be used as interactive shell with the … Read more

What is the naming standard for path components?

I think your search for a “standard” naming convention will be in vain. Here are my proposals, based on existing, well-known programs: A) C:\users\OddThinking\Documents\My Source\Widget\foo.src — Vim calls it file root (:help filename-modifiers) B) C:\users\OddThinking\Documents\My Source\Widget\foo.src ——- file name or base name C) C:\users\OddThinking\Documents\My Source\Widget\foo.src ___ (without dot) file/name extension D) C:\users\OddThinking\Documents\My Source\Widget\foo.src ____ (with … Read more

How do you run a Python script as a service in Windows?

Yes you can. I do it using the pythoncom libraries that come included with ActivePython or can be installed with pywin32 (Python for Windows extensions). This is a basic skeleton for a simple service: import win32serviceutil import win32service import win32event import servicemanager import socket class AppServerSvc (win32serviceutil.ServiceFramework): _svc_name_ = “TestService” _svc_display_name_ = “Test Service” def … Read more

How can I find the current OS in Python? [duplicate]

If you want user readable data but still detailed, you can use platform.platform() >>> import platform >>> platform.platform() ‘Linux-3.3.0-8.fc16.x86_64-x86_64-with-fedora-16-Verne’ platform also has some other useful methods: >>> platform.system() ‘Windows’ >>> platform.release() ‘XP’ >>> platform.version() ‘5.1.2600’ Here’s a few different possible calls you can make to identify where you are, linux_distribution and dist seem to have … Read more

How to detect reliably Mac OS X, iOS, Linux, Windows in C preprocessor? [duplicate]

There are predefined macros that are used by most compilers, you can find the list here. GCC compiler predefined macros can be found here. Here is an example for gcc: #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) //define something for Windows (32-bit and 64-bit, this part is common) #ifdef _WIN64 //define something for Windows … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)