Why do people write the #!/usr/bin/env python shebang on the first line of a Python script?

Why do people write the #!/usr/bin/env python shebang on the first line of a Python script?

It seems to me like the files run the same without that line. 1:If you have several versions of Python installed, /usr/bin/env will ensure the interpreter used is the first one on your environment's $PATH. The alternative would be to har

getResourceAsStream() vs FileInputStream

getResourceAsStream() vs FileInputStream

I was trying to load a file in a webapp, and I was getting a FileNotFound exception when I used FileInputStream. However, using the same path, I was able to load the file when I did getResourceAsStream(). What is the difference between the

When to use double or single quotes in JavaScript?

When to use double or single quotes in JavaScript?

console.log("double"); vs console.log('single');I see more and more JavaScript libraries out there using single quotes when handling strings. What are the reasons to use one over the other? I thought they're pretty much interchangeable.

Monitoring used connections on mysql to debug 'too many connections'

Monitoring used connections on mysql to debug 'too many connections'

On LAMP production server I get the 'too many connections' error from MYSQL occasionally, I want to add monitoring to find if the reason is that I exceed the max-connections limit. My question: How can I query from mysql or from mysqladmin

How to get a WPF window's ClientSize?

How to get a WPF window's ClientSize?

In WinForms, Form had a ClientSize property (inherited from Control), which returns the size of its client area, i.e., the area inside the title bar and window borders.I'm not seeing anything similar in WPF: there's no ClientSize, ClientWid

Where are Java final local variables stored?

Where are Java final local variables stored?

Take the following example:public void init() { final Environment env = new Environment(); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { env.close(); } });}Firstly, where is env

Why Java does not allow null while declaring primitive data types [duplicate]

Why Java does not allow null while declaring primitive data types [duplicate]

This question already has an answer here: Null for primitive data types 9 answers This is in continuation to my previous question and accroding to answ

slf4j logging with jdk – how to enable debug?

slf4j logging with jdk – how to enable debug?

By default slf4j, when using with jdk (slf4j-jdk14-1.6.1.jar), does not log debug messages.How do I enable them?I can’t find info neither in the official docs, the web or here on how to enable it.I found some info on (failed though) creatin

Local classes : C++03 vs. C++11

Local classes : C++03 vs. C++11

Is there any change in the usage of local class in C++11?It seems in C++03 local classes cannot be used as template argument (I recall that).Consider this code,template void f(const T&) {}//Note : S is a local class defined inside main()int

Why `float` function is slower than multiplying by 1.0?

Why `float` function is slower than multiplying by 1.0?

I understand that this could be argued as a non-issue, but I write software for HPC environments, so this 3.5x speed increase actually makes a difference.In [1]: %timeit 10 / float(98765) 1000000 loops, best of 3: 313 ns per loop

React onClick and preventDefault() link refresh/redirect?

React onClick and preventDefault() link refresh/redirect?

I'm rendering a link with react:render: -> `upvote`Then, above I have the upvote function:upvote: -> // do stuff (ajax)Before link I had span in that place but I need to switch to link and here's the trouble - every time I click on .upvot

C++ - Qt - Visual Studio 2010 - application with both gui and console

C++ - Qt - Visual Studio 2010 - application with both gui and console

If no arguments are given to the program it launches as a GUI application, if it is given args it is run through the command line. I was able to get visual studio to display and print to the console with Properties>Linker>SubSystem (Consol

Bootstrap 3 - modal disappearing below backdrop when using a fixed sidebar

Bootstrap 3 - modal disappearing below backdrop when using a fixed sidebar

I have indentified this problem as happening due to the popup getting enclosed in another div with position:fixedthat I cannot avoid due to a fixed sidebar feature I am using that encloses all the content in the body and encloses it in a se

Apache: how can I access my webpage from a computer outside my network?

Apache: how can I access my webpage from a computer outside my network?

I want to access my webpage from a computer outside the network. Our network has IPs like 192.168.0.1-192.168.0.255. The network is connected to Internet through a local gateway 192.168.0.1 and gets to DNS server 193.xxx.xxx.xxx.Let's say m

MVC App causing IE9 to use older standards

MVC App causing IE9 to use older standards

When I tested a new asp.net MVC app I created on another machine the layout was incorrect and seemed strange in IE9. When looking at Developer Tools the Mode/Standards were set to older versions and even Compatibility Mode. I changed this

Deepzoom for WPF [closed]

Deepzoom for WPF [closed]

Are there any ports to WPF of Silverlight's MultiScaleImage (aka DeepZoom)? Have Microsoft road-mapped this at all for WPF?I want to move from WinForms to WPF and require something like DeepZoom, using Silverlight isn't an option. 1:At

How do you flush Python sockets?

How do you flush Python sockets?

I've written a server in Python that is meant to send data to the client in the form "Header:Message"I would like to be able to have each message sent individually so that the client will need to perform minimal work in order to read the "

How do I allow CTRL-V (Paste) on a Winforms Textbox?

How do I allow CTRL-V (Paste) on a Winforms Textbox?

I have several textboxes on a windows form.I can't paste text into any of them using CTRL-V, though I can still right click and select paste. This is pretty annoying.I have tried this with the form's KeyPreview as both true and false. Text

Creating a security scope bookmark for a file from one of a directory containing it

Creating a security scope bookmark for a file from one of a directory containing it

I have a security scope bookmark for a directory, provided by a user via an openDialog request.I'm trying to create another security scope bookmark for a file inside this directory:NSURL *musicFolder = /* Secured URL Resolved from a NSData,

Stdout encoding in python

Stdout encoding in python

Is there a good reason why I shouldn't start all my python programs with this? Is there something special lost when doing exec like this?#!/usr/bin/pythonimport os, sysif sys.stdout.encoding == None: os.putenv("PYTHONIOENCODING",'UTF-8')

MongoDb Database vs Collection

MongoDb Database vs Collection

I am designing a system with MongoDb (64 bit version) to handle a large amount of users (around 100,000) and each user will have large amounts of data (around 1 million records). What is the best strategy of design?Dump all records in singl

Convert a LaTex formula to a type that can be used inside SymPy

Convert a LaTex formula to a type that can be used inside SymPy

I want to parse LaTeX formulas and directly use them as SymPy expressions. In other words, what I need is something similar to sympify:from sympy import sympifyf = sympify('x^2 + sin(y) + 1/2')print fbut that can take LaTeX expressions (str

What's the difference between static inline, extern inline and a normal inline function?

What's the difference between static inline, extern inline and a normal inline function?

What's the difference between a static inline, extern inline and a normal inline function?I've seen some vague explanations about this. As far as I've understood, static inline is not just an inline function that is meant to only be referre

Tail Recursion in Haskell

Tail Recursion in Haskell

I am trying to understand tail-recursion in Haskell. I think I understand what it is and how it works but I'd like to make sure I am not messing things up.Here is the "standard" factorial definition:factorial 1 = 1factorial k = k * factoria

Find process id by window's handle

Find process id by window's handle

i have a problem with getting a specific PID of a process, the problem with this process is that it's a hidden process, it's not showing on task manager / powershell, completely hidden.what i have do far is the main window handle of this pr