Why does flowing off the end of a non-void function without returning a value not produce a compiler

Why does flowing off the end of a non-void function without returning a value not produce a compiler

Ever since I realized many years ago, that this doesn't produce an error by default, (in gcc at least) I've always wondered why?I understand that you can issue compiler flags to produce a warning, but shouldn't it always be an error? Why do

Listening for variable changes in JavaScript

Listening for variable changes in JavaScript

Is it possible to have an event in JS that fires when the value of a certain variable changes? JQuery is accepted. 1:Yes, object.watch (it's non-standard though). Here's my implementation that works in every current major browser. 2:Y

PHP's white screen of death

PHP's white screen of death

Now that I'm starting to get back into PHP, I'm starting to remember why I gave it up in the first place. The most annoying thing on my plate at the moment is what I've come to term "PHP's white screen of death". When PHP gets a fatal error

Twitter Bootstrap - Print all tab content

Twitter Bootstrap - Print all tab content

I have the basic bootstrap tabs set up with no dynamically inserted content and print specific media queries in my base stylesheet. When the user prints from the browser I want all the tab content to print, not just the active tab. I know t

How do you do polymorphism in Ruby?

How do you do polymorphism in Ruby?

In C#, I can do this:class Program{ static void Main(string[] args) { List animals = new List(); animals.Add(new Dog()); animals.Add(new Cat()); foreach (Animal a in animals) {

Truncate a decimal value in Python

Truncate a decimal value in Python

I am trying to truncate a decimal value in Python. I don't want to round it, but instead just display the decimal values upto the specified accuracy. I tried the following:d = 0.989434'{:.{prec}f}'.format(d, prec=2)This rounds it to 0.99. B

is there a way to pass nested initializer lists in C++11 to construct a 2D matrix?

is there a way to pass nested initializer lists in C++11 to construct a 2D matrix?

Imagine you have a simple matrix classtemplate class Matrix { T* data; size_t row, col;public: Matrix(size_t m, size_t n) : row(m), col(n), data(new T[m*n]) {} //... friend std::ostream& operatorIs there a way that I can initial

Eclipse/javac disagree on compiling signature with default method collision; who is right?

Eclipse/javac disagree on compiling signature with default method collision; who is right?

Here's a simple class that demonstrates the issue:package com.mimvista.debug;public class DefaultCollisionTest { public static interface Interface1 { public String getName(); } public static interface Interface2 { pub

dateutil and pytz give different results

dateutil and pytz give different results

I have an issue comparing outputs with dateutil and pytz. I'm creating a aware datetime object (UTC) and then converting to a given time zone, but I get different answers. I suspect that dateutil sometimes gives wrong results because it has

Delete all objects in a list

Delete all objects in a list

I create many object then I store in a list. But I want to delete them after some time because I create news one and don't want my memory goes high (in my case, it jumps to 20 gigs of ram if I don't delete it).Here is a little code to illus

What does it mean to have an index to scalar variable error? python

What does it mean to have an index to scalar variable error? python

import numpy as npwith open('matrix.txt', 'r') as f: x = [] for line in f: x.append(map(int, line.split()))f.close()a = array(x)l, v = eig(a)exponent = array(exp(l))L = identity(len(l))for i in xrange(len(l)): L[i][i] = expo

resize with averaging or rebin a numpy 2d array

resize with averaging or rebin a numpy 2d array

I am trying to reimplement in python an IDL function:http://star.pst.qub.ac.uk/idl/REBIN.htmlwhich downsizes by an integer factor a 2d array by averaging.For example:>>> a=np.arange(24).reshape((4,6))>>> aarray([[ 0, 1, 2, 3, 4, 5],

How to unbox from object to type it contains, not knowing that type at compile time?

How to unbox from object to type it contains, not knowing that type at compile time?

At the run-time I get boxed instance of some type. How to unbox it to underlying type?Object obj;String variable = "Some text";obj = variable // boxing;// explicit unboxing, because we know the type of variable at compile time.var x = (Stri

Get the current value of env.hosts list with Python Fabric Library

Get the current value of env.hosts list with Python Fabric Library

I've got this code (foo and bar are local servers):env.hosts = ['foo', 'bar']def mytask(): print(env.hosts[0])Which, of course prints foo every iteration.As you probably know, Fabric iterates through the env.hosts list and executes mytas

output the command line called by subprocess?

output the command line called by subprocess?

I'm using the subprocess.Popen call, and in another question I found out that I had been misunderstanding how Python was generating arguments for the command line. My QuestionIs there a way to find out what the actual command line was? Ex

Cast Flask form value to int

Cast Flask form value to int

I'm trying to get the post data in flask @app.route('/getpersonbyid', methods = ['POST']) def getPersonById(): personId = (int)(request.form['personId']) print personIdI'm sending the data "personId" via POST in RESTClie

Get only unique elements from two lists python

Get only unique elements from two lists python

if i have two lists (may be with different len):x = [1,2,3,4]f = [1,11,22,33,44,3,4]result = [11,22,33,44]im doing:for element in f: if element in x: f.remove(element)im gettingresult = [11,22,33,44,4] 1:If you want the unique

Finding the actual runtime call tree of a Java Program

Finding the actual runtime call tree of a Java Program

Suppose I have a big program that consists of hundreds of methods in it. And according to the nature of input the program flow is getting changed. Think I want to make a change to the original flow. And it is big hassle to find call hierarc

Change TCP Payload with nfqueue/scapy

Change TCP Payload with nfqueue/scapy

Hello I am using nfqueue and scapy and I my goal is to recieve packets at my NFQUEUE, change the payload and resend them.I can change fields like the TTL without any kind of problem, but when it comes to change the payload, I am encoutering

Variable assignment within a for-loop [duplicate]

Variable assignment within a for-loop [duplicate]

Possible Duplicate: R: How to convert string to variable name? In R, I'm writing a for-loop that will iteratively create variable names and then assign values to each variable.Here is a simplified version. The intention is to create the v

How do I get a tabbed pane component in JSF 2.0 (Sun Mojarra)

How do I get a tabbed pane component in JSF 2.0 (Sun Mojarra)

I am learning/using JSF 2.0 (Sun Mojarra) now and I want to have a tabbed pane in my webapp (single tabs could named be General, Detail1,Detail2,...).How do I achieve this? I haven't found any documetation for this so far :( 1:Others hav

Return values from one script to another script

Return values from one script to another script

I have the following script that will run each script (sequentially) in a directory:import osdirectory = []for dirpath, dirnames, filenames in os.walk("path\to\scripts"): for filename in [f for f in filenames if f.endswith(".py")]:

Python PyQT: How to call a GUI function from a worker thread?

Python PyQT: How to call a GUI function from a worker thread?

I have a pyqt gui and calling a long process (ffmpeg) which I put on a separate thread to not block the gui. I then want to update a progress bar when one command of a longer list of commands finishes. The problem is, that I can't call a fu

How to get a Matplotlib figure to scroll + resize properly in a Tkinter GUI

How to get a Matplotlib figure to scroll + resize properly in a Tkinter GUI

I have a Tkinter GUI which displays a Matplotlib plot (Python 2.7.3 with Matplotlib 1.2.0rc2) and lets the user configure certain aspects of the plot. The plots tend to get large, so the figure is wrapped in a scrolling canvas. One aspect o

How to properly highlight points in ggplot2 plots that use facets

How to properly highlight points in ggplot2 plots that use facets

In the following example I create two series of points and plot them using ggplot2. I also highlight several points based on their valueslibrary(ggplot2)x And here is the resultNow I want to separate the two cases into two facets, keeping t