What is thread safe or non-thread safe in PHP?

Needed background on concurrency approaches: Different web servers implement different techniques for handling incoming HTTP requests in parallel. A pretty popular technique is using threads — that is, the web server will create/dedicate a single thread for each incoming request. The Apache HTTP web server supports multiple models for handling requests, one of which (called … Read more

Create cross platform Java SWT Application

I’ve just run into the same problem. I haven’t tried it yet, but I plan to include versions of swt.jar for all platforms and load the correct one dynamically in the start of the main method. UPDATE: It worked. build.xml includes all jars: <zipfileset dir=”/home/aromanov/workspace/foo/lib” includes=”swt_linux_gtk_x86.jar”/> <zipfileset dir=”/home/aromanov/workspace/foo/lib” includes=”swt_macosx_x86.jar”/> <zipfileset dir=”/home/aromanov/workspace/foo/lib” includes=”swt_win32_x86.jar”/> <zipfileset dir=”/home/aromanov/workspace/foo/lib” includes=”swt_linux_gtk_x64.jar”/> … Read more

Relative imports – ModuleNotFoundError: No module named x

TL;DR: You can’t do relative imports from the file you execute since __main__ module is not a part of a package. Absolute imports – import something available on sys.path Relative imports – import something relative to the current module, must be a part of a package If you’re running both variants in exactly the same … Read more

NodeJS require a global module/package

In Node.js, require doesn’t look in the folder where global modules are installed. You can fix this by setting the NODE_PATH environment variable. In Linux this will be: export NODE_PATH=/usr/lib/node_modules Note: This depend on where your global modules are actually installed. See: Loading from the global folders.

How do I create a namespace package in Python?

TL;DR: On Python 3.3 you don’t have to do anything, just don’t put any __init__.py in your namespace package directories and it will just work. On pre-3.3, choose the pkgutil.extend_path() solution over the pkg_resources.declare_namespace() one, because it’s future-proof and already compatible with implicit namespace packages. Python 3.3 introduces implicit namespace packages, see PEP 420. This … Read more